[gnome-commander] tab lock: added popup menu and user action (view.toggle_lock_tab)
- From: Piotr Eljasiak <epiotr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] tab lock: added popup menu and user action (view.toggle_lock_tab)
- Date: Mon, 10 Jan 2011 20:25:32 +0000 (UTC)
commit 82a4768c956fe8e798ee6682715f03da13ae3168
Author: Piotr Eljasiak <epiotr src gnome org>
Date: Mon Jan 10 21:13:38 2011 +0100
tab lock: added popup menu and user action (view.toggle_lock_tab)
src/gnome-cmd-file-selector.cc | 20 ++++++++++++++++++++
src/gnome-cmd-file-selector.h | 1 +
src/gnome-cmd-user-actions.cc | 38 ++++++++++++++++++++++++++++++++++++++
src/gnome-cmd-user-actions.h | 1 +
4 files changed, 60 insertions(+), 0 deletions(-)
---
diff --git a/src/gnome-cmd-file-selector.cc b/src/gnome-cmd-file-selector.cc
index 2f8e0d3..e4cdc93 100644
--- a/src/gnome-cmd-file-selector.cc
+++ b/src/gnome-cmd-file-selector.cc
@@ -626,6 +626,11 @@ static gboolean on_notebook_button_pressed (GtkWidget *widget, GdkEventButton *e
gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ());
+ menuitem = gtk_image_menu_item_new_with_mnemonic (fl->locked ? _("_Unlock Tab") : _("_Lock Tab"));
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), gtk_image_new_from_file (fl->locked ? PACKAGE_NAME G_DIR_SEPARATOR_S "unpin.png" : PACKAGE_NAME G_DIR_SEPARATOR_S "pin.png"));
+ g_signal_connect (menuitem, "activate", G_CALLBACK (view_toggle_tab_lock), GINT_TO_POINTER (fs->is_active() ? tab_clicked+1 : -tab_clicked-1));
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+
menuitem = gtk_image_menu_item_new_with_mnemonic (_("_Refresh Tab"));
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), gtk_image_new_from_stock (GTK_STOCK_REFRESH, GTK_ICON_SIZE_MENU));
g_signal_connect (menuitem, "activate", G_CALLBACK (view_refresh), fl);
@@ -1399,6 +1404,21 @@ void GnomeCmdFileSelector::update_tab_label(const GnomeCmdFileList *fl)
}
+void GnomeCmdFileSelector::update_tab_label(const GnomeCmdFileList *fl, gint page)
+{
+ const gchar *name = GNOME_CMD_FILE (fl->cwd)->get_name();
+
+ if (fl->locked)
+ {
+ gchar *s = g_strconcat ("* ", name, NULL);
+ notebook->set_label(page,s);
+ g_free (s);
+ }
+ else
+ notebook->set_label(page,name);
+}
+
+
XML::xstream &operator << (XML::xstream &xml, GnomeCmdFileSelector &fs)
{
if (gnome_cmd_data.save_tabs_on_exit)
diff --git a/src/gnome-cmd-file-selector.h b/src/gnome-cmd-file-selector.h
index 1fe8887..6498a8e 100644
--- a/src/gnome-cmd-file-selector.h
+++ b/src/gnome-cmd-file-selector.h
@@ -92,6 +92,7 @@ struct GnomeCmdFileSelector
void close_tab(gint n) { if (notebook->size()>1) notebook->remove_page(n); }
void update_tab_label(const GnomeCmdFileList *fl);
+ void update_tab_label(const GnomeCmdFileList *fl, gint page);
void show_filter();
void update_files();
diff --git a/src/gnome-cmd-user-actions.cc b/src/gnome-cmd-user-actions.cc
index 25d2cb1..d9476d5 100644
--- a/src/gnome-cmd-user-actions.cc
+++ b/src/gnome-cmd-user-actions.cc
@@ -218,6 +218,7 @@ static UserActionData user_actions_data[] = {
{view_prev_tab, "view.prev_tab", N_("Previous tab")},
{view_refresh, "view.refresh", N_("Refresh")},
{view_root, "view.root", N_("Root directory")},
+ {view_toggle_tab_lock, "view.toggle_lock_tab", N_("Lock/unlock tab")},
#if 0
{view_terminal, "view.terminal", N_("Show terminal")},
#endif
@@ -1608,6 +1609,43 @@ void view_in_inactive_tab (GtkMenuItem *menuitem, gpointer file_list)
}
+void view_toggle_tab_lock (GtkMenuItem *menuitem, gpointer page)
+{
+ // 0 -> current tab
+ // 1 .. n -> tab #n for active fs
+ // -1 .. -n -> tab #n for inactive fs
+
+ GnomeCmdFileSelector *fs;
+ GnomeCmdFileList *fl;
+
+ if (!page)
+ {
+ fs = get_fs (ACTIVE);
+ fl = get_fl (ACTIVE);
+
+ if (fs && fl)
+ {
+ fl->locked = !fl->locked;
+ fs->update_tab_label(fl);
+ }
+
+ return;
+ }
+
+ int n = GPOINTER_TO_INT (page);
+
+ fs = get_fs (n>0 ? ACTIVE : INACTIVE);
+ n = ABS(n)-1;
+ fl = fs->file_list(n);
+
+ if (fs && fl)
+ {
+ fl->locked = !fl->locked;
+ fs->update_tab_label(fl,n);
+ }
+}
+
+
/************** Options Menu **************/
void options_edit (GtkMenuItem *menuitem, gpointer not_used)
{
diff --git a/src/gnome-cmd-user-actions.h b/src/gnome-cmd-user-actions.h
index 9936a20..8e8d10f 100644
--- a/src/gnome-cmd-user-actions.h
+++ b/src/gnome-cmd-user-actions.h
@@ -304,6 +304,7 @@ GNOME_CMD_USER_ACTION(view_prev_tab);
GNOME_CMD_USER_ACTION(view_next_tab);
GNOME_CMD_USER_ACTION(view_in_new_tab);
GNOME_CMD_USER_ACTION(view_in_inactive_tab);
+GNOME_CMD_USER_ACTION(view_toggle_tab_lock);
/************** Bookmarks Menu **************/
GNOME_CMD_USER_ACTION(bookmarks_add_current);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]