diff options
Diffstat (limited to 'applets/brightness')
-rw-r--r-- | applets/brightness/Makefile.am | 9 | ||||
-rw-r--r-- | applets/brightness/brightness-applet.c | 295 | ||||
-rw-r--r-- | applets/brightness/egg-dbus-monitor.c | 251 | ||||
-rw-r--r-- | applets/brightness/egg-dbus-monitor.h | 65 | ||||
-rw-r--r-- | applets/brightness/gpm-common.c | 132 | ||||
-rw-r--r-- | applets/brightness/gpm-common.h | 147 |
6 files changed, 148 insertions, 751 deletions
diff --git a/applets/brightness/Makefile.am b/applets/brightness/Makefile.am index 56ecd5a..7962787 100644 --- a/applets/brightness/Makefile.am +++ b/applets/brightness/Makefile.am @@ -2,10 +2,9 @@ AM_CPPFLAGS = \ -I. -I$(srcdir) \ $(GLIB_CFLAGS) \ $(DBUS_CFLAGS) \ - $(MATE_CFLAGS) \ + $(CAIRO_CFLAGS) \ $(PANEL_CFLAGS) \ $(LIBNOTIFY_CFLAGS) \ - $(GTKUNIQUE_CFLAGS) \ -DBINDIR=\"$(bindir)\" \ -DMATELOCALEDIR=\""$(datadir)/locale"\" \ -DDATADIR=\"$(datadir)\" \ @@ -19,7 +18,6 @@ AM_CPPFLAGS = \ -DEGG_VERBOSE="\"GPM_VERBOSE\"" \ -DEGG_LOGGING="\"GPM_LOGGING\"" \ -DEGG_CONSOLE="\"GPM_CONSOLE\"" \ - -I$(top_srcdir)/libdbus-glib \ $(DISABLE_DEPRECATED) $(NULL) @@ -27,8 +25,6 @@ libexec_PROGRAMS=mate-brightness-applet mate_brightness_applet_SOURCES = \ brightness-applet.c \ - egg-dbus-monitor.c \ - egg-dbus-monitor.h \ egg-debug.c \ egg-debug.h \ gpm-common.c \ @@ -36,10 +32,9 @@ mate_brightness_applet_SOURCES = \ mate_brightness_applet_LDADD = \ $(DBUS_LIBS) \ - $(MATE_LIBS) \ + $(CAIRO_LIBS) \ $(PANEL_LIBS) - appletdir = $(datadir)/mate-panel/applets applet_in_files = org.mate.BrightnessApplet.mate-panel-applet.in applet_DATA = $(applet_in_files:.mate-panel-applet.in=.mate-panel-applet) diff --git a/applets/brightness/brightness-applet.c b/applets/brightness/brightness-applet.c index d3570b8..8e5345d 100644 --- a/applets/brightness/brightness-applet.c +++ b/applets/brightness/brightness-applet.c @@ -22,12 +22,9 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif -/* FIXME: gdk_gc_* needs porting to cairo */ -#undef GDK_DISABLE_DEPRECATED - #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -35,16 +32,10 @@ #include <gtk/gtk.h> #include <glib/gi18n.h> #include <gdk/gdkkeysyms.h> -#if GTK_CHECK_VERSION (3, 0, 0) -#include <gdk/gdkkeysyms-compat.h> -#define GtkObject GtkWidget -#endif #include <glib-object.h> #include <dbus/dbus-glib.h> -#include <libmate-desktop/mate-aboutdialog.h> #include "egg-debug.h" -#include "egg-dbus-monitor.h" #include "gpm-common.h" #define GPM_TYPE_BRIGHTNESS_APPLET (gpm_brightness_applet_get_type ()) @@ -67,7 +58,7 @@ typedef struct{ /* connection to g-p-m */ DBusGProxy *proxy; DBusGConnection *connection; - EggDbusMonitor *monitor; + guint bus_watch_id; guint level; /* a cache for panel size */ gint size; @@ -80,6 +71,10 @@ typedef struct{ GType gpm_brightness_applet_get_type (void); +#define GPM_DBUS_SERVICE "org.mate.PowerManager" +#define GPM_DBUS_PATH_BACKLIGHT "/org/mate/PowerManager/Backlight" +#define GPM_DBUS_INTERFACE_BACKLIGHT "org.mate.PowerManager.Backlight" + static void gpm_brightness_applet_class_init (GpmBrightnessAppletClass *klass); static void gpm_brightness_applet_init (GpmBrightnessApplet *applet); @@ -90,11 +85,7 @@ static void gpm_applet_check_size (GpmBrightnessApplet *applet); static gboolean gpm_applet_draw_cb (GpmBrightnessApplet *applet); static void gpm_applet_change_background_cb (GpmBrightnessApplet *applet, MatePanelAppletBackgroundType arg1, -#if GTK_CHECK_VERSION (3, 0, 0) cairo_pattern_t *arg2, gpointer data); -#else - GdkColor *arg2, GdkPixmap *arg3, gpointer data); -#endif static void gpm_applet_theme_change_cb (GtkIconTheme *icon_theme, gpointer data); static void gpm_applet_stop_scroll_events_cb (GtkWidget *widget, GdkEvent *event); static gboolean gpm_applet_destroy_popup_cb (GpmBrightnessApplet *applet); @@ -109,7 +100,7 @@ static void gpm_applet_create_popup (GpmBrightnessApplet *applet); static gboolean gpm_applet_popup_cb (GpmBrightnessApplet *applet, GdkEventButton *event); static void gpm_applet_dialog_about_cb (GtkAction *action, gpointer data); static gboolean gpm_applet_cb (MatePanelApplet *_applet, const gchar *iid, gpointer data); -static void gpm_applet_destroy_cb (GtkObject *object); +static void gpm_applet_destroy_cb (GtkWidget *widget); #define GPM_BRIGHTNESS_APPLET_ID "BrightnessApplet" #define GPM_BRIGHTNESS_APPLET_FACTORY_ID "BrightnessAppletFactory" @@ -268,16 +259,10 @@ static gboolean gpm_applet_draw_cb (GpmBrightnessApplet *applet) { gint w, h, bg_type; -#if GTK_CHECK_VERSION (3, 0, 0) GdkRGBA color; cairo_t *cr; cairo_pattern_t *pattern; GtkStyleContext *context; -#else - GdkColor color; - GdkGC *gc; - GdkPixmap *background; -#endif GtkAllocation allocation; if (gtk_widget_get_window (GTK_WIDGET(applet)) == NULL) { @@ -300,74 +285,38 @@ gpm_applet_draw_cb (GpmBrightnessApplet *applet) w = allocation.width; h = allocation.height; -#if GTK_CHECK_VERSION (3, 0, 0) cr = gdk_cairo_create (gtk_widget_get_window (GTK_WIDGET(applet))); -#else - gc = gdk_gc_new (gtk_widget_get_window (GTK_WIDGET(applet))); -#endif /* draw pixmap background */ -#if GTK_CHECK_VERSION (3, 0, 0) bg_type = mate_panel_applet_get_background (MATE_PANEL_APPLET (applet), &color, &pattern); -#else - bg_type = mate_panel_applet_get_background (MATE_PANEL_APPLET (applet), &color, &background); -#endif if (bg_type == PANEL_PIXMAP_BACKGROUND && !applet->popped) { /* fill with given background pixmap */ -#if GTK_CHECK_VERSION (3, 0, 0) cairo_set_source (cr, pattern); cairo_rectangle (cr, 0, 0, w, h); cairo_fill (cr); -#else - gdk_draw_drawable (gtk_widget_get_window (GTK_WIDGET(applet)), gc, background, 0, 0, 0, 0, w, h); -#endif } /* draw color background */ if (bg_type == PANEL_COLOR_BACKGROUND && !applet->popped) { -#if GTK_CHECK_VERSION (3, 0, 0) gdk_cairo_set_source_rgba (cr, &color); cairo_rectangle (cr, 0, 0, w, h); cairo_fill (cr); -#else - gdk_gc_set_rgb_fg_color (gc,&color); - gdk_gc_set_fill (gc,GDK_SOLID); - gdk_draw_rectangle (gtk_widget_get_window (GTK_WIDGET(applet)), gc, TRUE, 0, 0, w, h); -#endif } /* fill with selected color if popped */ if (applet->popped) { -#if GTK_CHECK_VERSION (3, 0, 0) context = gtk_widget_get_style_context (GTK_WIDGET(applet)); gtk_style_context_get_color (context, GTK_STATE_FLAG_SELECTED, &color); gdk_cairo_set_source_rgba (cr, &color); cairo_rectangle (cr, 0, 0, w, h); cairo_fill (cr); -#else - color = gtk_rc_get_style (GTK_WIDGET(applet))->bg[GTK_STATE_SELECTED]; - gdk_gc_set_rgb_fg_color (gc,&color); - gdk_gc_set_fill (gc,GDK_SOLID); - gdk_draw_rectangle (gtk_widget_get_window (GTK_WIDGET(applet)), gc, TRUE, 0, 0, w, h); -#endif } /* draw icon at center */ -#if GTK_CHECK_VERSION (3, 0, 0) gdk_cairo_set_source_pixbuf (cr, applet->icon, (w - applet->icon_width)/2, (h - applet->icon_height)/2); cairo_paint (cr); -#else - gdk_draw_pixbuf (gtk_widget_get_window (GTK_WIDGET(applet)), gc, applet->icon, - 0, 0, (w - applet->icon_width)/2, (h - applet->icon_height)/2, - applet->icon_width, applet->icon_height, - GDK_RGB_DITHER_NONE, 0, 0); -#endif -#if GTK_CHECK_VERSION (3, 0, 0) cairo_destroy (cr); -#else - g_object_unref (gc); -#endif return TRUE; } @@ -380,11 +329,7 @@ gpm_applet_draw_cb (GpmBrightnessApplet *applet) static void gpm_applet_change_background_cb (GpmBrightnessApplet *applet, MatePanelAppletBackgroundType arg1, -#if GTK_CHECK_VERSION (3, 0, 0) cairo_pattern_t *arg2, gpointer data) -#else - GdkColor *arg2, GdkPixmap *arg3, gpointer data) -#endif { gtk_widget_queue_draw (GTK_WIDGET (applet)); } @@ -520,19 +465,19 @@ gpm_applet_key_press_cb (GpmBrightnessApplet *applet, GdkEventKey *event) int i; switch (event->keyval) { - case GDK_KP_Enter: - case GDK_ISO_Enter: - case GDK_3270_Enter: - case GDK_Return: - case GDK_space: - case GDK_KP_Space: - case GDK_Escape: + case GDK_KEY_KP_Enter: + case GDK_KEY_ISO_Enter: + case GDK_KEY_3270_Enter: + case GDK_KEY_Return: + case GDK_KEY_space: + case GDK_KEY_KP_Space: + case GDK_KEY_Escape: /* if yet popped, release focus and hide then redraw applet unselected */ if (applet->popped) { gdk_keyboard_ungrab (GDK_CURRENT_TIME); gdk_pointer_ungrab (GDK_CURRENT_TIME); gtk_grab_remove (GTK_WIDGET(applet)); - gtk_widget_set_state (GTK_WIDGET(applet), GTK_STATE_NORMAL); + gtk_widget_set_state_flags (GTK_WIDGET(applet), GTK_STATE_FLAG_NORMAL, TRUE); gtk_widget_hide (applet->popup); applet->popped = FALSE; gpm_applet_draw_cb (applet); @@ -542,25 +487,25 @@ gpm_applet_key_press_cb (GpmBrightnessApplet *applet, GdkEventKey *event) return FALSE; } break; - case GDK_Page_Up: + case GDK_KEY_Page_Up: for (i = 0;i < 10;i++) { gpm_applet_plus_cb (NULL, applet); } return TRUE; break; - case GDK_Left: - case GDK_Up: + case GDK_KEY_Left: + case GDK_KEY_Up: gpm_applet_plus_cb (NULL, applet); return TRUE; break; - case GDK_Page_Down: + case GDK_KEY_Page_Down: for (i = 0;i < 10;i++) { gpm_applet_minus_cb (NULL, applet); } return TRUE; break; - case GDK_Right: - case GDK_Down: + case GDK_KEY_Right: + case GDK_KEY_Down: gpm_applet_minus_cb (NULL, applet); return TRUE; break; @@ -604,6 +549,35 @@ gpm_applet_scroll_cb (GpmBrightnessApplet *applet, GdkEventScroll *event) } /** + * on_popup_button_press: + * @applet: Brightness applet instance + * @event: The button press event + * + * hide popup on focus loss. + **/ +static gboolean +on_popup_button_press (GtkWidget *widget, + GdkEventButton *event, + GpmBrightnessApplet *applet) +{ + GtkWidget *event_widget; + + if (event->type != GDK_BUTTON_PRESS) { + return FALSE; + } + event_widget = gtk_get_event_widget ((GdkEvent *)event); + g_debug ("Button press: %p dock=%p", event_widget, widget); + if (event_widget == widget) { + gtk_widget_hide (applet->popup); + applet->popped = FALSE; + gpm_applet_update_tooltip (applet); + return TRUE; + } + + return FALSE; +} + +/** * gpm_applet_create_popup: * @applet: Brightness applet instance * @@ -619,10 +593,10 @@ gpm_applet_create_popup (GpmBrightnessApplet *applet) /* slider */ if (MATE_PANEL_APPLET_VERTICAL(orientation)) { - applet->slider = gtk_hscale_new_with_range (0, 100, 1); + applet->slider = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 100, 1); gtk_widget_set_size_request (applet->slider, 100, -1); } else { - applet->slider = gtk_vscale_new_with_range (0, 100, 1); + applet->slider = gtk_scale_new_with_range (GTK_ORIENTATION_VERTICAL, 0, 100, 1); gtk_widget_set_size_request (applet->slider, -1, 100); } gtk_range_set_inverted (GTK_RANGE(applet->slider), TRUE); @@ -633,18 +607,20 @@ gpm_applet_create_popup (GpmBrightnessApplet *applet) /* minus button */ applet->btn_minus = gtk_button_new_with_label ("\342\210\222"); /* U+2212 MINUS SIGN */ gtk_button_set_relief (GTK_BUTTON(applet->btn_minus), GTK_RELIEF_NONE); + gtk_widget_set_can_focus (applet->btn_minus, FALSE); g_signal_connect (G_OBJECT(applet->btn_minus), "pressed", G_CALLBACK(gpm_applet_minus_cb), applet); /* plus button */ applet->btn_plus = gtk_button_new_with_label ("+"); gtk_button_set_relief (GTK_BUTTON(applet->btn_plus), GTK_RELIEF_NONE); + gtk_widget_set_can_focus (applet->btn_plus, FALSE); g_signal_connect (G_OBJECT(applet->btn_plus), "pressed", G_CALLBACK(gpm_applet_plus_cb), applet); /* box */ if (MATE_PANEL_APPLET_VERTICAL(orientation)) { - box = gtk_hbox_new (FALSE, 1); + box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 1); } else { - box = gtk_vbox_new (FALSE, 1); + box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 1); } gtk_box_pack_start (GTK_BOX(box), applet->btn_plus, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(box), applet->slider, TRUE, TRUE, 0); @@ -657,12 +633,25 @@ gpm_applet_create_popup (GpmBrightnessApplet *applet) /* window */ applet->popup = gtk_window_new (GTK_WINDOW_POPUP); -#if !GTK_CHECK_VERSION (2, 90, 0) - GTK_WIDGET_UNSET_FLAGS (applet->popup, GTK_TOPLEVEL); -#endif gtk_window_set_type_hint (GTK_WINDOW(applet->popup), GDK_WINDOW_TYPE_HINT_UTILITY); - gtk_widget_set_parent (applet->popup, GTK_WIDGET(applet)); gtk_container_add (GTK_CONTAINER(applet->popup), frame); + + /* window events */ + g_signal_connect (G_OBJECT(applet->popup), "button-press-event", + G_CALLBACK (on_popup_button_press), applet); + + g_signal_connect (G_OBJECT(applet->popup), "key-press-event", + G_CALLBACK(gpm_applet_key_press_cb), applet); + + /* Set volume control frame, slider and toplevel window to follow panel volume control theme */ + GtkWidget *toplevel = gtk_widget_get_toplevel (frame); + GtkStyleContext *context; + context = gtk_widget_get_style_context (GTK_WIDGET(toplevel)); + gtk_style_context_add_class(context,"mate-panel-applet-slider"); + /*Make transparency possible in gtk3 theme3 */ + GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel)); + GdkVisual *visual = gdk_screen_get_rgba_visual(screen); + gtk_widget_set_visual(GTK_WIDGET(toplevel), visual); } /** @@ -676,6 +665,11 @@ gpm_applet_popup_cb (GpmBrightnessApplet *applet, GdkEventButton *event) { GtkAllocation allocation, popup_allocation; gint orientation, x, y; + GdkWindow *window; + GdkDisplay *display; + GdkDeviceManager *device_manager; + GdkDevice *pointer; + GdkDevice *keyboard; /* react only to left mouse button */ if (event->button != 1) { @@ -684,23 +678,19 @@ gpm_applet_popup_cb (GpmBrightnessApplet *applet, GdkEventButton *event) /* if yet popped, release focus and hide then redraw applet unselected */ if (applet->popped) { - gdk_keyboard_ungrab (GDK_CURRENT_TIME); - gdk_pointer_ungrab (GDK_CURRENT_TIME); - gtk_grab_remove (GTK_WIDGET(applet)); - gtk_widget_set_state (GTK_WIDGET(applet), GTK_STATE_NORMAL); gtk_widget_hide (applet->popup); applet->popped = FALSE; - gpm_applet_draw_cb (applet); gpm_applet_update_tooltip (applet); return TRUE; } - /* update UI for current brightness */ - gpm_applet_update_popup_level (applet); + /* don't show the popup if brightness is unavailable */ + if (applet->level == -1) { + return FALSE; + } /* otherwise pop */ applet->popped = TRUE; - gpm_applet_draw_cb (applet); /* create a new popup (initial or if panel parameters changed) */ if (applet->popup == NULL) { @@ -748,16 +738,19 @@ gpm_applet_popup_cb (GpmBrightnessApplet *applet, GdkEventButton *event) gtk_window_move (GTK_WINDOW (applet->popup), x, y); /* grab input */ - gtk_widget_grab_focus (GTK_WIDGET(applet)); - gtk_grab_add (GTK_WIDGET(applet)); - gdk_pointer_grab (gtk_widget_get_window (GTK_WIDGET(applet)), TRUE, - GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_POINTER_MOTION_MASK, - NULL, NULL, GDK_CURRENT_TIME); - gdk_keyboard_grab (gtk_widget_get_window (GTK_WIDGET(applet)), - TRUE, GDK_CURRENT_TIME); - gtk_widget_set_state (GTK_WIDGET(applet), GTK_STATE_SELECTED); + window = gtk_widget_get_window (GTK_WIDGET (applet->popup)); + display = gdk_window_get_display (window); + device_manager = gdk_display_get_device_manager (display); + pointer = gdk_device_manager_get_client_pointer (device_manager); + keyboard = gdk_device_get_associated_device (pointer); + gdk_device_grab (pointer, window, + GDK_OWNERSHIP_NONE, TRUE, + GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK, + NULL, GDK_CURRENT_TIME); + gdk_device_grab (keyboard, window, + GDK_OWNERSHIP_NONE, TRUE, + GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK, + NULL, GDK_CURRENT_TIME); return TRUE; } @@ -794,7 +787,7 @@ gpm_applet_stop_scroll_events_cb (GtkWidget *widget, GdkEvent *event) static void gpm_applet_dialog_about_cb (GtkAction *action, gpointer data) { - MateAboutDialog *about; + GtkAboutDialog *about; GdkPixbuf *logo = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), @@ -806,6 +799,11 @@ gpm_applet_dialog_about_cb (GtkAction *action, gpointer data) "Richard Hughes <[email protected]>", NULL }; + + char copyright[] = \ + "Copyright \xc2\xa9 2012-2016 MATE developers\n" + "Copyright \xc2\xa9 2006 Benjamin Canou"; + const char *documenters [] = { NULL }; @@ -830,17 +828,17 @@ gpm_applet_dialog_about_cb (GtkAction *action, gpointer data) license_trans = g_strconcat (_(license[0]), "\n\n", _(license[1]), "\n\n", _(license[2]), "\n\n", _(license[3]), "\n", NULL); - about = (MateAboutDialog*) mate_about_dialog_new (); - mate_about_dialog_set_program_name (about, GPM_BRIGHTNESS_APPLET_NAME); - mate_about_dialog_set_version (about, VERSION); - mate_about_dialog_set_copyright (about, _("Copyright \xc2\xa9 2006 Benjamin Canou")); - mate_about_dialog_set_comments (about, GPM_BRIGHTNESS_APPLET_DESC); - mate_about_dialog_set_authors (about, authors); - mate_about_dialog_set_documenters (about, documenters); - mate_about_dialog_set_translator_credits (about, translator_credits); - mate_about_dialog_set_logo (about, logo); - mate_about_dialog_set_license (about, license_trans); - mate_about_dialog_set_website (about, GPM_HOMEPAGE_URL); + about = (GtkAboutDialog*) gtk_about_dialog_new (); + gtk_about_dialog_set_program_name (about, GPM_BRIGHTNESS_APPLET_NAME); + gtk_about_dialog_set_version (about, VERSION); + gtk_about_dialog_set_copyright (about, copyright); + gtk_about_dialog_set_comments (about, GPM_BRIGHTNESS_APPLET_DESC); + gtk_about_dialog_set_authors (about, authors); + gtk_about_dialog_set_documenters (about, documenters); + gtk_about_dialog_set_translator_credits (about, translator_credits); + gtk_about_dialog_set_logo (about, logo); + gtk_about_dialog_set_license (about, license_trans); + gtk_about_dialog_set_website (about, "http://www.mate-desktop.org/"); g_signal_connect (G_OBJECT(about), "response", G_CALLBACK(gtk_widget_destroy), NULL); @@ -864,19 +862,16 @@ gpm_applet_help_cb (GtkAction *action, gpointer data) /** * gpm_applet_destroy_cb: - * @object: Class instance to destroy + * @widget: Class instance to destroy **/ static void -gpm_applet_destroy_cb (GtkObject *object) +gpm_applet_destroy_cb (GtkWidget *widget) { - GpmBrightnessApplet *applet = GPM_BRIGHTNESS_APPLET(object); + GpmBrightnessApplet *applet = GPM_BRIGHTNESS_APPLET(widget); - if (applet->monitor != NULL) { - g_object_unref (applet->monitor); - } - if (applet->icon != NULL) { + g_bus_unwatch_name (applet->bus_watch_id); + if (applet->icon != NULL) g_object_unref (applet->icon); - } } /** @@ -957,25 +952,30 @@ gpm_brightness_applet_dbus_disconnect (GpmBrightnessApplet *applet) } /** - * monitor_connection_cb: - * @proxy: The dbus raw proxy - * @status: The status of the service, where TRUE is connected - * @screensaver: This class instance + * gpm_brightness_applet_name_appeared_cb: **/ static void -monitor_connection_cb (EggDbusMonitor *monitor, - gboolean status, - GpmBrightnessApplet *applet) +gpm_brightness_applet_name_appeared_cb (GDBusConnection *connection, + const gchar *name, + const gchar *name_owner, + GpmBrightnessApplet *applet) { - if (status) { - gpm_brightness_applet_dbus_connect (applet); - gpm_applet_update_tooltip (applet); - gpm_applet_draw_cb (applet); - } else { - gpm_brightness_applet_dbus_disconnect (applet); - gpm_applet_update_tooltip (applet); - gpm_applet_draw_cb (applet); - } + gpm_brightness_applet_dbus_connect (applet); + gpm_applet_update_tooltip (applet); + gpm_applet_draw_cb (applet); +} + +/** + * gpm_brightness_applet_name_vanished_cb: + **/ +void +gpm_brightness_applet_name_vanished_cb (GDBusConnection *connection, + const gchar *name, + GpmBrightnessApplet *applet) +{ + gpm_brightness_applet_dbus_disconnect (applet); + gpm_applet_update_tooltip (applet); + gpm_applet_draw_cb (applet); } /** @@ -1001,12 +1001,14 @@ gpm_brightness_applet_init (GpmBrightnessApplet *applet) GPM_DATA G_DIR_SEPARATOR_S "icons"); - applet->monitor = egg_dbus_monitor_new (); - g_signal_connect (applet->monitor, "connection-changed", - G_CALLBACK (monitor_connection_cb), applet); - connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL); - egg_dbus_monitor_assign (applet->monitor, connection, GPM_DBUS_SERVICE); - gpm_brightness_applet_dbus_connect (applet); + /* monitor the daemon */ + applet->bus_watch_id = + g_bus_watch_name (G_BUS_TYPE_SESSION, + GPM_DBUS_SERVICE, + G_BUS_NAME_WATCHER_FLAGS_NONE, + (GBusNameAppearedCallback) gpm_brightness_applet_name_appeared_cb, + (GBusNameVanishedCallback) gpm_brightness_applet_name_vanished_cb, + applet, NULL); /* coldplug */ applet->call_worked = gpm_applet_get_brightness (applet); @@ -1034,13 +1036,8 @@ gpm_brightness_applet_init (GpmBrightnessApplet *applet) /* We use g_signal_connect_after because letting the panel draw * the background is the only way to have the correct * background when a theme defines a background picture. */ -#if GTK_CHECK_VERSION (3, 0, 0) g_signal_connect_after (G_OBJECT(applet), "draw", G_CALLBACK(gpm_applet_draw_cb), NULL); -#else - g_signal_connect_after (G_OBJECT(applet), "expose-event", - G_CALLBACK(gpm_applet_draw_cb), NULL); -#endif g_signal_connect (G_OBJECT(applet), "change-background", G_CALLBACK(gpm_applet_change_background_cb), NULL); diff --git a/applets/brightness/egg-dbus-monitor.c b/applets/brightness/egg-dbus-monitor.c deleted file mode 100644 index b8238d1..0000000 --- a/applets/brightness/egg-dbus-monitor.c +++ /dev/null @@ -1,251 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2006-2008 Richard Hughes <[email protected]> - * - * Licensed under the GNU General Public License Version 2 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> -#include <stdlib.h> -#include <stdio.h> -#include <glib.h> -#include <dbus/dbus-glib.h> -#include <dbus/dbus-glib-lowlevel.h> -#include <dbus/dbus.h> - -#include "egg-debug.h" -#include "egg-dbus-monitor.h" - -static void egg_dbus_monitor_finalize (GObject *object); - -#define EGG_DBUS_MONITOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EGG_TYPE_DBUS_MONITOR, EggDbusMonitorPrivate)) - -struct EggDbusMonitorPrivate -{ - gchar *service; - DBusGProxy *proxy; - DBusGConnection *connection; - const gchar *unique_name; -}; - -enum { - EGG_DBUS_MONITOR_CONNECTION_CHANGED, - EGG_DBUS_MONITOR_CONNECTION_REPLACED, - EGG_DBUS_MONITOR_LAST_SIGNAL -}; - -static guint signals [EGG_DBUS_MONITOR_LAST_SIGNAL] = { 0 }; - -G_DEFINE_TYPE (EggDbusMonitor, egg_dbus_monitor, G_TYPE_OBJECT) - -/** - * egg_dbus_monitor_name_owner_changed_cb: - **/ -static void -egg_dbus_monitor_name_owner_changed_cb (DBusGProxy *proxy, const gchar *name, - const gchar *prev, const gchar *new, - EggDbusMonitor *monitor) -{ - guint new_len; - guint prev_len; - - g_return_if_fail (EGG_IS_DBUS_MONITOR (monitor)); - if (monitor->priv->proxy == NULL) - return; - - /* not us */ - if (strcmp (name, monitor->priv->service) != 0) - return; - - /* ITS4: ignore, not used for allocation */ - new_len = strlen (new); - /* ITS4: ignore, not used for allocation */ - prev_len = strlen (prev); - - /* something --> nothing */ - if (prev_len != 0 && new_len == 0) { - g_signal_emit (monitor, signals [EGG_DBUS_MONITOR_CONNECTION_CHANGED], 0, FALSE); - return; - } - - /* nothing --> something */ - if (prev_len == 0 && new_len != 0) { - g_signal_emit (monitor, signals [EGG_DBUS_MONITOR_CONNECTION_CHANGED], 0, TRUE); - return; - } - - /* something --> something (we've replaced the old process) */ - if (prev_len != 0 && new_len != 0) { - /* only send this to the prev client */ - if (strcmp (monitor->priv->unique_name, prev) == 0) - g_signal_emit (monitor, signals [EGG_DBUS_MONITOR_CONNECTION_REPLACED], 0); - return; - } -} - -/** - * egg_dbus_monitor_assign: - * @monitor: This class instance - * @connection: The bus connection - * @service: The EGG_DBUS_MONITOR service name - * Return value: success - * - * Emits connection-changed(TRUE) if connection is alive - this means you - * have to connect up the callback before this function is called. - **/ -gboolean -egg_dbus_monitor_assign (EggDbusMonitor *monitor, DBusGConnection *connection, const gchar *service) -{ - GError *error = NULL; - gboolean connected; - DBusConnection *conn; - - g_return_val_if_fail (EGG_IS_DBUS_MONITOR (monitor), FALSE); - g_return_val_if_fail (service != NULL, FALSE); - g_return_val_if_fail (connection != NULL, FALSE); - - if (monitor->priv->proxy != NULL) { - egg_warning ("already assigned!"); - return FALSE; - } - - monitor->priv->service = g_strdup (service); - monitor->priv->connection = connection; - monitor->priv->proxy = dbus_g_proxy_new_for_name_owner (monitor->priv->connection, - DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, - DBUS_INTERFACE_DBUS, - &error); - if (error != NULL) { - egg_warning ("Cannot connect to DBUS: %s", error->message); - g_error_free (error); - return FALSE; - } - dbus_g_proxy_add_signal (monitor->priv->proxy, "NameOwnerChanged", - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_connect_signal (monitor->priv->proxy, "NameOwnerChanged", - G_CALLBACK (egg_dbus_monitor_name_owner_changed_cb), - monitor, NULL); - - /* coldplug */ - connected = egg_dbus_monitor_is_connected (monitor); - if (connected) - g_signal_emit (monitor, signals [EGG_DBUS_MONITOR_CONNECTION_CHANGED], 0, TRUE); - - /* save this for the replaced check */ - conn = dbus_g_connection_get_connection (monitor->priv->connection); - monitor->priv->unique_name = dbus_bus_get_unique_name (conn); - return TRUE; -} - -/** - * egg_dbus_monitor_is_connected: - * @monitor: This class instance - * Return value: if we are connected to a valid watch - **/ -gboolean -egg_dbus_monitor_is_connected (EggDbusMonitor *monitor) -{ - DBusError error; - DBusConnection *conn; - gboolean ret; - g_return_val_if_fail (EGG_IS_DBUS_MONITOR (monitor), FALSE); - - /* get raw connection */ - conn = dbus_g_connection_get_connection (monitor->priv->connection); - dbus_error_init (&error); - ret = dbus_bus_name_has_owner (conn, monitor->priv->service, &error); - if (dbus_error_is_set (&error)) { - egg_debug ("error: %s", error.message); - dbus_error_free (&error); - } - - return ret; -} - -/** - * egg_dbus_monitor_class_init: - * @klass: The EggDbusMonitorClass - **/ -static void -egg_dbus_monitor_class_init (EggDbusMonitorClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - object_class->finalize = egg_dbus_monitor_finalize; - g_type_class_add_private (klass, sizeof (EggDbusMonitorPrivate)); - signals [EGG_DBUS_MONITOR_CONNECTION_CHANGED] = - g_signal_new ("connection-changed", - G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EggDbusMonitorClass, connection_changed), - NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, - G_TYPE_NONE, 1, G_TYPE_BOOLEAN); - signals [EGG_DBUS_MONITOR_CONNECTION_REPLACED] = - g_signal_new ("connection-replaced", - G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EggDbusMonitorClass, connection_replaced), - NULL, NULL, g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); -} - -/** - * egg_dbus_monitor_init: - * @monitor: This class instance - **/ -static void -egg_dbus_monitor_init (EggDbusMonitor *monitor) -{ - monitor->priv = EGG_DBUS_MONITOR_GET_PRIVATE (monitor); - monitor->priv->service = NULL; - monitor->priv->connection = NULL; - monitor->priv->proxy = NULL; -} - -/** - * egg_dbus_monitor_finalize: - * @object: The object to finalize - **/ -static void -egg_dbus_monitor_finalize (GObject *object) -{ - EggDbusMonitor *monitor; - - g_return_if_fail (EGG_IS_DBUS_MONITOR (object)); - - monitor = EGG_DBUS_MONITOR (object); - - g_return_if_fail (monitor->priv != NULL); - if (monitor->priv->proxy != NULL) - g_object_unref (monitor->priv->proxy); - - G_OBJECT_CLASS (egg_dbus_monitor_parent_class)->finalize (object); -} - -/** - * egg_dbus_monitor_new: - * - * Return value: a new EggDbusMonitor object. - **/ -EggDbusMonitor * -egg_dbus_monitor_new (void) -{ - EggDbusMonitor *monitor; - monitor = g_object_new (EGG_TYPE_DBUS_MONITOR, NULL); - return EGG_DBUS_MONITOR (monitor); -} - diff --git a/applets/brightness/egg-dbus-monitor.h b/applets/brightness/egg-dbus-monitor.h deleted file mode 100644 index 9efa8b9..0000000 --- a/applets/brightness/egg-dbus-monitor.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2008 Richard Hughes <[email protected]> - * - * Licensed under the GNU General Public License Version 2 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __EGG_DBUS_MONITOR_H -#define __EGG_DBUS_MONITOR_H - -#include <glib-object.h> -#include <dbus/dbus-glib.h> - -G_BEGIN_DECLS - -#define EGG_TYPE_DBUS_MONITOR (egg_dbus_monitor_get_type ()) -#define EGG_DBUS_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EGG_TYPE_DBUS_MONITOR, EggDbusMonitor)) -#define EGG_DBUS_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EGG_TYPE_DBUS_MONITOR, EggDbusMonitorClass)) -#define EGG_IS_DBUS_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EGG_TYPE_DBUS_MONITOR)) -#define EGG_IS_DBUS_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EGG_TYPE_DBUS_MONITOR)) -#define EGG_DBUS_MONITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EGG_TYPE_DBUS_MONITOR, EggDbusMonitorClass)) -#define EGG_DBUS_MONITOR_ERROR (egg_dbus_monitor_error_quark ()) -#define EGG_DBUS_MONITOR_TYPE_ERROR (egg_dbus_monitor_error_get_type ()) - -typedef struct EggDbusMonitorPrivate EggDbusMonitorPrivate; - -typedef struct -{ - GObject parent; - EggDbusMonitorPrivate *priv; -} EggDbusMonitor; - -typedef struct -{ - GObjectClass parent_class; - void (* connection_changed) (EggDbusMonitor *watch, - gboolean connected); - void (* connection_replaced) (EggDbusMonitor *watch); -} EggDbusMonitorClass; - -GType egg_dbus_monitor_get_type (void); -EggDbusMonitor *egg_dbus_monitor_new (void); -gboolean egg_dbus_monitor_assign (EggDbusMonitor *monitor, - DBusGConnection *connection, - const gchar *service); -gboolean egg_dbus_monitor_is_connected (EggDbusMonitor *monitor); - -G_END_DECLS - -#endif /* __EGG_DBUS_MONITOR_H */ - diff --git a/applets/brightness/gpm-common.c b/applets/brightness/gpm-common.c index 3f8a1ff..e2ea5f6 100644 --- a/applets/brightness/gpm-common.c +++ b/applets/brightness/gpm-common.c @@ -31,138 +31,6 @@ #include "gpm-common.h" /** - * gpm_get_timestring: - * @time_secs: The time value to convert in seconds - * @cookie: The cookie we are looking for - * - * Returns a localised timestring - * - * Return value: The time string, e.g. "2 hours 3 minutes" - **/ -gchar * -gpm_get_timestring (guint time_secs) -{ - char* timestring = NULL; - gint hours; - gint minutes; - - /* Add 0.5 to do rounding */ - minutes = (int) ( ( time_secs / 60.0 ) + 0.5 ); - - if (minutes == 0) { - timestring = g_strdup (_("Unknown time")); - return timestring; - } - - if (minutes < 60) { - timestring = g_strdup_printf (ngettext ("%i minute", - "%i minutes", - minutes), minutes); - return timestring; - } - - hours = minutes / 60; - minutes = minutes % 60; - - if (minutes == 0) - timestring = g_strdup_printf (ngettext ( - "%i hour", - "%i hours", - hours), hours); - else - /* TRANSLATOR: "%i %s %i %s" are "%i hours %i minutes" - * Swap order with "%2$s %2$i %1$s %1$i if needed */ - timestring = g_strdup_printf (_("%i %s %i %s"), - hours, ngettext ("hour", "hours", hours), - minutes, ngettext ("minute", "minutes", minutes)); - return timestring; -} - -/** - * gpm_icon_policy_from_string: - **/ -GpmIconPolicy -gpm_icon_policy_from_string (const gchar *policy) -{ - if (policy == NULL) - return GPM_ICON_POLICY_NEVER; - if (g_strcmp0 (policy, "always") == 0) - return GPM_ICON_POLICY_ALWAYS; - if (g_strcmp0 (policy, "present") == 0) - return GPM_ICON_POLICY_PRESENT; - if (g_strcmp0 (policy, "charge") == 0) - return GPM_ICON_POLICY_CHARGE; - if (g_strcmp0 (policy, "low") == 0) - return GPM_ICON_POLICY_LOW; - if (g_strcmp0 (policy, "critical") == 0) - return GPM_ICON_POLICY_CRITICAL; - if (g_strcmp0 (policy, "never") == 0) - return GPM_ICON_POLICY_NEVER; - return GPM_ICON_POLICY_NEVER; -} - -/** - * gpm_icon_policy_to_string: - **/ -const gchar * -gpm_icon_policy_to_string (GpmIconPolicy policy) -{ - if (policy == GPM_ICON_POLICY_ALWAYS) - return "always"; - if (policy == GPM_ICON_POLICY_PRESENT) - return "present"; - if (policy == GPM_ICON_POLICY_CHARGE) - return "charge"; - if (policy == GPM_ICON_POLICY_LOW) - return "low"; - if (policy == GPM_ICON_POLICY_CRITICAL) - return "critical"; - if (policy == GPM_ICON_POLICY_NEVER) - return "never"; - return "never"; -} - -/** - * gpm_action_policy_from_string: - **/ -GpmActionPolicy -gpm_action_policy_from_string (const gchar *policy) -{ - if (policy == NULL) - return GPM_ACTION_POLICY_NOTHING; - if (g_strcmp0 (policy, "blank") == 0) - return GPM_ACTION_POLICY_BLANK; - if (g_strcmp0 (policy, "shutdown") == 0) - return GPM_ACTION_POLICY_SHUTDOWN; - if (g_strcmp0 (policy, "suspend") == 0) - return GPM_ACTION_POLICY_SUSPEND; - if (g_strcmp0 (policy, "hibernate") == 0) - return GPM_ACTION_POLICY_HIBERNATE; - if (g_strcmp0 (policy, "interactive") == 0) - return GPM_ACTION_POLICY_INTERACTIVE; - return GPM_ACTION_POLICY_NOTHING; -} - -/** - * gpm_action_policy_to_string: - **/ -const gchar * -gpm_action_policy_to_string (GpmActionPolicy policy) -{ - if (policy == GPM_ACTION_POLICY_BLANK) - return "blank"; - if (policy == GPM_ACTION_POLICY_SHUTDOWN) - return "shutdown"; - if (policy == GPM_ACTION_POLICY_SUSPEND) - return "suspend"; - if (policy == GPM_ACTION_POLICY_HIBERNATE) - return "hibernate"; - if (policy == GPM_ACTION_POLICY_INTERACTIVE) - return "interactive"; - return "nothing"; -} - -/** * gpm_help_display: * @link_id: Subsection of mate-power-manager help section **/ diff --git a/applets/brightness/gpm-common.h b/applets/brightness/gpm-common.h index 5a6d516..323ccac 100644 --- a/applets/brightness/gpm-common.h +++ b/applets/brightness/gpm-common.h @@ -26,153 +26,6 @@ G_BEGIN_DECLS -#define GPM_DBUS_SERVICE "org.mate.PowerManager" -#define GPM_DBUS_INTERFACE "org.mate.PowerManager" -#define GPM_DBUS_INTERFACE_BACKLIGHT "org.mate.PowerManager.Backlight" -#define GPM_DBUS_PATH "/org/mate/PowerManager" -#define GPM_DBUS_PATH_BACKLIGHT "/org/mate/PowerManager/Backlight" - -/* common descriptions of this program */ -#define GPM_NAME _("Power Manager") -#define GPM_DESCRIPTION _("Power Manager for the MATE desktop") - -/* help location */ -#define GPM_HOMEPAGE_URL "http://www.mate-desktop.org/" -#define GPM_BUGZILLA_URL "https://github.com/mate-desktop/mate-power-manager/issues" -#define GPM_FAQ_URL "http://wiki.mate-desktop.org/" - -/* change general/installed_schema whenever adding or moving keys */ -#define GPM_CONF_SCHEMA_ID 3 - -#define GPM_CONF_DIR "/apps/mate-power-manager" - -/* actions */ -#define GPM_CONF_ACTIONS_CRITICAL_UPS GPM_CONF_DIR "/actions/critical_ups" -#define GPM_CONF_ACTIONS_CRITICAL_BATT GPM_CONF_DIR "/actions/critical_battery" -#define GPM_CONF_ACTIONS_LOW_UPS GPM_CONF_DIR "/actions/low_ups" -#define GPM_CONF_ACTIONS_SLEEP_TYPE_AC GPM_CONF_DIR "/actions/sleep_type_ac" -#define GPM_CONF_ACTIONS_SLEEP_TYPE_BATT GPM_CONF_DIR "/actions/sleep_type_battery" -#define GPM_CONF_ACTIONS_SLEEP_WHEN_CLOSED GPM_CONF_DIR "/actions/event_when_closed_battery" - -/* backlight stuff */ -#define GPM_CONF_BACKLIGHT_ENABLE GPM_CONF_DIR "/backlight/enable" -#define GPM_CONF_BACKLIGHT_BATTERY_REDUCE GPM_CONF_DIR "/backlight/battery_reduce" -#define GPM_CONF_BACKLIGHT_DPMS_METHOD_AC GPM_CONF_DIR "/backlight/dpms_method_ac" -#define GPM_CONF_BACKLIGHT_DPMS_METHOD_BATT GPM_CONF_DIR "/backlight/dpms_method_battery" -#define GPM_CONF_BACKLIGHT_IDLE_BRIGHTNESS GPM_CONF_DIR "/backlight/idle_brightness" -#define GPM_CONF_BACKLIGHT_IDLE_DIM_AC GPM_CONF_DIR "/backlight/idle_dim_ac" -#define GPM_CONF_BACKLIGHT_IDLE_DIM_BATT GPM_CONF_DIR "/backlight/idle_dim_battery" -#define GPM_CONF_BACKLIGHT_IDLE_DIM_TIME GPM_CONF_DIR "/backlight/idle_dim_time" -#define GPM_CONF_BACKLIGHT_BRIGHTNESS_AC GPM_CONF_DIR "/backlight/brightness_ac" -#define GPM_CONF_BACKLIGHT_BRIGHTNESS_DIM_BATT GPM_CONF_DIR "/backlight/brightness_dim_battery" - -/* buttons */ -#define GPM_CONF_BUTTON_LID_AC GPM_CONF_DIR "/buttons/lid_ac" -#define GPM_CONF_BUTTON_LID_BATT GPM_CONF_DIR "/buttons/lid_battery" -#define GPM_CONF_BUTTON_SUSPEND GPM_CONF_DIR "/buttons/suspend" -#define GPM_CONF_BUTTON_HIBERNATE GPM_CONF_DIR "/buttons/hibernate" -#define GPM_CONF_BUTTON_POWER GPM_CONF_DIR "/buttons/power" - -/* general */ -#define GPM_CONF_SCHEMA_VERSION GPM_CONF_DIR "/general/installed_schema" -#define GPM_CONF_USE_TIME_POLICY GPM_CONF_DIR "/general/use_time_for_policy" -#define GPM_CONF_USE_PROFILE_TIME GPM_CONF_DIR "/general/use_profile_time" -#define GPM_CONF_NETWORKMANAGER_SLEEP GPM_CONF_DIR "/general/network_sleep" -#define GPM_CONF_IDLE_CHECK_CPU GPM_CONF_DIR "/general/check_type_cpu" -#define GPM_CONF_LAPTOP_USES_EXT_MON GPM_CONF_DIR "/general/using_external_monitor" - -/* lock */ -#define GPM_CONF_LOCK_USE_SCREENSAVER GPM_CONF_DIR "/lock/use_screensaver_settings" -#define GPM_CONF_LOCK_ON_BLANK_SCREEN GPM_CONF_DIR "/lock/blank_screen" -#define GPM_CONF_LOCK_ON_SUSPEND GPM_CONF_DIR "/lock/suspend" -#define GPM_CONF_LOCK_ON_HIBERNATE GPM_CONF_DIR "/lock/hibernate" -#define GPM_CONF_LOCK_MATE_KEYRING_SUSPEND GPM_CONF_DIR "/lock/mate_keyring_suspend" -#define GPM_CONF_LOCK_MATE_KEYRING_HIBERNATE GPM_CONF_DIR "/lock/mate_keyring_hibernate" - -/* disks */ -#define GPM_CONF_DISKS_SPINDOWN_ENABLE_AC GPM_CONF_DIR "/disks/spindown_enable_ac" -#define GPM_CONF_DISKS_SPINDOWN_ENABLE_BATT GPM_CONF_DIR "/disks/spindown_enable_battery" -#define GPM_CONF_DISKS_SPINDOWN_TIMEOUT_AC GPM_CONF_DIR "/disks/spindown_timeout_ac" -#define GPM_CONF_DISKS_SPINDOWN_TIMEOUT_BATT GPM_CONF_DIR "/disks/spindown_timeout_battery" - -/* notify */ -#define GPM_CONF_NOTIFY_PERHAPS_RECALL GPM_CONF_DIR "/notify/perhaps_recall" -#define GPM_CONF_NOTIFY_LOW_CAPACITY GPM_CONF_DIR "/notify/low_capacity" -#define GPM_CONF_NOTIFY_DISCHARGING GPM_CONF_DIR "/notify/discharging" -#define GPM_CONF_NOTIFY_FULLY_CHARGED GPM_CONF_DIR "/notify/fully_charged" -#define GPM_CONF_NOTIFY_SLEEP_FAILED GPM_CONF_DIR "/notify/sleep_failed" -#define GPM_CONF_NOTIFY_SLEEP_FAILED_URI GPM_CONF_DIR "/notify/sleep_failed_uri" -#define GPM_CONF_NOTIFY_LOW_POWER GPM_CONF_DIR "/notify/low_power" - -/* statistics */ -#define GPM_CONF_STATS_SHOW_AXIS_LABELS GPM_CONF_DIR "/statistics/show_axis_labels" -#define GPM_CONF_STATS_SHOW_EVENTS GPM_CONF_DIR "/statistics/show_events" -#define GPM_CONF_STATS_SMOOTH_DATA GPM_CONF_DIR "/statistics/smooth_data" -#define GPM_CONF_STATS_GRAPH_TYPE GPM_CONF_DIR "/statistics/graph_type" -#define GPM_CONF_STATS_MAX_TIME GPM_CONF_DIR "/statistics/data_max_time" - -/* thresholds */ -#define GPM_CONF_THRESH_PERCENTAGE_LOW GPM_CONF_DIR "/thresholds/percentage_low" -#define GPM_CONF_THRESH_PERCENTAGE_CRITICAL GPM_CONF_DIR "/thresholds/percentage_critical" -#define GPM_CONF_THRESH_PERCENTAGE_ACTION GPM_CONF_DIR "/thresholds/percentage_action" -#define GPM_CONF_THRESH_TIME_LOW GPM_CONF_DIR "/thresholds/time_low" -#define GPM_CONF_THRESH_TIME_CRITICAL GPM_CONF_DIR "/thresholds/time_critical" -#define GPM_CONF_THRESH_TIME_ACTION GPM_CONF_DIR "/thresholds/time_action" - -/* timeout */ -#define GPM_CONF_TIMEOUT_SLEEP_COMPUTER_AC GPM_CONF_DIR "/timeout/sleep_computer_ac" -#define GPM_CONF_TIMEOUT_SLEEP_COMPUTER_BATT GPM_CONF_DIR "/timeout/sleep_computer_battery" -#define GPM_CONF_TIMEOUT_SLEEP_COMPUTER_UPS GPM_CONF_DIR "/timeout/sleep_computer_ups" -#define GPM_CONF_TIMEOUT_SLEEP_DISPLAY_AC GPM_CONF_DIR "/timeout/sleep_display_ac" -#define GPM_CONF_TIMEOUT_SLEEP_DISPLAY_BATT GPM_CONF_DIR "/timeout/sleep_display_battery" -#define GPM_CONF_TIMEOUT_SLEEP_DISPLAY_UPS GPM_CONF_DIR "/timeout/sleep_display_ups" - -/* ui */ -#define GPM_CONF_UI_ICON_POLICY GPM_CONF_DIR "/ui/icon_policy" -#define GPM_CONF_UI_ENABLE_SOUND GPM_CONF_DIR "/ui/enable_sound" -#define GPM_CONF_UI_SHOW_ACTIONS GPM_CONF_DIR "/ui/show_actions" - -/* new info binary */ -#define GPM_CONF_INFO_HISTORY_TIME "/apps/mate-power-manager/info/history_time" -#define GPM_CONF_INFO_HISTORY_TYPE "/apps/mate-power-manager/info/history_type" -#define GPM_CONF_INFO_HISTORY_GRAPH_SMOOTH "/apps/mate-power-manager/info/history_graph_smooth" -#define GPM_CONF_INFO_HISTORY_GRAPH_POINTS "/apps/mate-power-manager/info/history_graph_points" -#define GPM_CONF_INFO_STATS_TYPE "/apps/mate-power-manager/info/stats_type" -#define GPM_CONF_INFO_STATS_GRAPH_SMOOTH "/apps/mate-power-manager/info/stats_graph_smooth" -#define GPM_CONF_INFO_STATS_GRAPH_POINTS "/apps/mate-power-manager/info/stats_graph_points" -#define GPM_CONF_INFO_PAGE_NUMBER "/apps/mate-power-manager/info/page_number" -#define GPM_CONF_INFO_LAST_DEVICE "/apps/mate-power-manager/info/last_device" - -/* mate-screensaver */ -#define GS_CONF_DIR "/apps/mate-screensaver" -#define GS_PREF_LOCK_ENABLED GS_CONF_DIR "/lock_enabled" - -/* mate-session */ -#define GPM_CONF_IDLE_DELAY "/desktop/mate/session/idle_delay" - -typedef enum { - GPM_ICON_POLICY_ALWAYS, - GPM_ICON_POLICY_PRESENT, - GPM_ICON_POLICY_CHARGE, - GPM_ICON_POLICY_LOW, - GPM_ICON_POLICY_CRITICAL, - GPM_ICON_POLICY_NEVER -} GpmIconPolicy; - -typedef enum { - GPM_ACTION_POLICY_BLANK, - GPM_ACTION_POLICY_SUSPEND, - GPM_ACTION_POLICY_SHUTDOWN, - GPM_ACTION_POLICY_HIBERNATE, - GPM_ACTION_POLICY_INTERACTIVE, - GPM_ACTION_POLICY_NOTHING -} GpmActionPolicy; - -gchar *gpm_get_timestring (guint time); -GpmIconPolicy gpm_icon_policy_from_string (const gchar *policy); -const gchar *gpm_icon_policy_to_string (GpmIconPolicy policy); -GpmActionPolicy gpm_action_policy_from_string (const gchar *policy); -const gchar *gpm_action_policy_to_string (GpmActionPolicy policy); void gpm_help_display (const gchar *link_id); #ifdef EGG_TEST void gpm_common_test (gpointer data); |