[file-roller] use a headerbar instead of a toolbar
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller] use a headerbar instead of a toolbar
- Date: Sat, 21 Dec 2013 16:01:36 +0000 (UTC)
commit 66d798e79c079af6fd9203f659ea6e158580c772
Author: Paolo Bacchilega <paobac src gnome org>
Date: Fri Dec 20 17:54:10 2013 +0100
use a headerbar instead of a toolbar
data/org.gnome.FileRoller.gschema.xml.in | 5 -
po/POTFILES.in | 4 +
src/Makefile.am | 3 +
src/app-menu.c | 15 ++
src/file-roller.gresource.xml | 1 +
src/fr-window-actions-callbacks.c | 149 ++++++++++++++
src/fr-window-actions-callbacks.h | 40 ++++
src/fr-window-actions-entries.h | 50 +++++
src/fr-window.c | 316 +++++++++++++-----------------
src/glib-utils.h | 1 +
src/gtk-utils.c | 256 ++++++++++++++++++++++++
src/gtk-utils.h | 26 +++
src/preferences.h | 1 -
src/ui.h | 2 -
src/ui/Makefile.am | 1 +
src/ui/app-menu.ui | 5 +-
src/ui/gears-menu.ui | 33 +++
src/ui/menus-toolbars.ui | 36 ----
18 files changed, 717 insertions(+), 227 deletions(-)
---
diff --git a/data/org.gnome.FileRoller.gschema.xml.in b/data/org.gnome.FileRoller.gschema.xml.in
index 664ba6f..6268df9 100644
--- a/data/org.gnome.FileRoller.gschema.xml.in
+++ b/data/org.gnome.FileRoller.gschema.xml.in
@@ -96,11 +96,6 @@
</schema>
<schema id="org.gnome.FileRoller.UI" path="/org/gnome/file-roller/ui/" gettext-domain="file-roller">
- <key name="history-len" type="i">
- <default>5</default>
- <_summary>Max history length</_summary>
- <_description>Max number of items in the 'Open Recents' submenu.</_description>
- </key>
<key name="window-width" type="i">
<default>600</default>
</key>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 076503c..4535521 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -104,6 +104,9 @@ src/fr-process.c
src/fr-process.h
src/fr-stock.c
src/fr-stock.h
+src/fr-window-actions-callbacks.c
+src/fr-window-actions-callbacks.h
+src/fr-window-actions-entries.h
src/fr-window.c
src/fr-window.h
src/gio-utils.c
@@ -142,6 +145,7 @@ src/typedefs.h
[type: gettext/glade]src/ui/error-dialog.ui
[type: gettext/glade]src/ui/extract-dialog-options.ui
[type: gettext/glade]src/ui/file-selector.ui
+[type: gettext/glade]src/ui/gears-menu.ui
src/ui.h
[type: gettext/glade]src/ui/menus-toolbars.ui
[type: gettext/glade]src/ui/message-dialog.ui
diff --git a/src/Makefile.am b/src/Makefile.am
index dfc0958..c289eab 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -144,6 +144,9 @@ COMMON_SOURCES = \
fr-process.h \
fr-window.c \
fr-window.h \
+ fr-window-actions-callbacks.c \
+ fr-window-actions-callbacks.h \
+ fr-window-actions-entries.h \
gio-utils.c \
gio-utils.h \
glib-utils.c \
diff --git a/src/app-menu.c b/src/app-menu.c
index 2adb77f..1d0a662 100644
--- a/src/app-menu.c
+++ b/src/app-menu.c
@@ -76,6 +76,20 @@ activate_new (GSimpleAction *action,
static void
+activate_open (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ GApplication *application = user_data;
+ GList *windows;
+
+ windows = gtk_application_get_windows (GTK_APPLICATION (application));
+ if (windows != NULL)
+ activate_action_open (NULL, windows->data);
+}
+
+
+static void
activate_view_sidebar (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
@@ -146,6 +160,7 @@ activate_quit (GSimpleAction *action,
static const GActionEntry app_menu_entries[] = {
{ "new", activate_new },
+ { "open", activate_open },
{ PREF_UI_VIEW_SIDEBAR, toggle_action_activated, NULL, "true", activate_view_sidebar },
{ PREF_LISTING_LIST_MODE, activate_list_mode, "s", "'as-dir'", NULL },
{ "help", activate_help },
diff --git a/src/file-roller.gresource.xml b/src/file-roller.gresource.xml
index 080073d..0c92547 100644
--- a/src/file-roller.gresource.xml
+++ b/src/file-roller.gresource.xml
@@ -10,6 +10,7 @@
<file compressed="true">ui/error-dialog.ui</file>
<file compressed="true">ui/extract-dialog-options.ui</file>
<file compressed="true">ui/file-selector.ui</file>
+ <file compressed="true">ui/gears-menu.ui</file>
<file compressed="true">ui/menus-toolbars.ui</file>
<file compressed="true">ui/message-dialog.ui</file>
<file compressed="true">ui/new-archive-dialog.ui</file>
diff --git a/src/fr-window-actions-callbacks.c b/src/fr-window-actions-callbacks.c
new file mode 100644
index 0000000..4bd3802
--- /dev/null
+++ b/src/fr-window-actions-callbacks.c
@@ -0,0 +1,149 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * File-Roller
+ *
+ * Copyright (C) 2013 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include <config.h>
+#include "dlg-add.h"
+#include "dlg-extract.h"
+#include "dlg-password.h"
+#include "dlg-prop.h"
+#include "fr-window.h"
+#include "fr-window-actions-callbacks.h"
+
+
+void
+toggle_action_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer data)
+{
+ GVariant *state;
+
+ state = g_action_get_state (G_ACTION (action));
+ g_action_change_state (G_ACTION (action), g_variant_new_boolean (! g_variant_get_boolean (state)));
+
+ g_variant_unref (state);
+}
+
+
+static GtkWidget *
+_gtk_application_get_current_window (GApplication *application)
+{
+ GList *windows;
+
+ windows = gtk_application_get_windows (GTK_APPLICATION (application));
+ if (windows == NULL)
+ return NULL;
+
+ return GTK_WIDGET (windows->data);
+}
+
+
+void
+fr_window_activate_add_files (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ dlg_add (FR_WINDOW (user_data));
+}
+
+
+void
+fr_window_activate_close (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ fr_window_close (FR_WINDOW (user_data));
+}
+
+
+void
+fr_window_activate_edit_find (GSimpleAction *action,
+ GVariant *state,
+ gpointer user_data)
+{
+ FrWindow *window = FR_WINDOW (user_data);
+
+ g_simple_action_set_state (action, state);
+ fr_window_find (window, g_variant_get_boolean (state));
+}
+
+
+void
+fr_window_activate_edit_password (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ dlg_password (NULL, FR_WINDOW (user_data));
+}
+
+
+void
+fr_window_activate_extract_files (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ dlg_extract (NULL, FR_WINDOW (user_data));
+}
+
+
+void
+fr_window_activate_go_back (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ fr_window_go_back (FR_WINDOW (user_data));
+}
+
+
+void
+fr_window_activate_go_forward (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ fr_window_go_forward (FR_WINDOW (user_data));
+}
+
+
+void
+fr_window_activate_save_as (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ fr_window_action_save_as (FR_WINDOW (user_data));
+}
+
+
+void
+fr_window_activate_test_archive (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ fr_window_archive_test (FR_WINDOW (user_data));
+}
+
+
+void
+fr_window_activate_view_properties (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ dlg_prop (FR_WINDOW (user_data));
+}
diff --git a/src/fr-window-actions-callbacks.h b/src/fr-window-actions-callbacks.h
new file mode 100644
index 0000000..86f8672
--- /dev/null
+++ b/src/fr-window-actions-callbacks.h
@@ -0,0 +1,40 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * File-Roller
+ *
+ * Copyright (C) 2013 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef FR_WINDOW_ACTION_CALLBACKS_H
+#define FR_WINDOW_ACTION_CALLBACKS_H
+
+#include <gtk/gtk.h>
+#include "glib-utils.h"
+
+DEF_ACTION_CALLBACK (toggle_action_activated)
+DEF_ACTION_CALLBACK (fr_window_activate_add_files)
+DEF_ACTION_CALLBACK (fr_window_activate_close)
+DEF_ACTION_CALLBACK (fr_window_activate_edit_find)
+DEF_ACTION_CALLBACK (fr_window_activate_edit_password)
+DEF_ACTION_CALLBACK (fr_window_activate_extract_files)
+DEF_ACTION_CALLBACK (fr_window_activate_go_back)
+DEF_ACTION_CALLBACK (fr_window_activate_go_forward)
+DEF_ACTION_CALLBACK (fr_window_activate_save_as)
+DEF_ACTION_CALLBACK (fr_window_activate_test_archive)
+DEF_ACTION_CALLBACK (fr_window_activate_view_properties)
+
+#endif /* FR_WINDOW_ACTION_CALLBACKS_H */
diff --git a/src/fr-window-actions-entries.h b/src/fr-window-actions-entries.h
new file mode 100644
index 0000000..ad05bc2
--- /dev/null
+++ b/src/fr-window-actions-entries.h
@@ -0,0 +1,50 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * File-Roller
+ *
+ * Copyright (C) 2013 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef FR_WINDOW_ACTION_ENTRIES_H
+#define FR_WINDOW_ACTION_ENTRIES_H
+
+#include <config.h>
+#include <glib/gi18n.h>
+#include "gtk-utils.h"
+#include "fr-window-actions-callbacks.h"
+
+
+static const GActionEntry fr_window_actions[] = {
+ { "add-files", fr_window_activate_add_files },
+ { "close", fr_window_activate_close },
+ { "edit-find", toggle_action_activated, NULL, "false", fr_window_activate_edit_find },
+ { "edit-password", fr_window_activate_edit_password },
+ { "extract-files", fr_window_activate_extract_files },
+ { "go-back", fr_window_activate_go_back },
+ { "go-forward", fr_window_activate_go_forward },
+ { "save-as", fr_window_activate_save_as },
+ { "test-archive", fr_window_activate_test_archive },
+ { "view-properties", fr_window_activate_view_properties },
+};
+
+
+static const FrAccelerator fr_window_accelerators[] = {
+ { "close", "<Control>w" }
+};
+
+
+#endif /* FR_WINDOW_ACTION_ENTRIES_H */
diff --git a/src/fr-window.c b/src/fr-window.c
index 926dc38..c8c12a6 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -48,6 +48,7 @@
#include "fr-new-archive-dialog.h"
#include "fr-stock.h"
#include "fr-window.h"
+#include "fr-window-actions-entries.h"
#include "file-data.h"
#include "file-utils.h"
#include "glib-utils.h"
@@ -234,7 +235,7 @@ struct _FrWindowPrivate {
GtkListStore *list_store;
GtkWidget *tree_view;
GtkTreeStore *tree_store;
- GtkWidget *toolbar;
+ GtkWidget *headerbar;
GtkWidget *statusbar;
GtkWidget *progress_bar;
GtkWidget *location_bar;
@@ -701,6 +702,18 @@ static void fr_window_update_dir_tree (FrWindow *window);
static void
+fr_window_enable_action (FrWindow *window,
+ const char *action_name,
+ gboolean enabled)
+{
+ GAction *action;
+
+ action = g_action_map_lookup_action (G_ACTION_MAP (window), action_name);
+ g_object_set (action, "enabled", enabled, NULL);
+}
+
+
+static void
set_sensitive (FrWindow *window,
const char *action_name,
gboolean sensitive)
@@ -1127,13 +1140,20 @@ fr_window_update_sensitivity (FrWindow *window)
set_sensitive (window, "SelectAll", (window->priv->current_view_length > 0) &&
(window->priv->current_view_length != n_selected));
set_sensitive (window, "DeselectAll", n_selected > 0);
- set_sensitive (window, "OpenRecent", ! running);
- set_sensitive (window, "OpenRecent_Toolbar", ! running);
set_sensitive (window, "ViewSidebar", (window->priv->list_mode == FR_WINDOW_LIST_MODE_AS_DIR));
set_sensitive (window, "ViewAllFiles", ! window->priv->filter_mode);
set_sensitive (window, "ViewAsFolder", ! window->priv->filter_mode);
+
+ fr_window_enable_action (window, "add-files", ! no_archive && ! ro && ! running &&
can_store_many_files);
+ fr_window_enable_action (window, "close", ! running || window->priv->stoppable);
+ fr_window_enable_action (window, "edit-password", ! running && (window->priv->asked_for_password ||
(! no_archive && window->archive->propPassword)));
+ fr_window_enable_action (window, "extract-files", file_op);
+ fr_window_enable_action (window, "edit-find", ! no_archive);
+ fr_window_enable_action (window, "save-as", ! no_archive && can_store_many_files && ! running);
+ fr_window_enable_action (window, "test-archive", ! no_archive && ! running &&
window->archive->propTest);
+ fr_window_enable_action (window, "view-properties", file_op);
}
@@ -1810,6 +1830,10 @@ fr_window_update_current_location (FrWindow *window)
set_sensitive (window, "GoForward", window->priv->archive_present && (current_dir != NULL) &&
(window->priv->history_current != NULL) && (window->priv->history_current->prev != NULL));
set_sensitive (window, "GoUp", window->priv->archive_present && (current_dir != NULL) && (strcmp
(current_dir, "/") != 0));
set_sensitive (window, "GoHome", window->priv->archive_present);
+
+ fr_window_enable_action (window, "go-back", window->priv->archive_present && (current_dir != NULL) &&
(window->priv->history_current != NULL) && (window->priv->history_current->next != NULL));
+ fr_window_enable_action (window, "go-forward", window->priv->archive_present && (current_dir != NULL)
&& (window->priv->history_current != NULL) && (window->priv->history_current->prev != NULL));
+
gtk_widget_set_sensitive (window->priv->location_entry, window->priv->archive_present);
gtk_widget_set_sensitive (window->priv->location_label, window->priv->archive_present);
gtk_widget_set_sensitive (window->priv->filter_entry, window->priv->archive_present);
@@ -2050,23 +2074,33 @@ fr_window_update_file_list (FrWindow *window,
static void
-fr_window_update_title (FrWindow *window)
+fr_window_set_title (FrWindow *window,
+ const char *title)
{
- if (! window->priv->archive_present)
- gtk_window_set_title (GTK_WINDOW (window), _("Archive Manager"));
- else {
- char *title;
- char *name;
+ gtk_window_set_title (GTK_WINDOW (window), title);
+ gtk_header_bar_set_title (GTK_HEADER_BAR (window->priv->headerbar), title);
+}
- name = _g_file_get_display_basename (fr_window_get_archive_file (window));
- title = g_strdup_printf ("%s %s",
- name,
- window->archive->read_only ? _("[read only]") : "");
- gtk_window_set_title (GTK_WINDOW (window), title);
- g_free (title);
- g_free (name);
+static void
+fr_window_update_title (FrWindow *window)
+{
+ char *title;
+ char *name;
+
+ if (! window->priv->archive_present) {
+ fr_window_set_title (window, _("Archive Manager"));
+ return;
}
+
+ name = _g_file_get_display_basename (fr_window_get_archive_file (window));
+ title = g_strdup_printf ("%s %s",
+ name,
+ window->archive->read_only ? _("[read only]") : "");
+ fr_window_set_title (window, title);
+
+ g_free (title);
+ g_free (name);
}
@@ -5199,25 +5233,6 @@ fr_window_show_cb (GtkWidget *widget,
static void
-pref_history_len_changed (GSettings *settings,
- const char *key,
- gpointer user_data)
-{
- FrWindow *window = user_data;
- int limit;
- GtkAction *action;
-
- limit = g_settings_get_int (settings, PREF_UI_HISTORY_LEN);
-
- action = gtk_action_group_get_action (window->priv->actions, "OpenRecent");
- gtk_recent_chooser_set_limit (GTK_RECENT_CHOOSER (action), limit);
-
- action = gtk_action_group_get_action (window->priv->actions, "OpenRecent_Toolbar");
- gtk_recent_chooser_set_limit (GTK_RECENT_CHOOSER (action), limit);
-}
-
-
-static void
pref_view_statusbar_changed (GSettings *settings,
const char *key,
gpointer user_data)
@@ -5377,52 +5392,6 @@ view_as_radio_action (GtkAction *action,
static void
-recent_chooser_item_activated_cb (GtkRecentChooser *chooser,
- FrWindow *window)
-{
- char *uri;
- GFile *file;
-
- uri = gtk_recent_chooser_get_current_uri (chooser);
- if (uri == NULL)
- return;
-
- file = g_file_new_for_uri (uri);
- fr_window_archive_open (window, file, GTK_WINDOW (window));
-
- g_object_unref (file);
- g_free (uri);
-}
-
-
-static void
-fr_window_init_recent_chooser (FrWindow *window,
- GtkRecentChooser *chooser)
-{
- GtkRecentFilter *filter;
- int i;
-
- g_return_if_fail (chooser != NULL);
-
- filter = gtk_recent_filter_new ();
- gtk_recent_filter_set_name (filter, _("All archives"));
- for (i = 0; open_type[i] != -1; i++)
- gtk_recent_filter_add_mime_type (filter, mime_type_desc[open_type[i]].mime_type);
- gtk_recent_chooser_add_filter (chooser, filter);
-
- gtk_recent_chooser_set_local_only (chooser, FALSE);
- gtk_recent_chooser_set_limit (chooser, g_settings_get_int (window->priv->settings_ui,
PREF_UI_HISTORY_LEN));
- gtk_recent_chooser_set_show_not_found (chooser, TRUE);
- gtk_recent_chooser_set_sort_type (chooser, GTK_RECENT_SORT_MRU);
-
- g_signal_connect (G_OBJECT (chooser),
- "item_activated",
- G_CALLBACK (recent_chooser_item_activated_cb),
- window);
-}
-
-
-static void
fr_window_activate_filter (FrWindow *window)
{
GtkTreeView *tree_view = GTK_TREE_VIEW (window->priv->list_view);
@@ -5500,22 +5469,11 @@ fr_window_attach (FrWindow *window,
static void
-set_action_important (GtkUIManager *ui,
- const char *action_name)
-{
- GtkAction *action;
-
- action = gtk_ui_manager_get_action (ui, action_name);
- g_object_set (action, "is_important", TRUE, NULL);
- g_object_unref (action);
-}
-
-
-static void
fr_window_construct (FrWindow *window)
{
- GtkWidget *toolbar;
GtkWidget *list_scrolled_window;
+ gboolean rtl;
+ GtkWidget *navigation_commands;
GtkWidget *location_box;
GtkStatusbar *statusbar;
GtkWidget *statusbar_box;
@@ -5523,8 +5481,6 @@ fr_window_construct (FrWindow *window)
GtkWidget *tree_scrolled_window;
GtkTreeSelection *selection;
GtkActionGroup *actions;
- GtkAction *action;
- GtkAction *other_actions_action;
GtkUIManager *ui;
GtkSizeGroup *toolbar_size_group;
GError *error = NULL;
@@ -5825,52 +5781,21 @@ fr_window_construct (FrWindow *window)
fr_window_attach (FR_WINDOW (window), window->priv->paned, FR_WINDOW_AREA_CONTENTS);
gtk_widget_show_all (window->priv->paned);
- /* Build the menu and the toolbar. */
+ /* ui actions */
- ui = gtk_ui_manager_new ();
-
- window->priv->actions = actions = gtk_action_group_new ("Actions");
+ g_action_map_add_action_entries (G_ACTION_MAP (window),
+ fr_window_actions,
+ G_N_ELEMENTS (fr_window_actions),
+ window);
+ /*fr_window_add_accelerators (window,
+ fr_window_accelerators,
+ G_N_ELEMENTS (fr_window_accelerators)); FIXME */
- /* open recent menu item action */
-
- action = g_object_new (GTK_TYPE_RECENT_ACTION,
- "name", "OpenRecent",
- /* Translators: this is the label for the "open recent file" sub-menu. */
- "label", _("Open _Recent"),
- "tooltip", _("Open a recently used archive"),
- "stock-id", GTK_STOCK_OPEN,
- NULL);
- fr_window_init_recent_chooser (window, GTK_RECENT_CHOOSER (action));
- gtk_action_group_add_action (actions, action);
- g_object_unref (action);
-
- /* open recent toolbar item action */
-
- action = g_object_new (GTK_TYPE_RECENT_ACTION,
- "name", "OpenRecent_Toolbar",
- "label", _("Open"),
- "tooltip", _("Open a recently used archive"),
- "stock-id", GTK_STOCK_OPEN,
- "is-important", TRUE,
- NULL);
- fr_window_init_recent_chooser (window, GTK_RECENT_CHOOSER (action));
- g_signal_connect (action,
- "activate",
- G_CALLBACK (activate_action_open),
- window);
- gtk_action_group_add_action (actions, action);
- g_object_unref (action);
+ /* Build the menu. */
- /* menu actions */
+ ui = gtk_ui_manager_new ();
- other_actions_action = action = g_object_new (GTH_TYPE_TOGGLE_MENU_ACTION,
- "name", "OtherActions",
- "label", _("_Other Actions"),
- "tooltip", _("Other actions"),
- "menu-halign", GTK_ALIGN_CENTER,
- "show-arrow", TRUE,
- NULL);
- gtk_action_group_add_action (actions, action);
+ window->priv->actions = actions = gtk_action_group_new ("Actions");
/* other actions */
@@ -5909,68 +5834,99 @@ fr_window_construct (FrWindow *window)
g_error_free (error);
}
- g_object_set (other_actions_action, "menu", gtk_ui_manager_get_widget (ui, "/OtherActionsMenu"),
NULL);
- g_object_unref (other_actions_action);
+ /* header bar */
+
+ window->priv->headerbar = gtk_header_bar_new ();
+ gtk_widget_show (window->priv->headerbar);
+ gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (window->priv->headerbar), TRUE);
+ gtk_window_set_titlebar (GTK_WINDOW (window), window->priv->headerbar);
- window->priv->toolbar = toolbar = gtk_ui_manager_get_widget (ui, "/ToolBar");
- gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), TRUE);
- gtk_style_context_add_class (gtk_widget_get_style_context (toolbar), GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
- set_action_important (ui, "/ToolBar/Extract_Toolbar");
- set_action_important (ui, "/ToolBar/Add_Toolbar");
+ /* header bar buttons */
+
+ gtk_header_bar_pack_start (GTK_HEADER_BAR (window->priv->headerbar),
+ _gtk_header_bar_create_text_button (_("Extract"),
+ NULL,
+ "win.extract-files"));
+ gtk_header_bar_pack_start (GTK_HEADER_BAR (window->priv->headerbar),
+ _gtk_header_bar_create_image_button ("list-add-symbolic",
+ _("Add Files"),
+ "win.add-files"));
+ gtk_header_bar_pack_end (GTK_HEADER_BAR (window->priv->headerbar),
+ _gtk_header_bar_create_image_toggle_button ("edit-find-symbolic",
+ _("Find files by name"),
+ "win.edit-find"));
+
+ /* gears menu button */
+
+ {
+ GtkBuilder *builder;
+ GMenuModel *menu;
+ GtkWidget *button;
+
+ builder = _gtk_builder_new_from_resource ("gears-menu.ui");
+ menu = G_MENU_MODEL (gtk_builder_get_object (builder, "menu"));
+ button = _gtk_menu_button_new_for_header_bar ();
+ gtk_container_add (GTK_CONTAINER (button), gtk_image_new_from_icon_name
("emblem-system-symbolic", GTK_ICON_SIZE_MENU));
+ gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), menu);
+ gtk_widget_show_all (button);
+ gtk_header_bar_pack_end (GTK_HEADER_BAR (window->priv->headerbar), button);
+
+ _gtk_window_add_accelerators_from_menu ((GTK_WINDOW (window)), menu);
+
+ g_object_unref (builder);
+ }
/* location bar */
- window->priv->location_bar = gtk_ui_manager_get_widget (ui, "/LocationBar");
- gtk_toolbar_set_show_arrow (GTK_TOOLBAR (window->priv->location_bar), FALSE);
- gtk_toolbar_set_style (GTK_TOOLBAR (window->priv->location_bar), GTK_TOOLBAR_BOTH_HORIZ);
- gtk_style_context_add_class (gtk_widget_get_style_context (window->priv->location_bar),
GTK_STYLE_CLASS_TOOLBAR);
- set_action_important (ui, "/LocationBar/GoBack");
+ window->priv->location_bar = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ gtk_widget_set_margin_top (window->priv->location_bar, 5);
+ gtk_widget_set_margin_bottom (window->priv->location_bar, 5);
+ gtk_style_context_add_class (gtk_widget_get_style_context (window->priv->location_bar),
GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
+
+ rtl = gtk_widget_get_direction (window->priv->headerbar) == GTK_TEXT_DIR_RTL;
+ navigation_commands = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_box_pack_start (GTK_BOX (navigation_commands),
+ _gtk_header_bar_create_image_button (rtl ? "go-previous-rtl-symbolic" :
"go-previous-symbolic", _("Go to the previous visited location"), "win.go-back"),
+ FALSE,
+ FALSE,
+ 0);
+ gtk_box_pack_start (GTK_BOX (navigation_commands),
+ _gtk_header_bar_create_image_button (rtl ? "go-next-rtl-symbolic" :
"go-next-symbolic", _("Go to the next visited location"), "win.go-forward"),
+ FALSE,
+ FALSE,
+ 0);
+ /*gtk_style_context_add_class (gtk_widget_get_style_context (navigation_commands),
GTK_STYLE_CLASS_LINKED);*/
+ gtk_widget_show_all (navigation_commands);
+ gtk_widget_set_margin_right (navigation_commands, 12);
+ gtk_box_pack_start (GTK_BOX (window->priv->location_bar), navigation_commands, FALSE, FALSE, 5);
/* current location */
- location_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ location_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
/* Translators: after the colon there is a folder name. */
window->priv->location_label = gtk_label_new_with_mnemonic (_("_Location:"));
- gtk_box_pack_start (GTK_BOX (location_box),
- window->priv->location_label, FALSE, FALSE, 5);
+ gtk_box_pack_start (GTK_BOX (location_box), window->priv->location_label, FALSE, FALSE, 5);
window->priv->location_entry = gtk_entry_new ();
- gtk_entry_set_icon_from_stock (GTK_ENTRY (window->priv->location_entry),
- GTK_ENTRY_ICON_PRIMARY,
- GTK_STOCK_DIRECTORY);
-
- gtk_box_pack_start (GTK_BOX (location_box),
- window->priv->location_entry, TRUE, TRUE, 5);
-
+ gtk_entry_set_has_frame (GTK_ENTRY (window->priv->location_entry), FALSE);
+ gtk_entry_set_icon_from_icon_name (GTK_ENTRY (window->priv->location_entry),
+ GTK_ENTRY_ICON_PRIMARY,
+ "folder-symbolic");
g_signal_connect (G_OBJECT (window->priv->location_entry),
"key_press_event",
G_CALLBACK (location_entry_key_press_event_cb),
window);
+ gtk_box_pack_start (GTK_BOX (location_box), window->priv->location_entry, TRUE, TRUE, 5);
+ gtk_box_pack_start (GTK_BOX (window->priv->location_bar), location_box, TRUE, TRUE, 0);
- {
- GtkToolItem *tool_item;
-
- tool_item = gtk_separator_tool_item_new ();
- gtk_widget_show_all (GTK_WIDGET (tool_item));
- gtk_toolbar_insert (GTK_TOOLBAR (window->priv->location_bar), tool_item, -1);
-
- tool_item = gtk_tool_item_new ();
- gtk_tool_item_set_expand (tool_item, TRUE);
- gtk_container_add (GTK_CONTAINER (tool_item), location_box);
- gtk_widget_show_all (GTK_WIDGET (tool_item));
- gtk_toolbar_insert (GTK_TOOLBAR (window->priv->location_bar), tool_item, -1);
- }
-
+ gtk_widget_show_all (window->priv->location_bar);
fr_window_attach (FR_WINDOW (window), window->priv->location_bar, FR_WINDOW_AREA_LOCATIONBAR);
if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT)
gtk_widget_hide (window->priv->location_bar);
else
gtk_widget_show (window->priv->location_bar);
- /**/
-
- fr_window_attach (FR_WINDOW (window), window->priv->toolbar, FR_WINDOW_AREA_TOOLBAR);
- gtk_widget_show (toolbar);
+ /* popup menus */
window->priv->file_popup_menu = gtk_ui_manager_get_widget (ui, "/FilePopupMenu");
window->priv->folder_popup_menu = gtk_ui_manager_get_widget (ui, "/FolderPopupMenu");
@@ -6024,10 +5980,6 @@ fr_window_construct (FrWindow *window)
/* Add notification callbacks. */
g_signal_connect (window->priv->settings_ui,
- "changed::" PREF_UI_HISTORY_LEN,
- G_CALLBACK (pref_history_len_changed),
- window);
- g_signal_connect (window->priv->settings_ui,
"changed::" PREF_UI_VIEW_STATUSBAR,
G_CALLBACK (pref_view_statusbar_changed),
window);
diff --git a/src/glib-utils.h b/src/glib-utils.h
index fef339c..f4e0706 100644
--- a/src/glib-utils.h
+++ b/src/glib-utils.h
@@ -33,6 +33,7 @@
#define DEBUG_INFO __FILE__, __LINE__, __FUNCTION__
#define MIME_TYPE_DIRECTORY "folder"
#define MIME_TYPE_ARCHIVE "application/x-archive"
+#define DEF_ACTION_CALLBACK(x) void x (GSimpleAction *action, GVariant *parameter, gpointer user_data);
#define get_home_relative_path(x) \
g_strconcat (g_get_home_dir (), \
diff --git a/src/gtk-utils.c b/src/gtk-utils.c
index 9e39019..55d44cd 100644
--- a/src/gtk-utils.c
+++ b/src/gtk-utils.c
@@ -655,3 +655,259 @@ _gtk_entry_use_as_password_entry (GtkEntry *entry)
G_CALLBACK (password_entry_icon_press_cb),
NULL);
}
+
+
+static void
+_gtk_menu_button_set_style_for_header_bar (GtkWidget *button)
+{
+ GtkStyleContext *context;
+
+ gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
+ context = gtk_widget_get_style_context (button);
+ gtk_style_context_add_class (context, "image-button");
+ gtk_style_context_remove_class (context, "text-button");
+}
+
+
+GtkWidget *
+_gtk_menu_button_new_for_header_bar (void)
+{
+ GtkWidget *button;
+
+ button = gtk_menu_button_new ();
+ _gtk_menu_button_set_style_for_header_bar (button);
+
+ return button;
+}
+
+
+GtkWidget *
+_gtk_image_button_new_for_header_bar (const char *icon_name)
+{
+ GtkWidget *button;
+
+ button = gtk_button_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
+ _gtk_menu_button_set_style_for_header_bar (button);
+
+ return button;
+}
+
+
+GtkWidget *
+_gtk_header_bar_create_text_button (const char *label,
+ const char *tooltip,
+ const char *action_name)
+{
+ GtkWidget *button;
+
+ g_return_if_fail (label != NULL);
+ g_return_if_fail (action_name != NULL);
+
+ button = gtk_button_new_with_label (label);
+ gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
+ gtk_style_context_add_class (gtk_widget_get_style_context (button), "text-button");
+ gtk_style_context_remove_class (gtk_widget_get_style_context (button), "image-button");
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (button), action_name);
+ if (tooltip != NULL)
+ gtk_widget_set_tooltip_text (button, tooltip);
+ gtk_widget_show (button);
+
+ return button;
+}
+
+
+GtkWidget *
+_gtk_header_bar_create_image_button (const char *icon_name,
+ const char *tooltip,
+ const char *action_name)
+{
+ GtkWidget *button;
+
+ g_return_if_fail (icon_name != NULL);
+ g_return_if_fail (action_name != NULL);
+
+ button = _gtk_image_button_new_for_header_bar (icon_name);
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (button), action_name);
+ if (tooltip != NULL)
+ gtk_widget_set_tooltip_text (button, tooltip);
+ gtk_widget_show (button);
+
+ return button;
+}
+
+
+GtkWidget *
+_gtk_header_bar_create_image_toggle_button (const char *icon_name,
+ const char *tooltip,
+ const char *action_name)
+{
+ GtkWidget *button;
+
+ g_return_if_fail (icon_name != NULL);
+ g_return_if_fail (action_name != NULL);
+
+ button = gtk_toggle_button_new ();
+ gtk_container_add (GTK_CONTAINER (button), gtk_image_new_from_icon_name (icon_name,
GTK_ICON_SIZE_MENU));
+ _gtk_menu_button_set_style_for_header_bar (button);
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (button), action_name);
+ if (tooltip != NULL)
+ gtk_widget_set_tooltip_text (button, tooltip);
+ gtk_widget_show_all (button);
+
+ return button;
+}
+
+
+/* -- _gtk_window_add_accelerator_for_action -- */
+
+
+typedef struct {
+ GtkWindow *window;
+ char *action_name;
+ GVariant *target;
+} AccelData;
+
+
+static void
+accel_data_free (gpointer user_data,
+ GClosure *closure)
+{
+ AccelData *accel_data = user_data;
+
+ g_return_if_fail (accel_data != NULL);
+
+ if (accel_data->target != NULL)
+ g_variant_unref (accel_data->target);
+ g_free (accel_data->action_name);
+ g_free (accel_data);
+}
+
+
+static void
+window_accelerator_activated_cb (GtkAccelGroup *accel_group,
+ GObject *object,
+ guint key,
+ GdkModifierType mod,
+ gpointer user_data)
+{
+ AccelData *accel_data = user_data;
+ GAction *action;
+
+ action = g_action_map_lookup_action (G_ACTION_MAP (accel_data->window), accel_data->action_name);
+ if (action != NULL)
+ g_action_activate (action, accel_data->target);
+}
+
+
+void
+_gtk_window_add_accelerator_for_action (GtkWindow *window,
+ GtkAccelGroup *accel_group,
+ const char *action_name,
+ const char *accel,
+ GVariant *target)
+{
+ AccelData *accel_data;
+ guint key;
+ GdkModifierType mods;
+ GClosure *closure;
+
+ if ((action_name == NULL) || (accel == NULL))
+ return;
+
+ if (g_str_has_prefix (action_name, "app."))
+ return;
+
+ accel_data = g_new0 (AccelData, 1);
+ accel_data->window = window;
+ /* remove the win. prefix from the action name */
+ if (g_str_has_prefix (action_name, "win."))
+ accel_data->action_name = g_strdup (action_name + strlen ("win."));
+ else
+ accel_data->action_name = g_strdup (action_name);
+ if (target != NULL)
+ accel_data->target = g_variant_ref (target);
+
+ gtk_accelerator_parse (accel, &key, &mods);
+ closure = g_cclosure_new (G_CALLBACK (window_accelerator_activated_cb),
+ accel_data,
+ accel_data_free);
+ gtk_accel_group_connect (accel_group,
+ key,
+ mods,
+ 0,
+ closure);
+}
+
+
+/* -- _gtk_window_add_accelerators_from_menu -- */
+
+
+static void
+add_accelerators_from_menu_item (GtkWindow *window,
+ GtkAccelGroup *accel_group,
+ GMenuModel *model,
+ int item)
+{
+ GMenuAttributeIter *iter;
+ const char *key;
+ GVariant *value;
+ const char *accel = NULL;
+ const char *action = NULL;
+ GVariant *target = NULL;
+
+ iter = g_menu_model_iterate_item_attributes (model, item);
+ while (g_menu_attribute_iter_get_next (iter, &key, &value)) {
+ if (g_str_equal (key, "action") && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
+ action = g_variant_get_string (value, NULL);
+ else if (g_str_equal (key, "accel") && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
+ accel = g_variant_get_string (value, NULL);
+ else if (g_str_equal (key, "target"))
+ target = g_variant_ref (value);
+ g_variant_unref (value);
+ }
+ g_object_unref (iter);
+
+ _gtk_window_add_accelerator_for_action (window,
+ accel_group,
+ action,
+ accel,
+ target);
+
+ if (target != NULL)
+ g_variant_unref (target);
+}
+
+
+static void
+add_accelerators_from_menu (GtkWindow *window,
+ GtkAccelGroup *accel_group,
+ GMenuModel *model)
+{
+ int i;
+ GMenuLinkIter *iter;
+ const char *key;
+ GMenuModel *m;
+
+ for (i = 0; i < g_menu_model_get_n_items (model); i++) {
+ add_accelerators_from_menu_item (window, accel_group, model, i);
+
+ iter = g_menu_model_iterate_item_links (model, i);
+ while (g_menu_link_iter_get_next (iter, &key, &m)) {
+ add_accelerators_from_menu (window, accel_group, m);
+ g_object_unref (m);
+ }
+ g_object_unref (iter);
+ }
+}
+
+
+void
+_gtk_window_add_accelerators_from_menu (GtkWindow *window,
+ GMenuModel *menu)
+{
+ GtkAccelGroup *accel_group;
+
+ accel_group = gtk_accel_group_new ();
+ add_accelerators_from_menu (window, accel_group, menu);
+ gtk_window_add_accel_group (window, accel_group);
+}
diff --git a/src/gtk-utils.h b/src/gtk-utils.h
index 87e0077..7da18d8 100644
--- a/src/gtk-utils.h
+++ b/src/gtk-utils.h
@@ -26,6 +26,11 @@
#include <gio/gio.h>
#include <gtk/gtk.h>
+typedef struct {
+ const char *action_name;
+ const char *accelerator;
+} FrAccelerator;
+
int _gtk_tree_selection_count_selected (GtkTreeSelection *selection);
GtkWidget * _gtk_message_dialog_new (GtkWindow *parent,
GtkDialogFlags flags,
@@ -80,5 +85,26 @@ GtkWidget * _gtk_builder_get_widget (GtkBuilder *builder,
int _gtk_widget_lookup_for_size (GtkWidget *widget,
GtkIconSize icon_size);
void _gtk_entry_use_as_password_entry (GtkEntry *entry);
+GtkWidget * _gtk_menu_button_new_for_header_bar (void);
+GtkWidget * _gtk_image_button_new_for_header_bar (const char *icon_name);
+GtkWidget * _gtk_header_bar_create_text_button (const char *icon_name,
+ const char *tooltip,
+ const char *action_name);
+GtkWidget * _gtk_header_bar_create_image_button (const char *icon_name,
+ const char *tooltip,
+ const char *action_name);
+GtkWidget * _gtk_header_bar_create_image_toggle_button
+ (const char *icon_name,
+ const char *tooltip,
+ const char *action_name);
+void _gtk_window_add_accelerator_for_action
+ (GtkWindow *window,
+ GtkAccelGroup *accel_group,
+ const char *action_name,
+ const char *accel,
+ GVariant *target);
+void _gtk_window_add_accelerators_from_menu
+ (GtkWindow *window,
+ GMenuModel *menu);
#endif
diff --git a/src/preferences.h b/src/preferences.h
index 436af79..399bd0a 100644
--- a/src/preferences.h
+++ b/src/preferences.h
@@ -48,7 +48,6 @@
#define PREF_UI_WINDOW_WIDTH "window-width"
#define PREF_UI_WINDOW_HEIGHT "window-height"
#define PREF_UI_SIDEBAR_WIDTH "sidebar-width"
-#define PREF_UI_HISTORY_LEN "history-len"
#define PREF_UI_VIEW_STATUSBAR "view-statusbar"
#define PREF_UI_VIEW_SIDEBAR "view-sidebar"
diff --git a/src/ui.h b/src/ui.h
index 6dc4542..db4fb6c 100644
--- a/src/ui.h
+++ b/src/ui.h
@@ -28,8 +28,6 @@
static GtkActionEntry action_entries[] = {
- { "OtherActionsMenu", NULL, NULL },
-
{ "About", GTK_STOCK_ABOUT,
NULL, NULL,
N_("Information about the program"),
diff --git a/src/ui/Makefile.am b/src/ui/Makefile.am
index 0e00637..a89ba68 100644
--- a/src/ui/Makefile.am
+++ b/src/ui/Makefile.am
@@ -8,6 +8,7 @@ EXTRA_DIST = \
error-dialog.ui \
extract-dialog-options.ui \
file-selector.ui \
+ gears-menu.ui \
menus-toolbars.ui \
message-dialog.ui \
new-archive-dialog.ui \
diff --git a/src/ui/app-menu.ui b/src/ui/app-menu.ui
index 1688110..f95e7f9 100644
--- a/src/ui/app-menu.ui
+++ b/src/ui/app-menu.ui
@@ -5,9 +5,12 @@
<attribute name="action">app.new</attribute>
<attribute name="label" translatable="yes">_New Archive</attribute>
</item>
+ <item>
+ <attribute name="action">app.open</attribute>
+ <attribute name="label" translatable="yes">_Open…</attribute>
+ </item>
</section>
<section>
- <attribute name="label" translatable="yes">List Mode</attribute>
<item>
<attribute name="label" translatable="yes">View All _Files</attribute>
<attribute name="action">app.list-mode</attribute>
diff --git a/src/ui/gears-menu.ui b/src/ui/gears-menu.ui
new file mode 100644
index 0000000..4a38d0b
--- /dev/null
+++ b/src/ui/gears-menu.ui
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <menu id="menu">
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">Save As…</attribute>
+ <attribute name="action">win.save-as</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Pass_word…</attribute>
+ <attribute name="action">win.edit-password</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Test Integrity</attribute>
+ <attribute name="action">win.test-archive</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">Properties</attribute>
+ <attribute name="action">win.view-properties</attribute>
+ <attribute name="accel"><![CDATA[<Alt>Return]]></attribute>
+ </item>
+ </section>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">Close</attribute>
+ <attribute name="action">win.close</attribute>
+ </item>
+ </section>
+ </menu>
+</interface>
diff --git a/src/ui/menus-toolbars.ui b/src/ui/menus-toolbars.ui
index 7e3ddfc..da6b478 100644
--- a/src/ui/menus-toolbars.ui
+++ b/src/ui/menus-toolbars.ui
@@ -35,27 +35,6 @@
<accelerator action="Contents" />
<accelerator action="About" />
- <!-- Toolbars -->
-
- <toolbar name="ToolBar">
- <toolitem action="New"/>
- <toolitem action="OpenRecent_Toolbar"/>
- <separator/>
- <toolitem action="Add_Toolbar"/>
- <toolitem action="Extract_Toolbar"/>
- <separator/>
- <toolitem action="Find"/>
- <separator expand="true"/>
- <toolitem action="OtherActions"/>
- </toolbar>
-
- <toolbar name="LocationBar">
- <toolitem action="GoBack"/>
- <toolitem action="GoForward"/>
- <toolitem action="GoUp"/>
- <toolitem action="GoHome"/>
- </toolbar>
-
<!-- Popup menus -->
<popup name="FilePopupMenu">
@@ -83,10 +62,6 @@
<menuitem action="Delete"/>
</popup>
- <popup name="AddMenu">
- <menuitem action="Add"/>
- </popup>
-
<popup name="SidebarFolderPopupMenu">
<menuitem action="OpenFolderFromSidebar"/>
<separator/>
@@ -98,15 +73,4 @@
<menuitem action="RenameFolderFromSidebar"/>
<menuitem action="DeleteFolderFromSidebar"/>
</popup>
-
- <popup action="OtherActionsMenu">
- <menuitem action="SaveAs"/>
- <menuitem action="Password"/>
- <menuitem action="TestArchive"/>
- <menuitem action="Reload"/>
- <separator/>
- <menuitem action="Properties"/>
- <separator/>
- <menuitem action="Close"/>
- </popup>
</ui>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]