diff options
author | Ali Abdallah <ali@ali-xfce.org> | 2009-08-31 10:08:09 +0000 |
---|---|---|
committer | Ali Abdallah <ali@ali-xfce.org> | 2009-08-31 10:08:09 +0000 |
commit | 73f412645e0d67ad9039f7572892f844dbb9a915 (patch) | |
tree | 1b9b44dd0a7537462a72c8a989165fcdcc741c20 | |
parent | 74e4ab7ee7c4d1fe51029931a09e3a61dc6a64f8 (diff) | |
download | ixfce4-power-manager-73f412645e0d67ad9039f7572892f844dbb9a915.tar.gz |
Put the icon prefix in one place+get rid of a useless icon load function
-rw-r--r-- | libxfpm/Makefile.am | 1 | ||||
-rw-r--r-- | libxfpm/xfpm-common.c | 20 | ||||
-rw-r--r-- | libxfpm/xfpm-common.h | 3 | ||||
-rw-r--r-- | libxfpm/xfpm-icons.h | 44 | ||||
-rw-r--r-- | libxfpm/xfpm-notify.c | 7 | ||||
-rw-r--r-- | panel-plugins/brightness/brightness-button.c | 3 | ||||
-rw-r--r-- | settings/xfpm-settings.c | 9 | ||||
-rw-r--r-- | src/xfpm-battery.c | 26 | ||||
-rw-r--r-- | src/xfpm-supply.c | 3 | ||||
-rw-r--r-- | src/xfpm-tray-icon.c | 11 |
10 files changed, 81 insertions, 46 deletions
diff --git a/libxfpm/Makefile.am b/libxfpm/Makefile.am index fa8ac391..81a3aa2b 100644 --- a/libxfpm/Makefile.am +++ b/libxfpm/Makefile.am @@ -43,6 +43,7 @@ libxfpmcommon_la_CFLAGS = \ $(GLIB_CFLAGS) \ $(DBUS_CFLAGS) \ $(LIBXFCE4UTIL_CFLAGS) \ + $(LIBXFCEGUI4_CFLAGS) \ $(LIBNOTIFY_CFLAGS) if MAINTAINER_MODE diff --git a/libxfpm/xfpm-common.c b/libxfpm/xfpm-common.c index 99ebb495..76c8cf33 100644 --- a/libxfpm/xfpm-common.c +++ b/libxfpm/xfpm-common.c @@ -66,26 +66,6 @@ xfpm_link_mailto (GtkAboutDialog *about, const gchar *link, gpointer data) g_free (cmd); } - -GdkPixbuf * -xfpm_load_icon (const char *icon_name, gint size) -{ - GdkPixbuf *icon; - GError *error = NULL; - - icon = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), - icon_name, - size, - GTK_ICON_LOOKUP_FORCE_SVG, - &error); - if ( error ) - { - g_warning ("Error occured while loading icon %s: %s\n", icon_name, error->message); - g_error_free (error); - } - return icon; -} - void xfpm_lock_screen (void) { diff --git a/libxfpm/xfpm-common.h b/libxfpm/xfpm-common.h index 9ab0fb37..75d310e1 100644 --- a/libxfpm/xfpm-common.h +++ b/libxfpm/xfpm-common.h @@ -33,9 +33,6 @@ G_BEGIN_DECLS GtkBuilder *xfpm_builder_new_from_string (const gchar *file, GError **error); -GdkPixbuf* xfpm_load_icon (const gchar *icon_name, - gint size) G_GNUC_MALLOC; - void xfpm_lock_screen (void); void xfpm_preferences (void); diff --git a/libxfpm/xfpm-icons.h b/libxfpm/xfpm-icons.h new file mode 100644 index 00000000..3bc8f673 --- /dev/null +++ b/libxfpm/xfpm-icons.h @@ -0,0 +1,44 @@ +/* + * * Copyright (C) 2009 Ali <aliov@xfce.org> + * + * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __XFPM_ICONS_H +#define __XFPM_ICONS_H + +G_BEGIN_DECLS + +#define XFPM_AC_ADAPTER_ICON "xfpm-ac-adapter" +#define XFPM_BATTERY_ICON "battery" + +#define XFPM_PRIMARY_ICON_PREFIX "xfpm-primary-" +#define XFPM_UPS_ICON_PREFIX "xfpm-ups-" +#define XFPM_MOUSE_ICON_PREFIX "xfpm-mouse-" +#define XFPM_KBD_ICON_PREFIX "xfpm-keyboard-" +#define XFPM_CAMERA_ICON_PREFIX "xfpm-camera-" +#define XFPM_PDA_ICON_PREFIX "xfpm-pda-" +#define XFPM_KBD_MOUSE_ICON_PREFIX "xfpm-keyboard-mouse-" + +#define XFPM_DISPLAY_BRIGHTNESS_ICON "xfpm-brightness-lcd" +#define XFPM_DISPLAY_BRIGHTNESS_INVALID_ICON "xfpm-brightness-lcd-invalid" /* When no hw found */ +#define XFPM_HIBERNATE_ICON "xfpm-hibernate" +#define XFPM_SUSPEND_ICON "xfpm-suspend" + +G_END_DECLS + +#endif diff --git a/libxfpm/xfpm-notify.c b/libxfpm/xfpm-notify.c index 5c5effc6..e9830874 100644 --- a/libxfpm/xfpm-notify.c +++ b/libxfpm/xfpm-notify.c @@ -37,7 +37,9 @@ #endif #include <gtk/gtk.h> + #include <libxfce4util/libxfce4util.h> +#include <libxfcegui4/libxfcegui4.h> #include <libnotify/notify.h> @@ -102,14 +104,15 @@ xfpm_notify_finalize(GObject *object) static void xfpm_notify_set_notification_icon (NotifyNotification *n, const gchar *icon_name ) { - GdkPixbuf *pix = xfpm_load_icon (icon_name, 48); + GdkPixbuf *pix = xfce_themed_icon_load (icon_name, 48); if ( pix ) { - notify_notification_set_icon_from_pixbuf (n, + notify_notification_set_icon_from_pixbuf (n, pix); g_object_unref ( G_OBJECT(pix)); } + } static NotifyNotification * diff --git a/panel-plugins/brightness/brightness-button.c b/panel-plugins/brightness/brightness-button.c index 49f0f537..cf9577fa 100644 --- a/panel-plugins/brightness/brightness-button.c +++ b/panel-plugins/brightness/brightness-button.c @@ -31,6 +31,7 @@ #include <libxfcegui4/libxfcegui4.h> #include "libxfpm/xfpm-common.h" +#include "libxfpm/xfpm-icons.h" #include "brightness-button.h" #include "brightness-proxy.h" @@ -557,7 +558,7 @@ brightness_button_set_icon (BrightnessButton *button, gint width) hw_found = brightness_proxy_has_hw (button->priv->brightness); - icon_name = hw_found ? "xfpm-brightness-lcd" : "xfpm-brightness-lcd-invalid"; + icon_name = hw_found ? XFPM_DISPLAY_BRIGHTNESS_ICON : XFPM_DISPLAY_BRIGHTNESS_INVALID_ICON; pixbuf = xfce_themed_icon_load (icon_name, width); diff --git a/settings/xfpm-settings.c b/settings/xfpm-settings.c index 180444f8..772edf66 100644 --- a/settings/xfpm-settings.c +++ b/settings/xfpm-settings.c @@ -36,6 +36,7 @@ #include "libxfpm/xfpm-common.h" #include "libxfpm/xfpm-string.h" +#include "libxfpm/xfpm-icons.h" #include "interfaces/xfpm-settings_ui.h" @@ -1451,7 +1452,7 @@ xfpm_settings_tree_view (XfconfChannel *channel, gboolean system_laptop) gtk_tree_view_append_column(GTK_TREE_VIEW(view),col); /*General settings */ - pix = xfpm_load_icon("preferences-system", 48); + pix = xfce_themed_icon_load ("preferences-system", 48); gtk_list_store_append(list_store, &iter); @@ -1467,7 +1468,7 @@ xfpm_settings_tree_view (XfconfChannel *channel, gboolean system_laptop) i++; /* ON ac power */ - pix = xfpm_load_icon("xfpm-ac-adapter", 48); + pix = xfce_themed_icon_load (XFPM_AC_ADAPTER_ICON, 48); gtk_list_store_append(list_store, &iter); if ( pix ) { @@ -1482,7 +1483,7 @@ xfpm_settings_tree_view (XfconfChannel *channel, gboolean system_laptop) if ( system_laptop ) { - pix = xfpm_load_icon("battery", 48); + pix = xfce_themed_icon_load (XFPM_BATTERY_ICON, 48); gtk_list_store_append(list_store, &iter); if ( pix ) { @@ -1496,7 +1497,7 @@ xfpm_settings_tree_view (XfconfChannel *channel, gboolean system_laptop) } i++; - pix = xfpm_load_icon("applications-other", 48); + pix = xfce_themed_icon_load ("applications-other", 48); gtk_list_store_append(list_store, &iter); if ( pix ) { diff --git a/src/xfpm-battery.c b/src/xfpm-battery.c index c0e0e625..ca81fb74 100644 --- a/src/xfpm-battery.c +++ b/src/xfpm-battery.c @@ -35,6 +35,7 @@ #include "libxfpm/xfpm-string.h" #include "libxfpm/xfpm-notify.h" +#include "libxfpm/xfpm-icons.h" #include "xfpm-battery.h" #include "xfpm-tray-icon.h" @@ -164,7 +165,9 @@ xfpm_battery_refresh_icon (XfpmBattery *battery, if ( state == BATTERY_NOT_PRESENT ) { xfpm_tray_icon_set_icon (battery->priv->icon, - battery->priv->type == HAL_DEVICE_TYPE_UPS ? "xfpm-ups-missing" : "xfpm-primary-missing"); + battery->priv->type == HAL_DEVICE_TYPE_UPS ? + XFPM_UPS_ICON_PREFIX "missing" : + XFPM_PRIMARY_ICON_PREFIX "missing"); return; } @@ -172,7 +175,10 @@ xfpm_battery_refresh_icon (XfpmBattery *battery, if ( state == BATTERY_FULLY_CHARGED ) { if ( battery->priv->type == HAL_DEVICE_TYPE_PRIMARY) - xfpm_tray_icon_set_icon (battery->priv->icon, battery->priv->adapter_present ? "xfpm-primary-charged" : "xfpm-primary-100"); + xfpm_tray_icon_set_icon (battery->priv->icon, + battery->priv->adapter_present ? + XFPM_PRIMARY_ICON_PREFIX "charged" : + XFPM_PRIMARY_ICON_PREFIX "100"); else { icon = g_strdup_printf("%s%s", @@ -544,34 +550,34 @@ _get_icon_prefix_from_enum_type (HalDeviceType type) { if ( type == HAL_DEVICE_TYPE_PRIMARY ) { - return g_strdup("xfpm-primary-"); + return g_strdup (XFPM_PRIMARY_ICON_PREFIX); } else if ( type == HAL_DEVICE_TYPE_UPS ) { - return g_strdup("xfpm-ups-"); + return g_strdup (XFPM_UPS_ICON_PREFIX); } else if ( type == HAL_DEVICE_TYPE_MOUSE ) { - return g_strdup("xfpm-mouse-"); + return g_strdup (XFPM_MOUSE_ICON_PREFIX); } else if ( type == HAL_DEVICE_TYPE_KEYBOARD ) { - return g_strdup("xfpm-keyboard-"); + return g_strdup (XFPM_KBD_ICON_PREFIX); } else if ( type == HAL_DEVICE_TYPE_CAMERA ) { - return g_strdup("xfpm-camera-"); + return g_strdup (XFPM_CAMERA_ICON_PREFIX); } else if ( type == HAL_DEVICE_TYPE_PDA ) { - return g_strdup("xfpm-pda-"); + return g_strdup (XFPM_PDA_ICON_PREFIX); } else if ( type == HAL_DEVICE_TYPE_KEYBOARD_MOUSE ) { - return g_strdup("xfpm-keyboard-mouse-"); + return g_strdup (XFPM_KBD_MOUSE_ICON_PREFIX); } - return g_strdup("xfpm-primary-"); + return g_strdup (XFPM_PRIMARY_ICON_PREFIX); } static void diff --git a/src/xfpm-supply.c b/src/xfpm-supply.c index 4b2c5a6f..5fbdc169 100644 --- a/src/xfpm-supply.c +++ b/src/xfpm-supply.c @@ -34,6 +34,7 @@ #include "libxfpm/xfpm-string.h" #include "libxfpm/xfpm-common.h" #include "libxfpm/xfpm-notify.h" +#include "libxfpm/xfpm-icons.h" #include "xfpm-supply.h" #include "xfpm-adapter.h" @@ -232,7 +233,7 @@ xfpm_supply_show_tray_icon (XfpmSupply *supply) supply->priv->tray = xfpm_tray_icon_new (); xfpm_tray_icon_set_visible (supply->priv->tray, FALSE); - xfpm_tray_icon_set_icon (supply->priv->tray, "xfpm-ac-adapter"); + xfpm_tray_icon_set_icon (supply->priv->tray, XFPM_AC_ADAPTER_ICON); xfpm_tray_icon_set_show_info_menu (supply->priv->tray, FALSE); } diff --git a/src/xfpm-tray-icon.c b/src/xfpm-tray-icon.c index 1d99a5c0..15713d3f 100644 --- a/src/xfpm-tray-icon.c +++ b/src/xfpm-tray-icon.c @@ -35,6 +35,7 @@ #include "libxfpm/xfpm-common.h" #include "libxfpm/xfpm-string.h" #include "libxfpm/xfpm-notify.h" +#include "libxfpm/xfpm-icons.h" #include "xfpm-tray-icon.h" #include "xfpm-shutdown.h" @@ -263,10 +264,10 @@ xfpm_tray_icon_popup_menu_cb (GtkStatusIcon *icon, guint button, NULL); // Hibernate menu option - mi = gtk_image_menu_item_new_with_label(_("Hibernate")); - img = gtk_image_new_from_icon_name("xfpm-hibernate",GTK_ICON_SIZE_MENU); - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(mi),img); - gtk_widget_set_sensitive(mi,FALSE); + mi = gtk_image_menu_item_new_with_label (_("Hibernate")); + img = gtk_image_new_from_icon_name (XFPM_HIBERNATE_ICON, GTK_ICON_SIZE_MENU); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(mi), img); + gtk_widget_set_sensitive (mi,FALSE); if ( caller && can_hibernate && tray->priv->data_available ) { @@ -279,7 +280,7 @@ xfpm_tray_icon_popup_menu_cb (GtkStatusIcon *icon, guint button, // Suspend menu option mi = gtk_image_menu_item_new_with_label(_("Suspend")); - img = gtk_image_new_from_icon_name("xfpm-suspend",GTK_ICON_SIZE_MENU); + img = gtk_image_new_from_icon_name (XFPM_SUSPEND_ICON, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(mi),img); gtk_widget_set_sensitive(mi,FALSE); |