[file-roller: 19/26] file selector: added a context menu for the list commands
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller: 19/26] file selector: added a context menu for the list commands
- Date: Thu, 9 Aug 2012 20:19:36 +0000 (UTC)
commit 1117070ceaf44cf2b5d57224066498edbf9d0a88
Author: Paolo Bacchilega <paobac src gnome org>
Date: Thu Aug 9 15:48:48 2012 +0200
file selector: added a context menu for the list commands
removed the 'show hidden files' button; moved the command in the file
list context menu; added select/deselect all to the context menu.
src/fr-file-selector-dialog.c | 87 ++++++++++++++++++++++++++++++++++++----
src/ui/file-selector.ui | 90 +++++++++++++++++++++++-----------------
2 files changed, 131 insertions(+), 46 deletions(-)
---
diff --git a/src/fr-file-selector-dialog.c b/src/fr-file-selector-dialog.c
index b599d2b..9c4700a 100644
--- a/src/fr-file-selector-dialog.c
+++ b/src/fr-file-selector-dialog.c
@@ -1095,6 +1095,65 @@ go_up_button_clicked_cb (GtkButton *button,
}
+static gboolean
+files_treeview_button_press_event_cb (GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer user_data)
+{
+ FrFileSelectorDialog *self = user_data;
+
+ if (event->button == 3) {
+ gtk_menu_popup (GTK_MENU (GET_WIDGET ("file_list_context_menu")),
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ event->button,
+ event->time);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+static void
+select_all_files (FrFileSelectorDialog *self,
+ gboolean value)
+{
+ GtkListStore *list_store;
+ GtkTreeIter iter;
+
+ list_store = GTK_LIST_STORE (GET_WIDGET ("files_liststore"));
+ if (! gtk_tree_model_get_iter_first (GTK_TREE_MODEL (list_store), &iter))
+ return;
+
+ do {
+ gtk_list_store_set (list_store, &iter,
+ FILE_LIST_COLUMN_IS_SELECTED, value,
+ -1);
+ }
+ while (gtk_tree_model_iter_next (GTK_TREE_MODEL (list_store), &iter));
+}
+
+
+static void
+select_all_menuitem_activate_cb (GtkMenuItem *menu_item,
+ gpointer user_data)
+{
+ select_all_files (FR_FILE_SELECTOR_DIALOG (user_data), TRUE);
+}
+
+
+static void
+unselect_all_menuitem_activate_cb (GtkMenuItem *menu_item,
+ gpointer user_data)
+{
+ select_all_files (FR_FILE_SELECTOR_DIALOG (user_data), FALSE);
+}
+
+
static void
_set_current_folder (FrFileSelectorDialog *self,
GFile *folder,
@@ -1102,14 +1161,14 @@ _set_current_folder (FrFileSelectorDialog *self,
static void
-hidden_files_togglebutton_toggled_cb (GtkToggleButton *toggle_button,
- gpointer user_data)
+show_hidden_files_menuitem_toggled_cb (GtkCheckMenuItem *checkmenuitem,
+ gpointer user_data)
{
FrFileSelectorDialog *self = user_data;
GFile *folder;
GList *selected_files;
- self->priv->show_hidden = gtk_toggle_button_get_active (toggle_button);
+ self->priv->show_hidden = gtk_check_menu_item_get_active (checkmenuitem);
folder = fr_file_selector_dialog_get_current_folder (self);
selected_files = fr_file_selector_dialog_get_selected_files (self);
_set_current_folder (self, folder, selected_files);
@@ -1158,7 +1217,7 @@ fr_file_selector_dialog_init (FrFileSelectorDialog *self)
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (GET_WIDGET ("places_liststore")), GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, GTK_SORT_ASCENDING);
gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (GET_WIDGET ("places_treeview")), places_treeview_row_separator_func, self, NULL);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("hidden_files_togglebutton")), self->priv->show_hidden);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (GET_WIDGET ("show_hidden_files_menuitem")), self->priv->show_hidden);
g_signal_connect (GET_WIDGET ("is_selected_cellrenderertoggle"),
"toggled",
@@ -1172,14 +1231,26 @@ fr_file_selector_dialog_init (FrFileSelectorDialog *self)
"clicked",
G_CALLBACK (go_up_button_clicked_cb),
self);
- g_signal_connect (GET_WIDGET ("hidden_files_togglebutton"),
- "toggled",
- G_CALLBACK (hidden_files_togglebutton_toggled_cb),
- self);
g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (GET_WIDGET ("places_treeview"))),
"changed",
G_CALLBACK (places_treeview_selection_changed_cb),
self);
+ g_signal_connect (GET_WIDGET ("files_treeview"),
+ "button-press-event",
+ G_CALLBACK (files_treeview_button_press_event_cb),
+ self);
+ g_signal_connect (GET_WIDGET ("select_all_menuitem"),
+ "activate",
+ G_CALLBACK (select_all_menuitem_activate_cb),
+ self);
+ g_signal_connect (GET_WIDGET ("unselect_all_menuitem"),
+ "activate",
+ G_CALLBACK (unselect_all_menuitem_activate_cb),
+ self);
+ g_signal_connect (GET_WIDGET ("show_hidden_files_menuitem"),
+ "toggled",
+ G_CALLBACK (show_hidden_files_menuitem_toggled_cb),
+ self);
monitor = g_volume_monitor_get ();
g_signal_connect (monitor, "drive-changed", G_CALLBACK (volume_list_changed_cb), self);
diff --git a/src/ui/file-selector.ui b/src/ui/file-selector.ui
index b1d16cd..45fa980 100644
--- a/src/ui/file-selector.ui
+++ b/src/ui/file-selector.ui
@@ -25,6 +25,22 @@
<column type="gboolean"/>
</columns>
</object>
+ <object class="GtkListStore" id="places_liststore">
+ <columns>
+ <!-- column-name icon -->
+ <column type="GdkPixbuf"/>
+ <!-- column-name name -->
+ <column type="gchararray"/>
+ <!-- column-name file -->
+ <column type="GObject"/>
+ <!-- column-name is_separator -->
+ <column type="gboolean"/>
+ <!-- column-name type -->
+ <column type="gint"/>
+ <!-- column-name sort_order -->
+ <column type="gint"/>
+ </columns>
+ </object>
<object class="GtkBox" id="content">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -96,29 +112,6 @@
<property name="position">2</property>
</packing>
</child>
- <child>
- <object class="GtkToggleButton" id="hidden_files_togglebutton">
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes">Show hidden files</property>
- <property name="use_action_appearance">False</property>
- <property name="relief">none</property>
- <child>
- <object class="GtkImage" id="image2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">emblem-system-symbolic</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">3</property>
- </packing>
- </child>
</object>
<packing>
<property name="expand">False</property>
@@ -286,21 +279,42 @@
</packing>
</child>
</object>
- <object class="GtkListStore" id="places_liststore">
- <columns>
- <!-- column-name icon -->
- <column type="GdkPixbuf"/>
- <!-- column-name name -->
- <column type="gchararray"/>
- <!-- column-name file -->
- <column type="GObject"/>
- <!-- column-name is_separator -->
- <column type="gboolean"/>
- <!-- column-name type -->
- <column type="gint"/>
- <!-- column-name sort_order -->
- <column type="gint"/>
- </columns>
+ <object class="GtkMenu" id="file_list_context_menu">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkMenuItem" id="select_all_menuitem">
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Select All</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="unselect_all_menuitem">
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Dese_lect All</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSeparatorMenuItem" id="menuitem3">
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkCheckMenuItem" id="show_hidden_files_menuitem">
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Show Hidden FIles</property>
+ </object>
+ </child>
</object>
<object class="GtkSizeGroup" id="toolbar_sizegroup"/>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]