[gnome-commander/GSettings] Renames list_orientation to horizontal_orientation, changes view menu
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander/GSettings] Renames list_orientation to horizontal_orientation, changes view menu
- Date: Sat, 4 Jun 2016 13:09:48 +0000 (UTC)
commit 1ad54b84d138429dc293f7f40c26f5ff02d82e42
Author: Uwe Scholz <uwescholz src gnome org>
Date: Sat Jun 4 13:33:19 2016 +0200
Renames list_orientation to horizontal_orientation, changes view menu
The variable "Switch to horizontal/vertical orientation" view menu entry
is now a simple check-menu-item entry. This makes it easier to access
the action of changing the orientation via GSettings. For user actions a
new GSettings object of type GcmdUserActionSettings is introduced in
gnome-cmd-user-actions.cc.
pixmaps/Makefile.am | 2 -
pixmaps/toggle_horizontal.xpm | 33 -----------------------
pixmaps/toggle_vertical.xpm | 33 -----------------------
src/gnome-cmd-data.cc | 18 ++++++------
src/gnome-cmd-data.h | 2 +-
src/gnome-cmd-main-menu.cc | 57 +++++------------------------------------
src/gnome-cmd-main-win.cc | 18 ++++++------
src/gnome-cmd-main-win.h | 2 +-
src/gnome-cmd-user-actions.cc | 57 +++++++++++++++++++++++++++++++++++++++++
src/gnome-cmd-user-actions.h | 6 ++++
10 files changed, 90 insertions(+), 138 deletions(-)
---
diff --git a/pixmaps/Makefile.am b/pixmaps/Makefile.am
index e269167..352250b 100644
--- a/pixmaps/Makefile.am
+++ b/pixmaps/Makefile.am
@@ -27,8 +27,6 @@ pixmaps_DATA = \
rotate-180-16.xpm \
rotate-270-16.xpm \
rotate-90-16.xpm \
- toggle_horizontal.xpm \
- toggle_vertical.xpm \
terminal.svg \
unpin.png
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index 28aba06..eb64b44 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -195,14 +195,14 @@ void on_icon_size_changed ()
main_win->update_view();
}
-void on_list_orientation_changed ()
+void on_horizontal_orientation_changed ()
{
- gboolean list_orientation;
+ gboolean horizontal_orientation;
- list_orientation = g_settings_get_boolean (gnome_cmd_data.options.gcmd_settings->general,
GCMD_SETTINGS_HORIZONTAL_ORIENTATION);
- gnome_cmd_data.list_orientation = list_orientation;
+ horizontal_orientation = g_settings_get_boolean (gnome_cmd_data.options.gcmd_settings->general,
GCMD_SETTINGS_HORIZONTAL_ORIENTATION);
+ gnome_cmd_data.horizontal_orientation = horizontal_orientation;
- main_win->update_list_orientation();
+ main_win->update_horizontal_orientation();
}
static void gcmd_settings_class_init (GcmdSettingsClass *klass)
@@ -313,7 +313,7 @@ static void gcmd_connect_gsettings_signals(GcmdSettings *gs)
g_signal_connect (gs->general,
"changed::horizontal-orientation",
- G_CALLBACK (on_list_orientation_changed),
+ G_CALLBACK (on_horizontal_orientation_changed),
NULL);
}
@@ -1603,7 +1603,7 @@ GnomeCmdData::GnomeCmdData(): search_defaults(selections)
XML_cfg_has_connections = FALSE;
XML_cfg_has_bookmarks = FALSE;
- list_orientation = FALSE;
+ horizontal_orientation = FALSE;
toolbar_visibility = TRUE;
show_devbuttons = TRUE;
@@ -1952,7 +1952,7 @@ void GnomeCmdData::load()
options.icon_scale_quality = (GdkInterpType) g_settings_get_enum (options.gcmd_settings->general,
GCMD_SETTINGS_ICON_SCALE_QUALITY);
options.theme_icon_dir = g_settings_get_string(options.gcmd_settings->general,
GCMD_SETTINGS_MIME_ICON_DIR);
cmdline_history_length = g_settings_get_uint (options.gcmd_settings->general,
GCMD_SETTINGS_CMDLINE_HISTORY_LENGTH);
- list_orientation = g_settings_get_boolean (options.gcmd_settings->general,
GCMD_SETTINGS_HORIZONTAL_ORIENTATION);
+ horizontal_orientation = g_settings_get_boolean (options.gcmd_settings->general,
GCMD_SETTINGS_HORIZONTAL_ORIENTATION);
gui_update_rate = gnome_cmd_data_get_int ("/options/gui_update_rate", DEFAULT_GUI_UPDATE_RATE);
priv->main_win_pos[0] = gnome_cmd_data_get_int ("/options/main_win_pos_x", -1);
priv->main_win_pos[1] = gnome_cmd_data_get_int ("/options/main_win_pos_y", -1);
@@ -2482,7 +2482,7 @@ void GnomeCmdData::save()
set_gsettings_enum_when_changed (options.gcmd_settings->general, GCMD_SETTINGS_ICON_SCALE_QUALITY,
options.icon_scale_quality);
set_gsettings_when_changed (options.gcmd_settings->general, GCMD_SETTINGS_MIME_ICON_DIR,
options.theme_icon_dir);
set_gsettings_when_changed (options.gcmd_settings->general, GCMD_SETTINGS_CMDLINE_HISTORY_LENGTH,
&(cmdline_history_length));
- set_gsettings_when_changed (options.gcmd_settings->general, GCMD_SETTINGS_HORIZONTAL_ORIENTATION,
&(list_orientation));
+ set_gsettings_when_changed (options.gcmd_settings->general, GCMD_SETTINGS_HORIZONTAL_ORIENTATION,
&(horizontal_orientation));
gnome_cmd_data_set_int ("/options/gui_update_rate", gui_update_rate);
gnome_cmd_data_set_bool ("/programs/honor_expect_uris", options.honor_expect_uris);
diff --git a/src/gnome-cmd-data.h b/src/gnome-cmd-data.h
index 7c98963..35fcea1 100644
--- a/src/gnome-cmd-data.h
+++ b/src/gnome-cmd-data.h
@@ -497,7 +497,7 @@ struct GnomeCmdData
IntViewerConfig intviewer_defaults;
BookmarksConfig bookmarks_defaults;
- gboolean list_orientation;
+ gboolean horizontal_orientation;
gboolean toolbar_visibility;
gboolean show_devbuttons;
diff --git a/src/gnome-cmd-main-menu.cc b/src/gnome-cmd-main-menu.cc
index 196db39..89ec354 100644
--- a/src/gnome-cmd-main-menu.cc
+++ b/src/gnome-cmd-main-menu.cc
@@ -351,55 +351,6 @@ static void add_bookmark_group (GnomeCmdMainMenu *main_menu, GtkMenuShell *menu,
}
-static void update_view_menu (GnomeCmdMainMenu *main_menu);
-
-
-static void on_switch_orientation (GtkMenuItem *menu_item, GnomeCmdMainMenu *main_menu)
-{
- gnome_cmd_data.list_orientation = !gnome_cmd_data.list_orientation;
-
- main_win->update_list_orientation();
-
- update_view_menu (main_menu);
-}
-
-
-static void update_view_menu (GnomeCmdMainMenu *main_menu)
-{
- gchar *label;
- GtkWidget *item;
- GdkPixmap *pm;
- GdkBitmap *bm;
-
- if (gnome_cmd_data.list_orientation)
- {
- label = g_strdup (_("Switch to Vertical Layout"));
- pm = IMAGE_get_pixmap (PIXMAP_SWITCH_V);
- bm = IMAGE_get_mask (PIXMAP_SWITCH_V);
- }
- else
- {
- label = g_strdup (_("Switch to Horizontal Layout"));
- pm = IMAGE_get_pixmap (PIXMAP_SWITCH_H);
- bm = IMAGE_get_mask (PIXMAP_SWITCH_H);
- }
-
- g_list_foreach (main_menu->priv->view_menuitems, (GFunc) gtk_object_destroy, NULL);
- g_list_free (main_menu->priv->view_menuitems);
- main_menu->priv->view_menuitems = NULL;
-
- item = add_menu_item (main_menu,
- GTK_MENU_SHELL (GTK_MENU_ITEM (main_menu->priv->view_menu)->submenu),
- label, NULL,
- pm, bm,
- GTK_SIGNAL_FUNC (on_switch_orientation), main_menu);
-
- g_free (label);
-
- main_menu->priv->view_menuitems = g_list_append (main_menu->priv->view_menuitems, item);
-}
-
-
/*******************************
* Gtk class implementation
*******************************/
@@ -696,6 +647,12 @@ static void init (GnomeCmdMainMenu *main_menu)
GNOME_APP_PIXMAP_NONE, NULL,
NULL
},
+ {
+ MENU_TYPE_TOGGLEITEM, _("Horizontal Orientation"), "", NULL,
+ (gpointer) view_horizontal_orientation, NULL,
+ GNOME_APP_PIXMAP_NONE, NULL,
+ NULL
+ },
MENUTYPE_END
};
@@ -828,7 +785,6 @@ static void init (GnomeCmdMainMenu *main_menu)
spec.label = _("_View");
main_menu->priv->view_menu = create_menu (main_menu, &spec, view_menu_uiinfo);
gtk_menu_shell_append (GTK_MENU_SHELL (main_menu), main_menu->priv->view_menu);
- update_view_menu (main_menu);
spec.label = _("_Settings");
main_menu->priv->options_menu = create_menu (main_menu, &spec, options_menu_uiinfo);
@@ -860,6 +816,7 @@ static void init (GnomeCmdMainMenu *main_menu)
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (view_menu_uiinfo[12].widget),
gnome_cmd_data.buttonbar_visibility);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (view_menu_uiinfo[14].widget),
!gnome_cmd_data.options.filter.hidden);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (view_menu_uiinfo[15].widget),
!gnome_cmd_data.options.filter.backup);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (view_menu_uiinfo[19].widget),
gnome_cmd_data.horizontal_orientation);
g_signal_connect (gnome_cmd_con_list_get (), "list-changed", G_CALLBACK (on_con_list_list_changed),
main_menu);
diff --git a/src/gnome-cmd-main-win.cc b/src/gnome-cmd-main-win.cc
index 8f1672e..341c237 100644
--- a/src/gnome-cmd-main-win.cc
+++ b/src/gnome-cmd-main-win.cc
@@ -269,7 +269,7 @@ static void create_toolbar (GnomeCmdMainWin *mw, GnomeUIInfo *uiinfo)
static void slide_set_100_0 (GtkMenu *menu, gpointer user_data)
{
gtk_paned_set_position (GTK_PANED (main_win->priv->paned),
- gnome_cmd_data.list_orientation ? GTK_WIDGET (main_win)->allocation.height :
+ gnome_cmd_data.horizontal_orientation ? GTK_WIDGET (main_win)->allocation.height
:
GTK_WIDGET (main_win)->allocation.width);
}
@@ -277,7 +277,7 @@ static void slide_set_100_0 (GtkMenu *menu, gpointer user_data)
static void slide_set_80_20 (GtkMenu *menu, gpointer user_data)
{
gtk_paned_set_position (GTK_PANED (main_win->priv->paned),
- gnome_cmd_data.list_orientation ? (int)(GTK_WIDGET
(main_win)->allocation.height*0.8f) :
+ gnome_cmd_data.horizontal_orientation ? (int)(GTK_WIDGET
(main_win)->allocation.height*0.8f) :
(int)(GTK_WIDGET
(main_win)->allocation.width*0.8f));
}
@@ -285,7 +285,7 @@ static void slide_set_80_20 (GtkMenu *menu, gpointer user_data)
static void slide_set_60_40 (GtkMenu *menu, gpointer user_data)
{
gtk_paned_set_position (GTK_PANED (main_win->priv->paned),
- gnome_cmd_data.list_orientation ? (int)(GTK_WIDGET
(main_win)->allocation.height*0.6f) :
+ gnome_cmd_data.horizontal_orientation ? (int)(GTK_WIDGET
(main_win)->allocation.height*0.6f) :
(int)(GTK_WIDGET
(main_win)->allocation.width*0.6f));
}
@@ -293,7 +293,7 @@ static void slide_set_60_40 (GtkMenu *menu, gpointer user_data)
static void slide_set_50_50 (GtkMenu *menu, gpointer user_data)
{
gtk_paned_set_position (GTK_PANED (main_win->priv->paned),
- gnome_cmd_data.list_orientation ? (int)(GTK_WIDGET
(main_win)->allocation.height*0.5f) :
+ gnome_cmd_data.horizontal_orientation ? (int)(GTK_WIDGET
(main_win)->allocation.height*0.5f) :
(int)(GTK_WIDGET
(main_win)->allocation.width*0.5f));
}
@@ -301,7 +301,7 @@ static void slide_set_50_50 (GtkMenu *menu, gpointer user_data)
static void slide_set_40_60 (GtkMenu *menu, gpointer user_data)
{
gtk_paned_set_position (GTK_PANED (main_win->priv->paned),
- gnome_cmd_data.list_orientation ? (int)(GTK_WIDGET
(main_win)->allocation.height*0.4f) :
+ gnome_cmd_data.horizontal_orientation ? (int)(GTK_WIDGET
(main_win)->allocation.height*0.4f) :
(int)(GTK_WIDGET
(main_win)->allocation.width*0.4f));
}
@@ -309,7 +309,7 @@ static void slide_set_40_60 (GtkMenu *menu, gpointer user_data)
static void slide_set_20_80 (GtkMenu *menu, gpointer user_data)
{
gtk_paned_set_position (GTK_PANED (main_win->priv->paned),
- gnome_cmd_data.list_orientation ? (int)(GTK_WIDGET
(main_win)->allocation.height*0.2f) :
+ gnome_cmd_data.horizontal_orientation ? (int)(GTK_WIDGET
(main_win)->allocation.height*0.2f) :
(int)(GTK_WIDGET
(main_win)->allocation.width*0.2f));
}
@@ -777,7 +777,7 @@ static void init (GnomeCmdMainWin *mw)
gnome_app_set_contents (GNOME_APP (mw), mw->priv->vbox);
- mw->priv->paned = gnome_cmd_data.list_orientation ? gtk_vpaned_new () : gtk_hpaned_new ();
+ mw->priv->paned = gnome_cmd_data.horizontal_orientation ? gtk_vpaned_new () : gtk_hpaned_new ();
g_object_ref (mw->priv->paned);
g_object_set_data_full (*mw, "paned", mw->priv->paned, g_object_unref);
@@ -1262,7 +1262,7 @@ void GnomeCmdMainWin::update_cmdline_visibility()
}
-void GnomeCmdMainWin::update_list_orientation()
+void GnomeCmdMainWin::update_horizontal_orientation()
{
gint pos = 2;
@@ -1273,7 +1273,7 @@ void GnomeCmdMainWin::update_list_orientation()
gtk_object_destroy (GTK_OBJECT (priv->paned));
- priv->paned = gnome_cmd_data.list_orientation ? gtk_vpaned_new () : gtk_hpaned_new ();
+ priv->paned = gnome_cmd_data.horizontal_orientation ? gtk_vpaned_new () : gtk_hpaned_new ();
g_object_ref (priv->paned);
g_object_set_data_full (*this, "paned", priv->paned, g_object_unref);
diff --git a/src/gnome-cmd-main-win.h b/src/gnome-cmd-main-win.h
index 8521fb7..88fe54a 100644
--- a/src/gnome-cmd-main-win.h
+++ b/src/gnome-cmd-main-win.h
@@ -95,7 +95,7 @@ struct GnomeCmdMainWin
void update_toolbar_visibility();
void update_cmdline_visibility();
void update_buttonbar_visibility();
- void update_list_orientation();
+ void update_horizontal_orientation();
void add_plugin_menu(PluginData *data);
diff --git a/src/gnome-cmd-user-actions.cc b/src/gnome-cmd-user-actions.cc
index 125ec0e..1785a59 100644
--- a/src/gnome-cmd-user-actions.cc
+++ b/src/gnome-cmd-user-actions.cc
@@ -57,6 +57,53 @@
using namespace std;
+/***********************************
+ * Functions for using GSettings
+ ***********************************/
+
+struct _GcmdUserActionSettings
+{
+ GObject parent;
+ GSettings *general;
+};
+
+G_DEFINE_TYPE (GcmdUserActionSettings, gcmd_user_action_settings, G_TYPE_OBJECT)
+
+static void gcmd_user_action_settings_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (gcmd_user_action_settings_parent_class)->finalize (object);
+}
+
+static void gcmd_user_action_settings_dispose (GObject *object)
+{
+ GcmdUserActionSettings *gs = GCMD_USER_ACTIONS (object);
+
+ g_clear_object (&gs->general);
+
+ G_OBJECT_CLASS (gcmd_user_action_settings_parent_class)->dispose (object);
+}
+
+static void gcmd_user_action_settings_class_init (GcmdUserActionSettingsClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gcmd_user_action_settings_finalize;
+ object_class->dispose = gcmd_user_action_settings_dispose;
+}
+
+GcmdUserActionSettings *gcmd_user_action_settings_new ()
+{
+ return (GcmdUserActionSettings *) g_object_new (USER_ACTION_SETTINGS, NULL);
+}
+
+static void gcmd_user_action_settings_init (GcmdUserActionSettings *gs)
+{
+ gs->general = g_settings_new (GCMD_PREF_GENERAL);
+}
+
+/***********************************
+ * UserActions
+ ***********************************/
inline GnomeCmdFileSelector *get_fs (const FileSelectorID fsID)
{
@@ -247,6 +294,7 @@ void GnomeCmdUserActions::init()
register_action(GDK_F7, "file.mkdir");
register_action(GDK_F8, "file.delete");
// register_action(GDK_F9, "edit.search"); // do not register F9 here, as edit.search action
wouldn't be checked for registration later
+ settings = gcmd_user_action_settings_new();
}
@@ -1561,6 +1609,15 @@ void view_backup_files (GtkMenuItem *menuitem, gpointer not_used)
}
+void view_horizontal_orientation (GtkMenuItem *menuitem, gpointer not_used)
+{
+ if (!GTK_WIDGET_REALIZED (main_win)) return;
+ GtkCheckMenuItem *checkitem = (GtkCheckMenuItem *) menuitem;
+ gnome_cmd_data.horizontal_orientation = checkitem->active;
+ g_settings_set_boolean (gcmd_user_actions.settings->general, GCMD_SETTINGS_HORIZONTAL_ORIENTATION,
gnome_cmd_data.horizontal_orientation);
+ main_win->update_horizontal_orientation();
+}
+
void view_up (GtkMenuItem *menuitem, gpointer not_used)
{
GnomeCmdFileSelector *fs = get_fs (ACTIVE);
diff --git a/src/gnome-cmd-user-actions.h b/src/gnome-cmd-user-actions.h
index 4ff5383..2aa25f0 100644
--- a/src/gnome-cmd-user-actions.h
+++ b/src/gnome-cmd-user-actions.h
@@ -36,6 +36,10 @@
#define GNOME_CMD_USER_ACTION(f) void f(GtkMenuItem *menuitem=NULL, gpointer user_data=NULL)
+#define USER_ACTION_SETTINGS (gcmd_user_action_settings_get_type ())
+G_DECLARE_FINAL_TYPE (GcmdUserActionSettings, gcmd_user_action_settings, GCMD, USER_ACTIONS, GObject)
+GcmdUserActionSettings *gcmd_user_action_settings_new (void);
+
typedef void (*GnomeCmdUserActionFunc) (GtkMenuItem *menuitem, gpointer user_data);
@@ -165,6 +169,7 @@ class GnomeCmdUserActions
void init();
void set_defaults();
void shutdown();
+ GcmdUserActionSettings *settings;
void load(const gchar *section);
@@ -311,6 +316,7 @@ 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);
+GNOME_CMD_USER_ACTION(view_horizontal_orientation);
/************** Bookmarks Menu **************/
GNOME_CMD_USER_ACTION(bookmarks_add_current);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]