98
extern gboolean gpm_workaround_done;
99
gboolean gpm_workaround_done = FALSE;
98
100
static NotificationAreaPrefs* notification_area_prefs_window;
99
101
static NotificationAreaPrefs* notification_area_prefs_window = NULL;
100
102
static gpointer notification_area_parent_class = NULL;
112
114
GType notification_area_prefs_get_type (void);
113
115
#define NOTIFICATION_AREA_BORDER 2
114
static void notification_area_on_icon_added (NotificationArea* self, GtkWidget* icon);
116
static void notification_area_on_icon_added (NotificationArea* self, GtkWidget* widget);
115
117
static void _notification_area_on_icon_added_egg_tray_manager_tray_icon_added (EggTrayManager* _sender, GtkWidget* object, gpointer self);
116
static void notification_area_on_icon_removed (NotificationArea* self, GtkWidget* icon);
118
static void notification_area_on_icon_removed (NotificationArea* self, GtkWidget* widget);
117
119
static void _notification_area_on_icon_removed_egg_tray_manager_tray_icon_removed (EggTrayManager* _sender, GtkWidget* object, gpointer self);
118
120
static void notification_area_update_icon_sizes (NotificationArea* self);
119
121
static void notification_area_table_refresh (NotificationArea* self);
133
135
NotificationAreaPrefs* notification_area_prefs_construct (GType object_type, AwnApplet* applet);
134
136
GtkDialog* notification_area_prefs_get_dialog (NotificationAreaPrefs* self);
135
137
static gint notification_area_get_tray_icon_size (NotificationArea* self);
138
gboolean workaround_gpm_bug (void);
139
static gboolean _workaround_gpm_bug_gsource_func (gpointer self);
136
140
static gboolean notification_area_redraw_scheduler (NotificationArea* self);
137
141
static gboolean _notification_area_redraw_scheduler_gsource_func (gpointer self);
138
142
gboolean notification_area_on_visibility_change (NotificationArea* self, GdkEvent* event, GtkWidget* applet);
149
153
static void notification_area_finalize (GObject* obj);
150
154
static void notification_area_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
151
155
static void notification_area_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
152
void workaround_gpm_bug (void);
153
156
AwnApplet* awn_applet_factory_initp (const char* canonical_name, const char* uid, gint panel_id);
157
static int _vala_strcmp0 (const char * str1, const char * str2);
227
231
self->priv->deletion_quark = g_quark_from_string ("na-tray-icon-deleted");
228
232
screen = gtk_window_get_screen ((GtkWindow*) applet);
229
233
if (egg_tray_manager_manage_screen (self->priv->manager, screen) == FALSE) {
230
g_error ("notification-area.vala:146: Unable to manage the screen!");
234
g_error ("notification-area.vala:148: Unable to manage the screen!");
232
236
g_signal_connect_object (self->priv->manager, "tray-icon-added", (GCallback) _notification_area_on_icon_added_egg_tray_manager_tray_icon_added, self, 0);
233
237
g_signal_connect_object (self->priv->manager, "tray-icon-removed", (GCallback) _notification_area_on_icon_removed_egg_tray_manager_tray_icon_removed, self, 0);
476
480
gtk_object_destroy ((GtkObject*) dialog);
477
481
notification_area_prefs_window = (_tmp1_ = NULL, _g_object_unref0 (notification_area_prefs_window), _tmp1_);
479
gdk_window_raise (((GtkWidget*) notification_area_prefs_get_dialog (notification_area_prefs_window))->window);
484
dialog = _g_object_ref0 (notification_area_prefs_get_dialog (notification_area_prefs_window));
485
gtk_window_present_with_time ((GtkWindow*) dialog, (*event).time);
486
_g_object_unref0 (dialog);
696
static void notification_area_on_icon_added (NotificationArea* self, GtkWidget* icon) {
703
static gboolean _workaround_gpm_bug_gsource_func (gpointer self) {
704
return workaround_gpm_bug ();
708
static void notification_area_on_icon_added (NotificationArea* self, GtkWidget* widget) {
710
gboolean _tmp0_ = FALSE;
698
712
g_return_if_fail (self != NULL);
699
g_return_if_fail (icon != NULL);
713
g_return_if_fail (widget != NULL);
714
icon = EGG_TRAY_CHILD (widget);
715
if (!gpm_workaround_done) {
717
_tmp0_ = _vala_strcmp0 (_tmp1_ = egg_tray_child_get_title (icon), "gnome-power-manager") == 0;
723
g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 2000, _workaround_gpm_bug_gsource_func, NULL, NULL);
724
gpm_workaround_done = TRUE;
700
726
g_object_set_qdata ((GObject*) icon, self->priv->addition_quark, GINT_TO_POINTER (1));
701
727
g_object_set_qdata ((GObject*) icon, self->priv->deletion_quark, GINT_TO_POINTER (0));
702
self->priv->tray_icons = g_list_append (self->priv->tray_icons, EGG_TRAY_CHILD (icon));
728
self->priv->tray_icons = g_list_append (self->priv->tray_icons, icon);
703
729
icon_size = notification_area_get_tray_icon_size (self);
704
gtk_widget_set_size_request (icon, icon_size, icon_size);
730
gtk_widget_set_size_request ((GtkWidget*) icon, icon_size, icon_size);
705
731
notification_area_table_refresh (self);
709
static void notification_area_on_icon_removed (NotificationArea* self, GtkWidget* icon) {
735
static void notification_area_on_icon_removed (NotificationArea* self, GtkWidget* widget) {
710
737
g_return_if_fail (self != NULL);
711
g_return_if_fail (icon != NULL);
738
g_return_if_fail (widget != NULL);
739
icon = EGG_TRAY_CHILD (widget);
712
740
g_object_set_qdata ((GObject*) icon, self->priv->deletion_quark, GINT_TO_POINTER (1));
713
self->priv->tray_icons = g_list_remove (self->priv->tray_icons, EGG_TRAY_CHILD (icon));
741
self->priv->tray_icons = g_list_remove (self->priv->tray_icons, icon);
714
742
notification_area_table_refresh (self);
963
void workaround_gpm_bug (void) {
991
gboolean workaround_gpm_bug (void) {
964
993
GError * _inner_error_;
965
AwnDBusWatcher* watcher;
966
995
_inner_error_ = NULL;
967
watcher = _g_object_ref0 (awn_dbus_watcher_get_default ());
968
if (awn_dbus_watcher_has_name (watcher, "org.gnome.PowerManager")) {
970
command = g_strdup ("python -c \"" "import time, gconf;" "time.sleep(5);" "c = gconf.Client();" "key = '/apps/gnome-power-manager/ui/icon_policy';" "pol = c.get_string(key);" "c.set_string(key, 'always');" "c.set_string(key, pol);" "\"");
971
g_spawn_command_line_async (command, &_inner_error_);
972
if (_inner_error_ != NULL) {
974
_g_object_unref0 (watcher);
975
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
976
g_clear_error (&_inner_error_);
996
command = g_strdup ("python -c \"" "import gconf;" "c = gconf.Client();" "key = '/apps/gnome-power-manager/ui/icon_policy';" "pol = c.get_string(key);" "c.set_string(key, 'always');" "c.set_string(key, pol);" "\"");
997
g_spawn_command_line_async (command, &_inner_error_);
998
if (_inner_error_ != NULL) {
979
999
_g_free0 (command);
1000
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
1001
g_clear_error (&_inner_error_);
981
g_object_unref ((GObject*) watcher);
982
_g_object_unref0 (watcher);
996
1020
d = g_object_ref_sink ((GtkMessageDialog*) gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", msg));
997
1021
gtk_message_dialog_format_secondary_text (d, "Please remove the existing notification area" " and then restart the applet.", NULL);
998
1022
gtk_dialog_run ((GtkDialog*) d);
999
g_error ("notification-area.vala:638: %s", msg);
1023
g_error ("notification-area.vala:647: %s", msg);
1001
1025
_g_free0 (msg);
1002
1026
_g_object_unref0 (d);
1007
1031
g_object_set_data ((GObject*) applet, "notification-area", g_object_ref ((GObject*) na));
1008
1032
gtk_widget_add_events ((GtkWidget*) applet, (gint) GDK_VISIBILITY_NOTIFY_MASK);
1009
1033
g_signal_connect_swapped (applet, "visibility-notify-event", (GCallback) notification_area_on_visibility_change, na);
1010
workaround_gpm_bug ();
1011
1034
result = applet;
1012
1035
_g_object_unref0 (na);
1040
static int _vala_strcmp0 (const char * str1, const char * str2) {
1042
return -(str1 != str2);
1045
return str1 != str2;
1047
return strcmp (str1, str2);