2
* This file is a part of the Cairo-Dock project
4
* Copyright : (C) see the 'copyright' file.
5
* E-mail : see the 'copyright' file.
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 3
10
* of the License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23
#include "applet-struct.h"
24
#include "applet-recent.h"
25
#include "applet-run-dialog.h"
26
#include "applet-notifications.h"
28
static const gchar *s_cEditMenuCmd = NULL; // we need to check with 'which' only one time if alacarte or kmenuedit is available
30
static void cd_menu_show_menu (void)
32
if (myData.pMenu != NULL)
34
CD_APPLET_POPUP_MENU_ON_MY_ICON (myData.pMenu);
38
static void cd_menu_show_hide_quick_launch (void)
40
cd_run_dialog_show_hide (myApplet);
43
//\___________ Define here the action to be taken when the user left-clicks on your icon or on its subdock or your desklet. The icon and the container that were clicked are available through the macros CD_APPLET_CLICKED_ICON and CD_APPLET_CLICKED_CONTAINER. CD_APPLET_CLICKED_ICON may be NULL if the user clicked in the container but out of icons.
44
CD_APPLET_ON_CLICK_BEGIN
46
CD_APPLET_ON_CLICK_END
49
//\___________ Define here the entries you want to add to the menu when the user right-clicks on your icon or on its subdock or your desklet. The icon and the container that were clicked are available through the macros CD_APPLET_CLICKED_ICON and CD_APPLET_CLICKED_CONTAINER. CD_APPLET_CLICKED_ICON may be NULL if the user clicked in the container but out of icons. The menu where you can add your entries is available throught the macro CD_APPLET_MY_MENU; you can add sub-menu to it if you want.
50
static void _cd_menu_configure_menu (GtkMenuItem *menu_item, gpointer data)
54
if (myConfig.cConfigureMenuCommand != NULL)
56
g_spawn_command_line_async (myConfig.cConfigureMenuCommand, &error);
58
else if (s_cEditMenuCmd != NULL)
60
g_spawn_command_line_async (s_cEditMenuCmd, &error);
65
cd_warning ("Attention : when trying to execute '%s' : %s",
66
myConfig.cConfigureMenuCommand ? myConfig.cConfigureMenuCommand : s_cEditMenuCmd,
73
static gboolean _cd_check_edit_menu_cmd (const gchar *cWhich)
75
gchar *cResult = cairo_dock_launch_command_sync (cWhich); // Gnome (2 + 3(?)) + XFCE(?)
76
gboolean bResult = (cResult != NULL && *cResult == '/');
81
CD_APPLET_ON_BUILD_MENU_BEGIN
82
gchar *cLabel = g_strdup_printf ("%s (%s)", D_("Quick launch"), D_("middle-click"));
83
CD_APPLET_ADD_IN_MENU_WITH_STOCK (cLabel, GTK_STOCK_EXECUTE, cd_menu_show_hide_quick_launch, CD_APPLET_MY_MENU);
85
CD_APPLET_ADD_SEPARATOR_IN_MENU (CD_APPLET_MY_MENU);
87
static gboolean bEditMenuCmdChecked = FALSE;
88
if (!myConfig.cConfigureMenuCommand && !bEditMenuCmdChecked)
90
bEditMenuCmdChecked = TRUE;
91
if (_cd_check_edit_menu_cmd ("which alacarte"))
92
s_cEditMenuCmd = "alacarte";
93
else if (_cd_check_edit_menu_cmd ("which kmenuedit"))
94
s_cEditMenuCmd = "kmenuedit";
95
else if (_cd_check_edit_menu_cmd ("which menulibre"))
96
s_cEditMenuCmd = "menulibre";
98
if (myConfig.cConfigureMenuCommand || s_cEditMenuCmd)
99
CD_APPLET_ADD_IN_MENU_WITH_STOCK (D_("Configure menu"), GTK_STOCK_PREFERENCES, _cd_menu_configure_menu, CD_APPLET_MY_MENU);
101
CD_APPLET_ADD_SEPARATOR_IN_MENU (CD_APPLET_MY_MENU);
102
CD_APPLET_ADD_IN_MENU_WITH_STOCK (D_("Clear recent"), GTK_STOCK_CLEAR, cd_menu_clear_recent, CD_APPLET_MY_MENU);
103
CD_APPLET_ON_BUILD_MENU_END
106
CD_APPLET_ON_MIDDLE_CLICK_BEGIN
107
cd_menu_show_hide_quick_launch ();
108
CD_APPLET_ON_MIDDLE_CLICK_END
111
void cd_menu_on_shortkey_menu (const char *keystring, gpointer data)
113
cd_menu_show_menu ();
116
void cd_menu_on_shortkey_quick_launch (const char *keystring, gpointer data)
118
cd_menu_show_hide_quick_launch ();