[Galago-commits] r2887 - in trunk/notification-daemon: . src
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Sat Jul 29 20:31:45 PDT 2006
Author: chipx86
Date: 2006-07-29 20:31:37 -0700 (Sat, 29 Jul 2006)
New Revision: 2887
Modified:
trunk/notification-daemon/ChangeLog
trunk/notification-daemon/src/daemon.c
Log:
- Move POPUP_STACK_LOCATION_DEFAULT into PopupStackLocationType.
- Remove _notify_daemon_stack_location_type_from_string.
- Moved some duplicate logic into update_stack_location_from_string.
Modified: trunk/notification-daemon/ChangeLog
===================================================================
--- trunk/notification-daemon/ChangeLog 2006-07-30 02:20:30 UTC (rev 2886)
+++ trunk/notification-daemon/ChangeLog 2006-07-30 03:31:37 UTC (rev 2887)
@@ -1,3 +1,10 @@
+Sat Jul 29 20:30:42 PDT 2006 Christian Hammond <chipx86 at chipx86.com>
+
+ * src/daemon.c:
+ - Move POPUP_STACK_LOCATION_DEFAULT into PopupStackLocationType.
+ - Remove _notify_daemon_stack_location_type_from_string.
+ - Moved some duplicate logic into update_stack_location_from_string.
+
Sat Jul 29 19:19:34 PDT 2006 Christian Hammond <chipx86 at chipx86.com>
* src/daemon.c:
Modified: trunk/notification-daemon/src/daemon.c
===================================================================
--- trunk/notification-daemon/src/daemon.c 2006-07-30 02:20:30 UTC (rev 2886)
+++ trunk/notification-daemon/src/daemon.c 2006-07-30 03:31:37 UTC (rev 2887)
@@ -48,18 +48,17 @@
#define IMAGE_SIZE 48
-typedef enum {
+typedef enum
+{
POPUP_STACK_LOCATION_UNKNOWN = -1,
POPUP_STACK_LOCATION_TOP_LEFT,
POPUP_STACK_LOCATION_TOP_RIGHT,
POPUP_STACK_LOCATION_BOTTOM_LEFT,
- POPUP_STACK_LOCATION_BOTTOM_RIGHT
+ POPUP_STACK_LOCATION_BOTTOM_RIGHT,
+ POPUP_STACK_LOCATION_DEFAULT = POPUP_STACK_LOCATION_BOTTOM_RIGHT
} PopupStackLocationType;
-#define POPUP_STACK_LOCATION_DEFAULT \
- POPUP_STACK_LOCATION_BOTTOM_RIGHT
-
struct PopupStackLocation
{
PopupStackLocationType type;
@@ -96,7 +95,7 @@
GSList *poptart_stack;
gboolean url_clicked_lock;
gboolean stack_only;
- gchar popup_stack_location;
+ PopupStackLocationType popup_stack_location;
};
static GConfClient *gconf_client = NULL;
@@ -116,8 +115,8 @@
};
#endif /* D-BUS < 0.60 */
-static PopupStackLocationType
- _notify_daemon_stack_location_type_from_string(const gchar *slocation);
+static void update_stack_location_from_string(NotifyDaemon *daemon,
+ const char *slocation);
static void notify_daemon_finalize(GObject *object);
static void _close_notification(NotifyDaemon *daemon, guint id,
gboolean hide_notification);
@@ -146,7 +145,8 @@
static void
notify_daemon_init(NotifyDaemon *daemon)
{
- GConfClient *client;
+ GConfClient *client = get_gconf_client();
+ gchar *slocation;
daemon->priv = G_TYPE_INSTANCE_GET_PRIVATE(daemon, NOTIFY_TYPE_DAEMON,
NotifyDaemonPrivate);
@@ -156,26 +156,11 @@
daemon->priv->stack_only = FALSE;
daemon->priv->popup_stack_location = POPUP_STACK_LOCATION_DEFAULT;
- client = get_gconf_client();
+ slocation = gconf_client_get_string(client, GCONF_KEY_POPUP_LOCATION,
+ NULL);
+ update_stack_location_from_string(daemon, slocation);
+ g_free(slocation);
- if (client != NULL)
- {
- gchar *slocation = gconf_client_get_string(client,
- GCONF_KEY_POPUP_LOCATION,
- NULL);
-
- if (slocation != NULL && *slocation != '\0')
- {
- gchar location =
- _notify_daemon_stack_location_type_from_string(slocation);
-
- if (location != POPUP_STACK_LOCATION_UNKNOWN)
- daemon->priv->popup_stack_location = location;
- }
-
- g_free(slocation);
- }
-
daemon->priv->notification_hash =
g_hash_table_new_full(g_int_hash, g_int_equal, g_free,
(GDestroyNotify)_notify_timeout_destroy);
@@ -184,16 +169,13 @@
static void
notify_daemon_finalize(GObject *object)
{
- NotifyDaemon *daemon;
- GObjectClass *parent_class;
+ NotifyDaemon *daemon = NOTIFY_DAEMON(object);
+ GObjectClass *parent_class = G_OBJECT_CLASS(notify_daemon_parent_class);
- daemon = NOTIFY_DAEMON(object);
-
g_hash_table_destroy(daemon->priv->notification_hash);
g_slist_free(daemon->priv->poptart_stack);
+ g_free(daemon->priv);
- parent_class = G_OBJECT_CLASS(notify_daemon_parent_class);
-
if (parent_class->finalize != NULL)
parent_class->finalize(object);
}
@@ -205,6 +187,36 @@
}
static void
+update_stack_location_from_string(NotifyDaemon *daemon, const char *slocation)
+{
+ if (slocation != NULL && *slocation != '\0')
+ {
+ PopupStackLocationType location_type = POPUP_STACK_LOCATION_DEFAULT;
+ const struct PopupStackLocation *l;
+
+ for (l = popup_stack_locations;
+ l->type != POPUP_STACK_LOCATION_UNKNOWN;
+ l++)
+ {
+ if (!strcmp(slocation, l->identifier))
+ location_type = l->type;
+ }
+
+ if (location_type != POPUP_STACK_LOCATION_UNKNOWN)
+ daemon->priv->popup_stack_location = location_type;
+ }
+ else
+ {
+ gconf_client_set_string(get_gconf_client(),
+ "/apps/notification-daemon/popup_location",
+ popup_stack_locations[POPUP_STACK_LOCATION_DEFAULT].identifier,
+ NULL);
+
+ daemon->priv->popup_stack_location = POPUP_STACK_LOCATION_DEFAULT;
+ }
+}
+
+static void
_action_invoked_cb(GtkWindow *nw, const char *key)
{
NotifyDaemon *daemon = g_object_get_data(G_OBJECT(nw), "_notify_daemon");
@@ -747,22 +759,6 @@
return TRUE;
}
-static PopupStackLocationType
-_notify_daemon_stack_location_type_from_string(const gchar *slocation)
-{
- const struct PopupStackLocation *l;
-
- for (l = popup_stack_locations;
- l->type != POPUP_STACK_LOCATION_UNKNOWN;
- l++)
- {
- if (!strcmp(slocation, l->identifier))
- return l->type;
- }
-
- return POPUP_STACK_LOCATION_UNKNOWN;
-}
-
static void
_pop_stack_get_origin_coordinates(PopupStackLocationType location_type,
GdkRectangle workarea,
@@ -845,30 +841,9 @@
return;
value = gconf_entry_get_value(entry);
-
- if (value != NULL)
- {
- const char *slocation = gconf_value_get_string(value);
-
- if (slocation != NULL)
- {
- PopupStackLocationType location_type =
- _notify_daemon_stack_location_type_from_string(slocation);
-
- if (location_type != POPUP_STACK_LOCATION_UNKNOWN)
- {
- daemon->priv->popup_stack_location = location_type;
- return;
- }
- }
- }
-
- gconf_client_set_string(client,
- "/apps/notification-daemon/popup_location",
- popup_stack_locations[POPUP_STACK_LOCATION_DEFAULT].identifier,
- NULL);
-
- daemon->priv->popup_stack_location = POPUP_STACK_LOCATION_DEFAULT;
+ update_stack_location_from_string(
+ daemon,
+ value != NULL ? gconf_value_get_string(value) : NULL);
}
static void
More information about the galago-commits
mailing list