~ubuntu-branches/ubuntu/lucid/awn-extras-applets/lucid

« back to all changes in this revision

Viewing changes to applets/maintained/notification-area/notification-area.c

  • Committer: Bazaar Package Importer
  • Author(s): Julien Lavergne
  • Date: 2010-03-30 20:26:40 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20100330202640-vza3bdnv9gc9bg5z
Tags: 0.4.0~rc1-0ubuntu1
* New upstream release (rc1) (LP: #551309)
 - Stack applet close on click (LP: #261520)
* debian/patches/
 - 03-remove-cairo-menu-pref.patch: From upstream (r1244 + r1245 + r1252),
   remove menu entry for cairo-menu preferences, it's not implemented
   (LP: #511254)
 - 04-tomboy-threading-free.patch: From upstream (r1246), remove threading to
   make the applet working. 
* debian/*.install: Update installation location of comics and digital 
  applets.
* debian/control: 
 - Move digital applet from python to C, and add proper Replaces.
 - Add Replaces for awn-applets-c-core to handle migration from 0.3.2.2.
   (LP: #524559)

Show diffs side-by-side

added added

removed removed

Lines of Context:
95
95
};
96
96
 
97
97
 
 
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;
111
113
};
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);
154
158
 
155
159
 
156
160
 
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!");
231
235
        }
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_);
478
482
                } else {
479
 
                        gdk_window_raise (((GtkWidget*) notification_area_prefs_get_dialog (notification_area_prefs_window))->window);
 
483
                        GtkDialog* dialog;
 
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);
480
487
                }
481
488
                result = TRUE;
482
489
                return result;
693
700
}
694
701
 
695
702
 
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 ();
 
705
}
 
706
 
 
707
 
 
708
static void notification_area_on_icon_added (NotificationArea* self, GtkWidget* widget) {
 
709
        EggTrayChild* icon;
 
710
        gboolean _tmp0_ = FALSE;
697
711
        gint icon_size;
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) {
 
716
                char* _tmp1_;
 
717
                _tmp0_ = _vala_strcmp0 (_tmp1_ = egg_tray_child_get_title (icon), "gnome-power-manager") == 0;
 
718
                _g_free0 (_tmp1_);
 
719
        } else {
 
720
                _tmp0_ = FALSE;
 
721
        }
 
722
        if (_tmp0_) {
 
723
                g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 2000, _workaround_gpm_bug_gsource_func, NULL, NULL);
 
724
                gpm_workaround_done = TRUE;
 
725
        }
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);
706
732
}
707
733
 
708
734
 
709
 
static void notification_area_on_icon_removed (NotificationArea* self, GtkWidget* icon) {
 
735
static void notification_area_on_icon_removed (NotificationArea* self, GtkWidget* widget) {
 
736
        EggTrayChild* icon;
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);
715
743
}
716
744
 
960
988
}
961
989
 
962
990
 
963
 
void workaround_gpm_bug (void) {
 
991
gboolean workaround_gpm_bug (void) {
 
992
        gboolean result;
964
993
        GError * _inner_error_;
965
 
        AwnDBusWatcher* watcher;
 
994
        char* command;
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")) {
969
 
                char* command;
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) {
973
 
                        _g_free0 (command);
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_);
977
 
                        return;
978
 
                }
 
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_);
 
1002
                return FALSE;
980
1003
        }
981
 
        g_object_unref ((GObject*) watcher);
982
 
        _g_object_unref0 (watcher);
 
1004
        result = FALSE;
 
1005
        _g_free0 (command);
 
1006
        return result;
983
1007
}
984
1008
 
985
1009
 
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);
1000
1024
                result = NULL;
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);
1013
1036
        return result;
1014
1037
}
1015
1038
 
1016
1039
 
 
1040
static int _vala_strcmp0 (const char * str1, const char * str2) {
 
1041
        if (str1 == NULL) {
 
1042
                return -(str1 != str2);
 
1043
        }
 
1044
        if (str2 == NULL) {
 
1045
                return str1 != str2;
 
1046
        }
 
1047
        return strcmp (str1, str2);
 
1048
}
 
1049
 
 
1050
 
1017
1051
 
1018
1052