~ubuntu-branches/debian/jessie/cairo-dock-plug-ins/jessie

« back to all changes in this revision

Viewing changes to powermanager/src/powermanager-menu-functions.c

  • Committer: Matthieu Baerts
  • Date: 2011-09-26 12:56:12 UTC
  • Revision ID: matttbe@gmail.com-20110926125612-mvlfm1ndpwx2ggk1
Tags: upstream-2.4.0~1
ImportĀ upstreamĀ versionĀ 2.4.0~1

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
        cd_powermanager_bubble ();
32
32
CD_APPLET_ON_CLICK_END
33
33
 
34
 
static void power_config (void) {  /// a mettre dans les plug-ins d'integration.
 
34
/// a mettre dans les plug-ins d'integration.
 
35
static void power_launch_cmd (GtkMenuItem *menu_item, const gchar *cCommand)
 
36
{
35
37
        GError *erreur = NULL;
36
 
        if (g_iDesktopEnv == CAIRO_DOCK_GNOME || g_iDesktopEnv == CAIRO_DOCK_XFCE)
37
 
        {
38
 
                g_spawn_command_line_async ("gnome-power-preferences", &erreur);
39
 
        }
40
 
        else if (g_iDesktopEnv == CAIRO_DOCK_KDE)
41
 
        {
42
 
                /// Ajouter les lignes de KDE...
43
 
        }
 
38
        g_spawn_command_line_async (cCommand, &erreur);
 
39
 
44
40
        if (erreur != NULL)
45
41
        {
46
42
                cd_warning ("PM : %s", erreur->message);
48
44
        }
49
45
}
50
46
 
51
 
 
52
47
CD_APPLET_ON_BUILD_MENU_BEGIN
53
48
        // Sub-Menu
54
49
        GtkWidget *pSubMenu = CD_APPLET_CREATE_MY_SUB_MENU ();
55
 
        if (g_iDesktopEnv == CAIRO_DOCK_GNOME)  /// TODO: other DE...
56
 
                CD_APPLET_ADD_IN_MENU_WITH_STOCK (D_("Set up power management"), MY_APPLET_SHARE_DATA_DIR"/default-battery.svg", power_config, CD_APPLET_MY_MENU);
 
50
        
 
51
        // Power preferences
 
52
        static gboolean bPowerPrefChecked = FALSE;
 
53
        static const gchar *cPowerPrefCmd = NULL;
 
54
        if (!bPowerPrefChecked)
 
55
        {
 
56
                bPowerPrefChecked = TRUE;
 
57
                gchar *cResult = cairo_dock_launch_command_sync ("which gnome-power-preferences"); // not available on Gnome3 => gnome-control-center => Energy
 
58
                /// => can't we open the control center on the Enery tab directly ?
 
59
                if (cResult != NULL && *cResult == '/')  /// TODO: other DE...
 
60
                        cPowerPrefCmd = "gnome-power-preferences";
 
61
                g_free (cResult);
 
62
        }
 
63
        if (cPowerPrefCmd)
 
64
        {
 
65
                CD_APPLET_ADD_IN_MENU_WITH_STOCK_AND_DATA (D_("Set up power management"), MY_APPLET_SHARE_DATA_DIR"/default-battery.svg", power_launch_cmd, CD_APPLET_MY_MENU, (gpointer)cPowerPrefCmd);
 
66
        }
 
67
        
 
68
        // Power statistics
 
69
        static gboolean bPowerStatsChecked = FALSE;
 
70
        static const gchar *cPowerStatsCmd = NULL;
 
71
        if (!bPowerStatsChecked)
 
72
        {
 
73
                bPowerStatsChecked = TRUE;
 
74
                gchar *cResult = cairo_dock_launch_command_sync ("which gnome-power-statistics");
 
75
                if (cResult != NULL && *cResult == '/')  /// TODO: other DE...
 
76
                        cPowerStatsCmd = "gnome-power-statistics";
 
77
                g_free (cResult);
 
78
        }
 
79
        if (cPowerStatsCmd)
 
80
        {
 
81
                CD_APPLET_ADD_IN_MENU_WITH_STOCK_AND_DATA (D_("Power statistics"), MY_APPLET_SHARE_DATA_DIR"/default-battery.svg", power_launch_cmd, CD_APPLET_MY_MENU, (gpointer)cPowerStatsCmd);
 
82
        }
 
83
        
 
84
        // Power actions (Hibernate/Suspend)
57
85
        if (cd_power_can_hibernate ())
58
86
                CD_APPLET_ADD_IN_MENU (D_("Hibernate"), cd_power_hibernate, pSubMenu);
59
87
        if (cd_power_can_suspend ())