~sladen/indicator-session/indicator-session-system-devices-naming

« back to all changes in this revision

Viewing changes to src/device-menu-mgr.c

  • Committer: Conor Curran
  • Date: 2011-07-22 17:00:09 UTC
  • mfrom: (161.3.3 device-menu-reorg)
  • Revision ID: conor.curran@canonical.com-20110722170009-cqv9pgg7ljjg60k8
apt item partially working

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
static DBusGProxyCall * hibernate_call = NULL;
59
59
 
60
60
static DbusmenuMenuitem * hibernate_mi = NULL;
61
 
//static DbusmenuMenuitem * suspend_mi = NULL;
 
61
static DbusmenuMenuitem * suspend_mi = NULL;
62
62
static DbusmenuMenuitem * logout_mi = NULL;
63
63
static DbusmenuMenuitem * restart_mi = NULL;
64
64
static DbusmenuMenuitem * shutdown_mi = NULL;
86
86
machine_sleep_from_hibernate (DbusmenuMenuitem * mi,
87
87
                              guint timestamp,
88
88
                              gpointer userdata);
89
 
/*static void
 
89
static void
90
90
machine_sleep_from_suspend (DbusmenuMenuitem * mi,
91
91
                            guint timestamp,
92
92
                            gpointer userdata);
93
 
*/
 
93
 
94
94
G_DEFINE_TYPE (DeviceMenuMgr, device_menu_mgr, G_TYPE_OBJECT);
95
95
 
96
96
static void
106
106
static void
107
107
device_menu_mgr_finalize (GObject *object)
108
108
{
109
 
        /* TODO: Add deinitalization code here */
110
109
        G_OBJECT_CLASS (device_menu_mgr_parent_class)->finalize (object);
111
110
}
112
111
 
115
114
device_menu_mgr_class_init (DeviceMenuMgrClass *klass)
116
115
{
117
116
        GObjectClass* object_class = G_OBJECT_CLASS (klass);
118
 
        //GObjectClass* parent_class = G_OBJECT_CLASS (klass);
119
117
        object_class->finalize = device_menu_mgr_finalize;
120
118
}
121
119
 
187
185
        return;
188
186
}
189
187
 
190
 
 
191
 
/*static void
 
188
static void
192
189
machine_sleep_from_suspend (DbusmenuMenuitem * mi,
193
190
                            guint timestamp,
194
191
                            gpointer userdata)
195
192
{
196
193
  DeviceMenuMgr* self = DEVICE_MENU_MGR (userdata);
197
194
  machine_sleep_with_context (self, "Suspend");
198
 
}*/
 
195
}
199
196
 
200
197
static void
201
198
machine_sleep_from_hibernate (DbusmenuMenuitem * mi,
229
226
}
230
227
 
231
228
/* A response to getting the suspend property */
232
 
// TODO
233
 
// Is this needed anymore
234
 
 
235
229
static void
236
230
suspend_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata)
237
231
{
252
246
        if (local_can_suspend != can_suspend) {
253
247
                can_suspend = local_can_suspend;
254
248
    // TODO figure out what needs updating on the menu
 
249
    // And add or remove it but just don't rebuild the whole menu
 
250
    // a waste
255
251
                device_menu_mgr_rebuild_items(self);
256
252
        }
257
253
        return;
258
254
}
259
255
 
260
256
/* Response to getting the hibernate property */
261
 
// TODO
262
 
// Is this needed anymore
263
257
static void
264
258
hibernate_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata)
265
259
{
505
499
  login_settings_menuitem = dbusmenu_menuitem_new();
506
500
  dbusmenu_menuitem_property_set (login_settings_menuitem,
507
501
                                  DBUSMENU_MENUITEM_PROP_LABEL,
508
 
                                  _("Login Items..."));
 
502
                                  _("Startup Applications..."));
509
503
  g_signal_connect (G_OBJECT(login_settings_menuitem),
510
504
                    DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
511
505
                    G_CALLBACK(show_session_properties),
512
506
                    "login");
513
507
  dbusmenu_menuitem_child_add_position(self->root_item,
514
 
                                       login_settings_menuitem,
 
508
                                       login_settings_menuitem,                                  
515
509
                                       3);
516
510
  software_updates_menuitem = dbusmenu_menuitem_new();
517
511
  dbusmenu_menuitem_property_set (software_updates_menuitem,
561
555
  dbusmenu_menuitem_child_add_position (self->root_item,
562
556
                                        scanners_menuitem,
563
557
                                        8);
 
558
 //tmp
 
559
  dbusmenu_menuitem_property_set_bool (scanners_menuitem,
 
560
                                       DBUSMENU_MENUITEM_PROP_VISIBLE,
 
561
                                       FALSE);
 
562
                                        
564
563
  webcam_menuitem = dbusmenu_menuitem_new();
565
564
  dbusmenu_menuitem_property_set (webcam_menuitem,
566
565
                                  DBUSMENU_MENUITEM_PROP_LABEL,
572
571
  dbusmenu_menuitem_child_add_position (self->root_item,
573
572
                                        webcam_menuitem,
574
573
                                        10);
 
574
 //tmp
 
575
  dbusmenu_menuitem_property_set_bool (webcam_menuitem,
 
576
                                       DBUSMENU_MENUITEM_PROP_VISIBLE,
 
577
                                       FALSE);
 
578
                                        
575
579
  DbusmenuMenuitem * separator3 = dbusmenu_menuitem_new();
576
580
  dbusmenu_menuitem_property_set (separator3,
577
581
                                  DBUSMENU_MENUITEM_PROP_TYPE,
630
634
                    DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
631
635
                    G_CALLBACK(show_dialog), "logout");
632
636
 
 
637
        if (can_suspend && allow_suspend) {
 
638
                suspend_mi = dbusmenu_menuitem_new();
 
639
                dbusmenu_menuitem_property_set (suspend_mi,
 
640
                                    DBUSMENU_MENUITEM_PROP_LABEL,
 
641
                                    _("Suspend"));
 
642
                dbusmenu_menuitem_child_append (self->root_item, suspend_mi);
 
643
                g_signal_connect( G_OBJECT(suspend_mi),
 
644
                      DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
 
645
                      G_CALLBACK(machine_sleep_from_suspend),
 
646
                      self);
 
647
        }
 
648
 
633
649
        if (can_hibernate && allow_hibernate) {
634
650
                hibernate_mi = dbusmenu_menuitem_new();
635
651
                dbusmenu_menuitem_property_set (hibernate_mi,
672
688
static void
673
689
device_menu_mgr_rebuild_items (DeviceMenuMgr* self)
674
690
{
675
 
}
 
691
  dbusmenu_menuitem_property_set_bool (hibernate_mi,
 
692
                                       DBUSMENU_MENUITEM_PROP_VISIBLE,
 
693
                                       can_hibernate && allow_hibernate);
 
694
  dbusmenu_menuitem_property_set_bool (suspend_mi,
 
695
                                       DBUSMENU_MENUITEM_PROP_VISIBLE,
 
696
                                       can_suspend && allow_suspend);
 
697
}                                       
676
698
 
677
699
/* When the directory changes we need to figure out how our menu
678
700
   item should look. */