[gnome-commander] Options: support for tab lock indicator configuration
- From: Piotr Eljasiak <epiotr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] Options: support for tab lock indicator configuration
- Date: Sat, 12 Feb 2011 10:19:57 +0000 (UTC)
commit 4348bef1893c19888aa2754486f3c522487c70b6
Author: Piotr Eljasiak <epiotr src gnome org>
Date: Sat Feb 12 11:14:50 2011 +0100
Options: support for tab lock indicator configuration
doc/C/gnome-commander.xml | 7 +++
src/gnome-cmd-data.cc | 3 +
src/gnome-cmd-data.h | 8 ++++
src/gnome-cmd-file-list.cc | 2 +
src/gnome-cmd-file-list.h | 3 +
src/gnome-cmd-file-selector.cc | 79 ++++++++++++++++++++++++++++-----------
src/gnome-cmd-file-selector.h | 3 +-
src/gnome-cmd-options-dialog.cc | 32 ++++++++++++++++
src/gnome-cmd-user-actions.cc | 25 +-----------
9 files changed, 116 insertions(+), 46 deletions(-)
---
diff --git a/doc/C/gnome-commander.xml b/doc/C/gnome-commander.xml
index 32b1107..7b91f4b 100644
--- a/doc/C/gnome-commander.xml
+++ b/doc/C/gnome-commander.xml
@@ -7411,6 +7411,13 @@
</row>
<row valign="top">
<entry><para></para></entry>
+ <entry><para>tab_lock_indicator</para></entry>
+ <entry><para>integer</para></entry>
+ <entry><para></para></entry>
+ <entry><para><xref linkend="gnome-commander-prefs-tabs"/></para></entry>
+ </row>
+ <row valign="top">
+ <entry><para></para></entry>
<entry><para>allow_multiple_instances</para></entry>
<entry><para></para></entry>
<entry><para></para></entry>
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index 8604090..0eb96da 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -946,6 +946,7 @@ GnomeCmdData::GnomeCmdData()
save_tabs_on_exit = TRUE;
always_show_tabs = FALSE;
+ tab_lock_indicator = TAB_LOCK_ICON;
allow_multiple_instances = FALSE;
use_internal_viewer = TRUE;
@@ -1230,6 +1231,7 @@ void GnomeCmdData::load()
save_tabs_on_exit = gnome_cmd_data_get_bool ("/options/save_tabs_on_exit", TRUE);
always_show_tabs = gnome_cmd_data_get_bool ("/options/always_show_tabs", FALSE);
+ tab_lock_indicator = (TabLockIndicator) gnome_cmd_data_get_int ("/options/tab_lock_indicator", TAB_LOCK_ICON);
priv->last_pattern = gnome_cmd_data_get_string ("/defaults/last_pattern", "");
priv->backup_pattern = gnome_cmd_data_get_string ("/defaults/backup_pattern", "*~;*.bak");
@@ -1647,6 +1649,7 @@ void GnomeCmdData::save()
gnome_cmd_data_set_bool ("/options/save_tabs_on_exit", save_tabs_on_exit);
gnome_cmd_data_set_bool ("/options/always_show_tabs", always_show_tabs);
+ gnome_cmd_data_set_int ("/options/tab_lock_indicator", (int) tab_lock_indicator);
gnome_cmd_data_set_string ("/defaults/last_pattern", priv->last_pattern);
gnome_cmd_data_set_string ("/defaults/backup_pattern", priv->backup_pattern);
diff --git a/src/gnome-cmd-data.h b/src/gnome-cmd-data.h
index 691ddea..bde9ec6 100644
--- a/src/gnome-cmd-data.h
+++ b/src/gnome-cmd-data.h
@@ -55,6 +55,13 @@ struct GnomeCmdData
RIGHT_BUTTON_POPUPS_MENU,
RIGHT_BUTTON_SELECTS
};
+
+ enum TabLockIndicator
+ {
+ TAB_LOCK_ICON,
+ TAB_LOCK_ASTERISK,
+ TAB_LOCK_STYLED_TEXT
+ };
enum {SEARCH_HISTORY_SIZE=10, ADVRENAME_HISTORY_SIZE=10, INTVIEWER_HISTORY_SIZE=16};
@@ -243,6 +250,7 @@ struct GnomeCmdData
gboolean save_tabs_on_exit;
gboolean always_show_tabs;
+ int tab_lock_indicator;
gboolean allow_multiple_instances;
gboolean use_internal_viewer;
diff --git a/src/gnome-cmd-file-list.cc b/src/gnome-cmd-file-list.cc
index d316590..193844a 100644
--- a/src/gnome-cmd-file-list.cc
+++ b/src/gnome-cmd-file-list.cc
@@ -217,6 +217,8 @@ GnomeCmdFileList::Private::~Private()
GnomeCmdFileList::GnomeCmdFileList(ColumnID sort_col, GtkSortType sort_order)
{
+ tab_label_pin = NULL;
+ tab_label_text = NULL;
realized = FALSE;
modifier_click = FALSE;
locked = FALSE;
diff --git a/src/gnome-cmd-file-list.h b/src/gnome-cmd-file-list.h
index 2ec0ab1..1cdb96f 100644
--- a/src/gnome-cmd-file-list.h
+++ b/src/gnome-cmd-file-list.h
@@ -68,6 +68,9 @@ struct GnomeCmdFileList
Private *priv;
+ GtkWidget *tab_label_pin;
+ GtkWidget *tab_label_text;
+
gboolean realized;
gboolean modifier_click;
diff --git a/src/gnome-cmd-file-selector.cc b/src/gnome-cmd-file-selector.cc
index ad547d5..092d3be 100644
--- a/src/gnome-cmd-file-selector.cc
+++ b/src/gnome-cmd-file-selector.cc
@@ -979,6 +979,20 @@ void GnomeCmdFileSelector::update_connections()
}
+static void update_style_notebook_tab (GtkWidget *widget, GnomeCmdFileSelector *fs)
+{
+ GnomeCmdFileList *fl = (GnomeCmdFileList *) gtk_bin_get_child (GTK_BIN (widget));
+
+ g_return_if_fail (GNOME_CMD_IS_FILE_LIST (fl));
+
+ if (gnome_cmd_data.tab_lock_indicator!=GnomeCmdData::TAB_LOCK_ICON)
+ gtk_widget_hide (fl->tab_label_pin);
+
+ if (fl->locked)
+ fs->update_tab_label(fl);
+}
+
+
void GnomeCmdFileSelector::update_style()
{
con_combo->update_style();
@@ -991,6 +1005,8 @@ void GnomeCmdFileSelector::update_style()
notebook->show_tabs(gnome_cmd_data.always_show_tabs ? GnomeCmdNotebook::SHOW_TABS : GnomeCmdNotebook::HIDE_TABS_IF_ONE);
+ gtk_container_foreach (*notebook, (GtkCallback) update_style_notebook_tab, this);
+
create_con_buttons (this);
update_connections();
}
@@ -1375,8 +1391,19 @@ GtkWidget *GnomeCmdFileSelector::new_tab(GnomeCmdDir *dir, GnomeCmdFileList::Col
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (scrolled_window), *list);
- GtkWidget *label = gtk_label_new (dir ? GNOME_CMD_FILE (dir)->get_name() : NULL);
- gint n = notebook->append_page(scrolled_window, label);
+ GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
+
+ list->tab_label_pin = gtk_image_new_from_file (PIXMAPS_DIR G_DIR_SEPARATOR_S "pin.png");
+ list->tab_label_text = gtk_label_new (dir ? GNOME_CMD_FILE (dir)->get_name() : NULL);
+
+ gtk_box_pack_start (GTK_BOX (hbox), list->tab_label_pin, FALSE, FALSE, 3);
+ gtk_box_pack_start (GTK_BOX (hbox), list->tab_label_text, FALSE, FALSE, 0);
+
+ if (locked && gnome_cmd_data.tab_lock_indicator==GnomeCmdData::TAB_LOCK_ICON)
+ gtk_widget_show (list->tab_label_pin);
+ gtk_widget_show (list->tab_label_text);
+
+ gint n = notebook->append_page(scrolled_window, hbox);
#if GTK_CHECK_VERSION (2, 10, 0)
gtk_notebook_set_tab_reorderable (*notebook, scrolled_window, TRUE);
#endif
@@ -1408,33 +1435,41 @@ GtkWidget *GnomeCmdFileSelector::new_tab(GnomeCmdDir *dir, GnomeCmdFileList::Col
}
-void GnomeCmdFileSelector::update_tab_label(const GnomeCmdFileList *fl)
+void GnomeCmdFileSelector::update_tab_label(GnomeCmdFileList *fl)
{
const gchar *name = GNOME_CMD_FILE (fl->cwd)->get_name();
- if (fl->locked)
+ switch (gnome_cmd_data.tab_lock_indicator)
{
- gchar *s = g_strconcat ("* ", name, NULL);
- notebook->set_label(s);
- g_free (s);
- }
- else
- notebook->set_label(name);
-}
-
+ case GnomeCmdData::TAB_LOCK_ICON:
+ if (fl->locked)
+ gtk_widget_show (fl->tab_label_pin);
+ else
+ gtk_widget_hide (fl->tab_label_pin);
+ break;
-void GnomeCmdFileSelector::update_tab_label(const GnomeCmdFileList *fl, gint page)
-{
- const gchar *name = GNOME_CMD_FILE (fl->cwd)->get_name();
+ case GnomeCmdData::TAB_LOCK_ASTERISK:
+ if (fl->locked)
+ {
+ gchar *s = g_strconcat ("* ", name, NULL);
+ gtk_label_set_text (GTK_LABEL (fl->tab_label_text), s);
+ g_free (s);
+ return;
+ }
+ break;
- if (fl->locked)
- {
- gchar *s = g_strconcat ("* ", name, NULL);
- notebook->set_label(page,s);
- g_free (s);
+ case GnomeCmdData::TAB_LOCK_STYLED_TEXT:
+ if (fl->locked)
+ {
+ gchar *s = g_strconcat ("<span foreground='blue'>", name, "</span>", NULL);
+ gtk_label_set_markup (GTK_LABEL (fl->tab_label_text), s);
+ g_free (s);
+ return;
+ }
+ break;
}
- else
- notebook->set_label(page,name);
+
+ gtk_label_set_text (GTK_LABEL (fl->tab_label_text), name);
}
diff --git a/src/gnome-cmd-file-selector.h b/src/gnome-cmd-file-selector.h
index 98c8335..ed41523 100644
--- a/src/gnome-cmd-file-selector.h
+++ b/src/gnome-cmd-file-selector.h
@@ -93,8 +93,7 @@ struct GnomeCmdFileSelector
void close_tab() { if (notebook->size()>1) notebook->remove_page(); }
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 update_tab_label(GnomeCmdFileList *fl);
void show_filter();
void update_files();
diff --git a/src/gnome-cmd-options-dialog.cc b/src/gnome-cmd-options-dialog.cc
index 983aa6c..3e4d37f 100644
--- a/src/gnome-cmd-options-dialog.cc
+++ b/src/gnome-cmd-options-dialog.cc
@@ -846,6 +846,7 @@ static GtkWidget *create_tabs_tab (GtkWidget *parent)
vbox = create_tabvbox (parent);
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
+
cat_box = create_vbox (parent, FALSE, 0);
cat = create_category (parent, cat_box, _("Tab bar"));
gtk_box_pack_start (GTK_BOX (vbox), cat, FALSE, TRUE, 0);
@@ -854,6 +855,27 @@ static GtkWidget *create_tabs_tab (GtkWidget *parent)
gtk_box_pack_start (GTK_BOX (cat_box), check, FALSE, TRUE, 0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), gnome_cmd_data.always_show_tabs);
+
+ // Size display mode
+ cat_box = create_vbox (parent, FALSE, 0);
+ cat = create_category (parent, cat_box, _("Tab lock indicator"));
+ gtk_box_pack_start (GTK_BOX (vbox), cat, FALSE, TRUE, 0);
+
+ radio = create_radio (parent, NULL, _("Lock icon"), "tab_lock_icon_radio");
+ gtk_container_add (GTK_CONTAINER (cat_box), radio);
+ if (gnome_cmd_data.tab_lock_indicator == GnomeCmdData::TAB_LOCK_ICON)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
+
+ radio = create_radio (parent, get_radio_group (radio), _("* (asterisk)"), "tab_lock_asterisk_radio");
+ gtk_container_add (GTK_CONTAINER (cat_box), radio);
+ if (gnome_cmd_data.tab_lock_indicator == GnomeCmdData::TAB_LOCK_ASTERISK)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
+
+ radio = create_radio (parent, get_radio_group (radio), _("Styled text"), "tab_lock_style_radio");
+ gtk_container_add (GTK_CONTAINER (cat_box), radio);
+ if (gnome_cmd_data.tab_lock_indicator == GnomeCmdData::TAB_LOCK_STYLED_TEXT)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
+
return frame;
}
@@ -861,8 +883,18 @@ static GtkWidget *create_tabs_tab (GtkWidget *parent)
inline void store_tabs_options (GtkWidget *dialog)
{
GtkWidget *always_show_tabs = lookup_widget (dialog, "always_show_tabs");
+ GtkWidget *tab_lock_icon_radio = lookup_widget (dialog, "tab_lock_icon_radio");
+ GtkWidget *tab_lock_asterisk_radio = lookup_widget (dialog, "tab_lock_asterisk_radio");
+ GtkWidget *tab_lock_style_radio = lookup_widget (dialog, "tab_lock_style_radio");
gnome_cmd_data.always_show_tabs = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (always_show_tabs));
+
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tab_lock_icon_radio)))
+ gnome_cmd_data.tab_lock_indicator = GnomeCmdData::TAB_LOCK_ICON;
+ else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tab_lock_asterisk_radio)))
+ gnome_cmd_data.tab_lock_indicator = GnomeCmdData::TAB_LOCK_ASTERISK;
+ else
+ gnome_cmd_data.tab_lock_indicator = GnomeCmdData::TAB_LOCK_STYLED_TEXT;
}
diff --git a/src/gnome-cmd-user-actions.cc b/src/gnome-cmd-user-actions.cc
index 9033765..1c77fcd 100644
--- a/src/gnome-cmd-user-actions.cc
+++ b/src/gnome-cmd-user-actions.cc
@@ -1623,33 +1623,14 @@ void view_toggle_tab_lock (GtkMenuItem *menuitem, gpointer page)
// 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);
+ GnomeCmdFileSelector *fs = get_fs (n>=0 ? ACTIVE : INACTIVE);
+ GnomeCmdFileList *fl = n==0 ? get_fl (ACTIVE) : fs->file_list(ABS(n)-1);
if (fs && fl)
{
fl->locked = !fl->locked;
- fs->update_tab_label(fl,n);
+ fs->update_tab_label(fl);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]