[gnome-commander] toolbar: 'terminal' button opens terminal with root privileges when clicked with SHIFT
- From: Piotr Eljasiak <epiotr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] toolbar: 'terminal' button opens terminal with root privileges when clicked with SHIFT
- Date: Thu, 16 Dec 2010 23:02:11 +0000 (UTC)
commit 1a045b4d80207d2a47f2dc931c504d7ee690516b
Author: Piotr Eljasiak <epiotr src gnome org>
Date: Fri Dec 17 00:00:25 2010 +0100
toolbar: 'terminal' button opens terminal with root privileges when clicked with SHIFT
src/gnome-cmd-file-popmenu.cc | 2 +-
src/gnome-cmd-list-popmenu.cc | 2 +-
src/gnome-cmd-main-win.cc | 2 +-
src/gnome-cmd-user-actions.cc | 15 ++++++++++++++-
src/gnome-cmd-user-actions.h | 1 +
5 files changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/src/gnome-cmd-file-popmenu.cc b/src/gnome-cmd-file-popmenu.cc
index f54019c..ff6d30a 100644
--- a/src/gnome-cmd-file-popmenu.cc
+++ b/src/gnome-cmd-file-popmenu.cc
@@ -457,7 +457,7 @@ GtkWidget *gnome_cmd_file_popmenu_new (GnomeCmdFileList *fl)
GNOMEUIINFO_ITEM_NONE (N_("Rename"), NULL, on_rename),
GNOMEUIINFO_ITEM_STOCK(N_("Send files"), NULL, file_sendto, GNOME_STOCK_MAIL_SND),
GNOMEUIINFO_ITEM_FILENAME (N_("Open this _folder"), NULL, command_open_nautilus, PACKAGE_NAME G_DIR_SEPARATOR_S "nautilus.svg"),
- GNOMEUIINFO_ITEM_FILENAME (N_("Open _terminal here"), NULL, command_open_terminal, PACKAGE_NAME G_DIR_SEPARATOR_S "terminal.svg"),
+ GNOMEUIINFO_ITEM_FILENAME (N_("Open _terminal here"), NULL, command_open_terminal__internal, PACKAGE_NAME G_DIR_SEPARATOR_S "terminal.svg"),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_STOCK(N_("_Properties..."), NULL, on_properties, GTK_STOCK_PROPERTIES),
GNOMEUIINFO_END
diff --git a/src/gnome-cmd-list-popmenu.cc b/src/gnome-cmd-list-popmenu.cc
index 4a6b949..edb1449 100644
--- a/src/gnome-cmd-list-popmenu.cc
+++ b/src/gnome-cmd-list-popmenu.cc
@@ -115,7 +115,7 @@ GtkWidget *gnome_cmd_list_popmenu_new (GnomeCmdFileSelector *fs)
GNOMEUIINFO_ITEM_STOCK(N_("_Paste"), NULL, on_paste, GTK_STOCK_PASTE),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_FILENAME (N_("Open this _folder"), NULL, command_open_nautilus_in_cwd, PACKAGE_NAME G_DIR_SEPARATOR_S "nautilus.svg"),
- GNOMEUIINFO_ITEM_FILENAME (N_("Open _terminal here"), NULL, command_open_terminal, PACKAGE_NAME G_DIR_SEPARATOR_S "terminal.svg"),
+ GNOMEUIINFO_ITEM_FILENAME (N_("Open _terminal here"), NULL, command_open_terminal__internal, PACKAGE_NAME G_DIR_SEPARATOR_S "terminal.svg"),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_STOCK(N_("_Refresh"), NULL, on_refresh, GTK_STOCK_REFRESH),
GNOMEUIINFO_END
diff --git a/src/gnome-cmd-main-win.cc b/src/gnome-cmd-main-win.cc
index fc56309..7c46d16 100644
--- a/src/gnome-cmd-main-win.cc
+++ b/src/gnome-cmd-main-win.cc
@@ -1171,7 +1171,7 @@ void GnomeCmdMainWin::update_toolbar_visibility()
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_STOCK(NULL, _("Edit (SHIFT for new document)"), file_edit, GTK_STOCK_EDIT),
GNOMEUIINFO_ITEM_STOCK(NULL, _("Send files"), file_sendto, GNOME_STOCK_MAIL_SND),
- GNOMEUIINFO_ITEM_FILENAME(NULL, _("Open terminal"), command_open_terminal, PACKAGE_NAME G_DIR_SEPARATOR_S "terminal.svg"),
+ GNOMEUIINFO_ITEM_FILENAME(NULL, _("Open terminal (SHIFT for root privileges)"), command_open_terminal__internal, PACKAGE_NAME G_DIR_SEPARATOR_S "terminal.svg"),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_STOCK(NULL, _("Remote Server"), connections_open, GTK_STOCK_CONNECT),
GNOMEUIINFO_ITEM_NONE(NULL, _("Drop connection"), connections_close_current),
diff --git a/src/gnome-cmd-user-actions.cc b/src/gnome-cmd-user-actions.cc
index 30d641e..cb83386 100644
--- a/src/gnome-cmd-user-actions.cc
+++ b/src/gnome-cmd-user-actions.cc
@@ -1169,6 +1169,19 @@ void command_execute (GtkMenuItem *menuitem, gpointer command)
}
+void command_open_terminal__internal (GtkMenuItem *menuitem, gpointer not_used) // this function is NOT exposed to user as UserAction
+{
+ GdkModifierType mask;
+
+ gdk_window_get_pointer (NULL, NULL, NULL, &mask);
+
+ if (mask & GDK_SHIFT_MASK)
+ command_open_terminal_as_root (menuitem, NULL);
+ else
+ command_open_terminal (menuitem, NULL);
+}
+
+
void command_open_terminal (GtkMenuItem *menuitem, gpointer not_used)
{
gchar *dpath = GNOME_CMD_FILE (get_fs (ACTIVE)->get_directory())->get_real_path();
@@ -1247,7 +1260,7 @@ void command_root_mode (GtkMenuItem *menuitem, gpointer not_used)
char **argv = g_new0 (char *, argc+1);
argv[0] = g_strdup (g_get_prgname ());
-
+
if (gnome_cmd_prepend_su_to_vector (argc, argv))
{
GError *error = NULL;
diff --git a/src/gnome-cmd-user-actions.h b/src/gnome-cmd-user-actions.h
index 029bdeb..08407a0 100644
--- a/src/gnome-cmd-user-actions.h
+++ b/src/gnome-cmd-user-actions.h
@@ -268,6 +268,7 @@ GNOME_CMD_USER_ACTION(edit_copy_fnames);
/************** Command Menu **************/
GNOME_CMD_USER_ACTION(command_execute);
+GNOME_CMD_USER_ACTION(command_open_terminal__internal); // this function is NOT exposed to user as UserAction
GNOME_CMD_USER_ACTION(command_open_terminal);
GNOME_CMD_USER_ACTION(command_open_terminal_as_root);
GNOME_CMD_USER_ACTION(command_open_nautilus);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]