From 9a0b804edc91fbf65c331ffbb9581ced4b52ffcb Mon Sep 17 00:00:00 2001 From: Daniel Wilkins Date: Sat, 15 Feb 2014 22:56:12 -0500 Subject: [PATCH 1/1] basic support for forcing directory --- terminal/terminal-preferences-dialog.c | 25 ++++-- terminal/terminal-preferences.c | 22 +++++ terminal/terminal-preferences.glade | 145 +++++++++++++++++++++------------ terminal/terminal-window.c | 12 ++- 4 files changed, 145 insertions(+), 59 deletions(-) diff --git a/terminal/terminal-preferences-dialog.c b/terminal/terminal-preferences-dialog.c index 9be0826..9b99125 100644 --- a/terminal/terminal-preferences-dialog.c +++ b/terminal/terminal-preferences-dialog.c @@ -64,8 +64,9 @@ static void terminal_preferences_dialog_background_set (GtkFileChooserButton TerminalPreferencesDialog *dialog); static void terminal_preferences_dialog_encoding_changed (GtkComboBox *combobox, TerminalPreferencesDialog *dialog); - - +static void terminal_preferences_dialog_specify_notify (GObject *object, + GParamSpec *pspec, + GObject *widget); struct _TerminalPreferencesDialogClass { @@ -146,7 +147,7 @@ terminal_preferences_dialog_init (TerminalPreferencesDialog *dialog) "color-background-vary", "dropdown-keep-open-default", "dropdown-keep-above", "dropdown-toggle-focus", "dropdown-status-icon", "dropdown-move-to-active", - "dropdown-always-show-tabs" + "dropdown-always-show-tabs", "specify-directory" }; const gchar *props_color[] = { "color-foreground", "color-cursor", "color-background", "tab-activity-color", @@ -228,6 +229,7 @@ error: BIND_PROPERTIES ("scrolling-lines", "value"); BIND_PROPERTIES ("tab-activity-timeout", "value"); BIND_PROPERTIES ("background-darkness", "value"); + BIND_PROPERTIES ("specified-directory", "text"); /* reset comparibility button */ object = gtk_builder_get_object (GTK_BUILDER (dialog), "reset-compatibility"); @@ -329,6 +331,12 @@ error: G_CALLBACK (terminal_preferences_dialog_encoding_changed), dialog); g_object_unref (G_OBJECT (model)); g_free (current); + + /* tie specified-directory to specify-directory */ + object = gtk_builder_get_object (GTK_BUILDER (dialog), "specify-directory"); + object2 = gtk_builder_get_object (GTK_BUILDER (dialog), "specified-directory"); + g_signal_connect(G_OBJECT(object), "notify::active", G_CALLBACK (terminal_preferences_dialog_specify_notify), object2); + } @@ -845,7 +853,14 @@ terminal_preferences_dialog_background_notify (GObject *object, g_free (prop_file); } - +static void terminal_preferences_dialog_specify_notify (GObject *object, + GParamSpec *pspec, + GObject *widget) +{ + gboolean specifydir; + g_object_get (object, "active", &specifydir, NULL); + gtk_editable_set_editable (GTK_EDITABLE (widget), specifydir); +} static void terminal_preferences_dialog_background_set (GtkFileChooserButton *widget, @@ -894,8 +909,6 @@ terminal_preferences_dialog_encoding_changed (GtkComboBox *combobo } } - - /** * terminal_preferences_dialog_new: * diff --git a/terminal/terminal-preferences.c b/terminal/terminal-preferences.c index dcb223b..4369503 100644 --- a/terminal/terminal-preferences.c +++ b/terminal/terminal-preferences.c @@ -103,6 +103,8 @@ enum PROP_WORD_CHARS, PROP_TAB_ACTIVITY_COLOR, PROP_TAB_ACTIVITY_TIMEOUT, + PROP_SPECIFY_DIRECTORY, + PROP_SPECIFIED_DIRECTORY, N_PROPERTIES, }; @@ -910,6 +912,26 @@ terminal_preferences_class_init (TerminalPreferencesClass *klass) "-A-Za-z0-9,./?%&#:_=+@~", G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + /** + * TerminalPreferences:specify-directory: + **/ + preferences_props[PROP_SPECIFY_DIRECTORY] = + g_param_spec_boolean ("specify-directory", + NULL, + "SpecifyDirectory", + FALSE, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + + /** + * TerminalPreferences:specified-directory: + */ + preferences_props[PROP_SPECIFIED_DIRECTORY] = + g_param_spec_string ("specified-directory", + NULL, + "SpecifiedDirectory", + g_getenv("HOME"), + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + /* install all properties */ g_object_class_install_properties (gobject_class, N_PROPERTIES, preferences_props); } diff --git a/terminal/terminal-preferences.glade b/terminal/terminal-preferences.glade index a4a9284..c04a20f 100644 --- a/terminal/terminal-preferences.glade +++ b/terminal/terminal-preferences.glade @@ -175,11 +175,6 @@ 1 10 - - 30 - 1 - 10 - False Terminal Preferences @@ -198,7 +193,6 @@ gtk-help - False True True True @@ -214,7 +208,6 @@ gtk-close - False True True True @@ -369,7 +362,6 @@ _Run command as login shell - False True True False @@ -386,7 +378,6 @@ _Update utmp/wtmp records when command is launched - False True True False @@ -441,7 +432,6 @@ Scroll single _line using Shift-Up/-Down keys - False True True False @@ -464,7 +454,6 @@ Scroll on ou_tput - False True True False @@ -481,7 +470,6 @@ Scroll on _keystroke - False True True False @@ -644,7 +632,6 @@ _Keep window open when it loses focus - False True True False @@ -660,7 +647,6 @@ Always keep window on _top - False True True False @@ -676,7 +662,6 @@ Use shortcut to _focus visible window - False True True False @@ -693,7 +678,6 @@ Show _status icon in notification area - False True True False @@ -932,7 +916,6 @@ _Always show tabs - False True True False @@ -1043,7 +1026,6 @@ Move to monitor with poi_nter - False True True False @@ -1120,7 +1102,6 @@ 6 - False True True True @@ -1137,7 +1118,6 @@ Allow bold te_xt - False True True False @@ -1365,7 +1345,6 @@ Display _menubar in new windows - False True True False @@ -1382,7 +1361,6 @@ Display _toolbar in new windows - False True True False @@ -1399,7 +1377,6 @@ Display _borders around new windows - False True True False @@ -1736,7 +1713,6 @@ _Vary the background color for each tab - False True True False @@ -1758,7 +1734,6 @@ 0 - False True True True @@ -1788,7 +1763,6 @@ 0 - False True True True @@ -1816,7 +1790,6 @@ 0 - False True True True @@ -1844,7 +1817,6 @@ 0 - False True True True @@ -1911,7 +1883,6 @@ Text _selection color: - False True True False @@ -1931,7 +1902,6 @@ 0 - False True True True @@ -1954,7 +1924,6 @@ B_old text color: - False True True False @@ -1976,7 +1945,6 @@ 0 - False True True True @@ -2035,7 +2003,6 @@ True - False True True True @@ -2051,7 +2018,6 @@ - False True True True @@ -2071,7 +2037,6 @@ - False True True True @@ -2093,7 +2058,6 @@ - False True True True @@ -2113,7 +2077,6 @@ - False True True True @@ -2135,7 +2098,6 @@ - False True True True @@ -2157,7 +2119,6 @@ - False True True True @@ -2177,7 +2138,6 @@ - False True True True @@ -2197,7 +2157,6 @@ - False True True True @@ -2217,7 +2176,6 @@ - False True True True @@ -2239,7 +2197,6 @@ - False True True True @@ -2261,7 +2218,6 @@ - False True True True @@ -2281,7 +2237,6 @@ - False True True True @@ -2301,7 +2256,6 @@ - False True True True @@ -2323,7 +2277,6 @@ - False True True True @@ -2345,7 +2298,6 @@ - False True True True @@ -2528,7 +2480,6 @@ _Reset compatibility options to defaults - False True True True @@ -2718,7 +2669,6 @@ when double clicking: Rese_t double click options to defaults - False True True True @@ -2844,7 +2794,6 @@ when double clicking: Disable all me_nu access keys (such as Alt+f) - False True True False @@ -2860,7 +2809,6 @@ when double clicking: Disable m_enu shortcut keys (F10 by default) - False True True False @@ -2895,6 +2843,94 @@ when double clicking: 2 + + + True + False + 0 + none + + + True + False + 12 + + + True + False + 6 + + + Force working directory + True + True + False + True + + + True + True + 0 + + + + + True + False + + + True + False + Directory: + + + True + False + 0 + + + + + True + True + + False + False + True + True + + + True + False + 1 + + + + + True + True + 1 + + + + + + + + + True + False + <b>Working Directory</b> + True + + + + + True + False + 3 + + 5 @@ -2932,4 +2968,9 @@ when double clicking: + + 30 + 1 + 10 + diff --git a/terminal/terminal-window.c b/terminal/terminal-window.c index 8dd564d..8c185fd 100644 --- a/terminal/terminal-window.c +++ b/terminal/terminal-window.c @@ -1233,11 +1233,16 @@ terminal_window_action_new_tab (GtkAction *action, { const gchar *directory; GtkWidget *terminal; - + gboolean specifydir; terminal = g_object_new (TERMINAL_TYPE_SCREEN, NULL); + g_object_get (G_OBJECT (window->preferences), "specify-directory", &specifydir, NULL); + if (G_LIKELY (window->active != NULL)) { + if (specifydir) + g_object_get (G_OBJECT (window->preferences), "specified-directory", &directory, NULL); + else directory = terminal_screen_get_working_directory (window->active); terminal_screen_set_working_directory (TERMINAL_SCREEN (terminal), directory); @@ -1254,9 +1259,14 @@ terminal_window_action_new_window (GtkAction *action, TerminalWindow *window) { const gchar *directory; + gboolean specifydir; + g_object_get (G_OBJECT (window->preferences), "specify-directory", &specifydir, NULL); if (G_LIKELY (window->active != NULL)) { + if (specifydir) + g_object_get (G_OBJECT (window->preferences), "specified-directory", &directory, NULL); + else directory = terminal_screen_get_working_directory (window->active); g_signal_emit (G_OBJECT (window), window_signals[NEW_WINDOW], 0, directory); } -- 1.8.4