summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/profile-editor.c77
-rw-r--r--src/profile-preferences.ui56
-rw-r--r--src/terminal-app.c2
-rw-r--r--src/terminal-profile.c4
-rw-r--r--src/terminal-profile.h1
-rw-r--r--src/terminal-screen.c66
-rw-r--r--src/terminal-screen.h1
-rw-r--r--src/terminal-window.c45
-rw-r--r--src/terminal-window.h7
9 files changed, 206 insertions, 53 deletions
diff --git a/src/profile-editor.c b/src/profile-editor.c
index 520a61b..ac08156 100644
--- a/src/profile-editor.c
+++ b/src/profile-editor.c
@@ -585,6 +585,77 @@ editor_response_cb (GtkWidget *editor,
}
static void
+icon_browse_button_clicked_cb (GtkWidget *button,
+ GtkWidget *entry)
+{
+ GtkWidget *dialog;
+ GtkFileFilter *filter;
+
+ dialog = gtk_file_chooser_dialog_new (_("Choose A Profile Icon"),
+ GTK_WINDOW (gtk_widget_get_toplevel (button)),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ _("_Cancel"), GTK_RESPONSE_CANCEL,
+ _("_Open"), GTK_RESPONSE_ACCEPT,
+ NULL);
+
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_add_pixbuf_formats (filter);
+ gtk_file_filter_set_name (filter, _("Images"));
+ gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter);
+
+ gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (dialog), TRUE);
+
+ /* Add standard icon folders as shortcots.
+ * This resolves to something like /usr/share/icons in the file chooser sidebar. */
+ gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (dialog),
+ TERM_DATADIR "/icons", NULL);
+ gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (dialog),
+ TERM_DATADIR "/pixmaps", NULL);
+
+ /* Pre-select the current icon file, resolving theme names via the icon theme */
+ const char *current = gtk_entry_get_text (GTK_ENTRY (entry));
+ if (current && current[0] != '\0')
+ {
+ if (g_path_is_absolute (current))
+ {
+ gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dialog), current);
+ }
+ else
+ {
+ GtkIconTheme *icon_theme;
+ GtkIconInfo *info;
+
+ icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (button));
+ info = gtk_icon_theme_lookup_icon (icon_theme, current, 48, 0);
+ if (info)
+ {
+ gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dialog),
+ gtk_icon_info_get_filename (info));
+ g_object_unref (info);
+ }
+ }
+ }
+ else
+ {
+ /* Use /usr/share/icons as the initial folder */
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog),
+ TERM_DATADIR "/icons");
+ }
+
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
+ {
+ char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+ if (filename)
+ {
+ gtk_entry_set_text (GTK_ENTRY (entry), filename);
+ g_free (filename);
+ }
+ }
+
+ gtk_widget_destroy (dialog);
+}
+
+static void
setup_background_filechooser (GtkWidget *filechooser,
TerminalProfile *profile)
{
@@ -842,6 +913,11 @@ terminal_profile_edit (TerminalProfile *profile,
g_signal_connect (w, "changed",
G_CALLBACK (visible_name_entry_changed_cb), editor);
+ w = GTK_WIDGET (gtk_builder_get_object (builder, "profile-icon-browse-button"));
+ g_signal_connect (w, "clicked",
+ G_CALLBACK (icon_browse_button_clicked_cb),
+ gtk_builder_get_object (builder, "profile-icon-entry"));
+
g_signal_connect (gtk_builder_get_object (builder, "reset-compat-defaults-button"),
"clicked",
G_CALLBACK (reset_compat_defaults_cb),
@@ -868,6 +944,7 @@ terminal_profile_edit (TerminalProfile *profile,
CONNECT ("foreground-colorpicker", TERMINAL_PROFILE_FOREGROUND_COLOR);
CONNECT ("image-radiobutton", TERMINAL_PROFILE_BACKGROUND_TYPE);
CONNECT ("login-shell-checkbutton", TERMINAL_PROFILE_LOGIN_SHELL);
+ CONNECT ("profile-icon-entry", TERMINAL_PROFILE_ICON);
CONNECT ("profile-name-entry", TERMINAL_PROFILE_VISIBLE_NAME);
CONNECT ("scrollback-lines-spinbutton", TERMINAL_PROFILE_SCROLLBACK_LINES);
CONNECT ("scrollback-unlimited-checkbutton", TERMINAL_PROFILE_SCROLLBACK_UNLIMITED);
diff --git a/src/profile-preferences.ui b/src/profile-preferences.ui
index e64b9f9..281a78a 100644
--- a/src/profile-preferences.ui
+++ b/src/profile-preferences.ui
@@ -352,6 +352,60 @@ Author: Wolfgang Ulbrich
</packing>
</child>
<child>
+ <object class="GtkBox" id="hbox-profile-icon">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="profile-icon-label">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="halign">start</property>
+ <property name="valign">center</property>
+ <property name="label" translatable="yes">Profile _icon:</property>
+ <property name="use-underline">True</property>
+ <property name="justify">center</property>
+ <property name="mnemonic-widget">profile-icon-entry</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="profile-icon-entry">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="placeholder-text" translatable="yes">Icon name or file path</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="profile-icon-browse-button">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="label" translatable="yes">_Browse…</property>
+ <property name="use-underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkCheckButton" id="system-font-checkbutton">
<property name="label" translatable="yes">_Use the system fixed width font</property>
<property name="visible">True</property>
@@ -364,7 +418,7 @@ Author: Wolfgang Ulbrich
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
diff --git a/src/terminal-app.c b/src/terminal-app.c
index 831f42f..ca99eb2 100644
--- a/src/terminal-app.c
+++ b/src/terminal-app.c
@@ -1798,7 +1798,7 @@ terminal_app_handle_options (TerminalApp *app,
gtk_window_set_role (GTK_WINDOW (window), iw->role);
if (iw->icon)
- terminal_window_set_icon (window, iw->icon);
+ terminal_window_set_icon_from_cli (window, iw->icon);
if (iw->force_menubar_state)
terminal_window_set_menubar_visible (window, iw->menubar_state);
diff --git a/src/terminal-profile.c b/src/terminal-profile.c
index 69bf5ac..634e0bc 100644
--- a/src/terminal-profile.c
+++ b/src/terminal-profile.c
@@ -65,6 +65,7 @@ enum
PROP_EXIT_ACTION,
PROP_FONT,
PROP_FOREGROUND_COLOR,
+ PROP_ICON,
PROP_LOGIN_SHELL,
PROP_NAME,
PROP_PALETTE,
@@ -107,6 +108,7 @@ enum
#define KEY_EXIT_ACTION "exit-action"
#define KEY_FONT "font"
#define KEY_FOREGROUND_COLOR "foreground-color"
+#define KEY_ICON "icon"
#define KEY_LOGIN_SHELL "login-shell"
#define KEY_PALETTE "palette"
#define KEY_SCROLL_BACKGROUND "scroll-background"
@@ -146,6 +148,7 @@ enum
#define DEFAULT_EXIT_ACTION (TERMINAL_EXIT_CLOSE)
#define DEFAULT_FONT ("Monospace 12")
#define DEFAULT_FOREGROUND_COLOR ("#000000")
+#define DEFAULT_ICON ("")
#define DEFAULT_LOGIN_SHELL (FALSE)
#define DEFAULT_NAME (NULL)
#define DEFAULT_PALETTE (terminal_palettes[TERMINAL_PALETTE_TANGO])
@@ -1342,6 +1345,7 @@ terminal_profile_class_init (TerminalProfileClass *klass)
TERMINAL_PROFILE_PROPERTY_STRING (BACKGROUND_IMAGE_FILE, DEFAULT_BACKGROUND_IMAGE_FILE, KEY_BACKGROUND_IMAGE_FILE);
TERMINAL_PROFILE_PROPERTY_STRING (CUSTOM_COMMAND, DEFAULT_CUSTOM_COMMAND, KEY_CUSTOM_COMMAND);
+ TERMINAL_PROFILE_PROPERTY_STRING (ICON, DEFAULT_ICON, KEY_ICON);
TERMINAL_PROFILE_PROPERTY_STRING (TITLE, _(DEFAULT_TITLE), KEY_TITLE);
TERMINAL_PROFILE_PROPERTY_STRING (VISIBLE_NAME, _(DEFAULT_VISIBLE_NAME), KEY_VISIBLE_NAME);
TERMINAL_PROFILE_PROPERTY_STRING (WORD_CHARS, DEFAULT_WORD_CHARS, KEY_WORD_CHARS);
diff --git a/src/terminal-profile.h b/src/terminal-profile.h
index ff9b0a7..be45f5b 100644
--- a/src/terminal-profile.h
+++ b/src/terminal-profile.h
@@ -86,6 +86,7 @@ typedef enum
#define TERMINAL_PROFILE_EXIT_ACTION "exit-action"
#define TERMINAL_PROFILE_FONT "font"
#define TERMINAL_PROFILE_FOREGROUND_COLOR "foreground-color"
+#define TERMINAL_PROFILE_ICON "icon"
#define TERMINAL_PROFILE_LOGIN_SHELL "login-shell"
#define TERMINAL_PROFILE_NAME "name"
#define TERMINAL_PROFILE_PALETTE "palette"
diff --git a/src/terminal-screen.c b/src/terminal-screen.c
index dd713d9..66a26a4 100644
--- a/src/terminal-screen.c
+++ b/src/terminal-screen.c
@@ -959,6 +959,9 @@ terminal_screen_profile_notify_cb (TerminalProfile *profile,
* update terminal window config
* with the flag of copy selection to clipboard or not. */
terminal_window_update_copy_selection(screen, window);
+
+ if (!prop_name || prop_name == I_(TERMINAL_PROFILE_ICON))
+ terminal_window_update_icon (window);
}
if (!prop_name || prop_name == I_(TERMINAL_PROFILE_SCROLLBAR_POSITION))
@@ -1188,6 +1191,9 @@ update_color_scheme (TerminalScreen *screen)
vte_terminal_set_color_bold (VTE_TERMINAL (screen),
bold_rgba);
+ /* Clear any OSC 10/11 color overrides so profile colors take effect */
+ vte_terminal_feed (VTE_TERMINAL (screen), "\033]110\a\033]111\a", -1);
+
update_toplevel_transparency (screen);
}
@@ -1881,61 +1887,39 @@ terminal_screen_get_dynamic_icon_title (TerminalScreen *screen)
* terminal_screen_get_current_dir:
* @screen:
*
- * Tries to determine the current working directory of the foreground process
- * in @screen's PTY, falling back to the current working directory of the
- * primary child.
+ * Tries to determine the current working directory of the terminal.
+ * First tries OSC 7 (current directory URI set by the shell), then
+ * falls back to reading /proc for the child process's cwd, and
+ * finally to the initial working directory.
*
* Returns: a newly allocated string containing the current working directory,
* or %NULL on failure
*/
-char*
+char *
terminal_screen_get_current_dir (TerminalScreen *screen)
{
- TerminalScreenPrivate *priv = screen->priv;
- char *cwd;
- VtePty *pty;
+ const char *uri;
- pty = vte_terminal_get_pty (VTE_TERMINAL (screen));
- if (pty != NULL)
+ /* Prefer OSC 7 current directory URI if the shell has set it */
+ uri = vte_terminal_get_current_directory_uri (VTE_TERMINAL (screen));
+ if (uri != NULL)
+ return g_filename_from_uri (uri, NULL, NULL);
+
+ /* Fallback to /proc-based detection */
+ if (vte_terminal_get_pty (VTE_TERMINAL (screen)) != NULL)
{
-#if 0
- /* Get the foreground process ID */
- cwd = cwd_of_pid (tcgetpgrp (priv->pty_fd));
- if (cwd != NULL)
- return cwd;
-#endif
+ char *cwd;
- /* If that didn't work, try falling back to the primary child. See bug #575184. */
- cwd = cwd_of_pid (priv->child_pid);
+ cwd = cwd_of_pid (screen->priv->child_pid);
if (cwd != NULL)
return cwd;
}
- return NULL;
-}
+ /* Further fallback to initial working directory */
+ if (screen->priv->initial_working_directory)
+ return g_strdup (screen->priv->initial_working_directory);
-/**
- * terminal_screen_get_current_dir_with_fallback:
- * @screen:
- *
- * Like terminal_screen_get_current_dir(), but falls back to returning
- * @screen's initial working directory, with a further fallback to the
- * user's home directory.
- *
- * Returns: a newly allocated string containing the current working directory,
- * or %NULL on failure
- */
-char*
-terminal_screen_get_current_dir_with_fallback (TerminalScreen *screen)
-{
- VtePty *pty;
- TerminalScreenPrivate *priv = screen->priv;
-
- pty = vte_terminal_get_pty (VTE_TERMINAL (screen));
- if (pty == NULL)
- return g_strdup (priv->initial_working_directory);
-
- return terminal_screen_get_current_dir (screen);
+ return NULL;
}
void
diff --git a/src/terminal-screen.h b/src/terminal-screen.h
index ba1c218..7c68d82 100644
--- a/src/terminal-screen.h
+++ b/src/terminal-screen.h
@@ -110,7 +110,6 @@ const char *terminal_screen_get_dynamic_title (TerminalScreen *screen);
const char *terminal_screen_get_dynamic_icon_title (TerminalScreen *screen);
char *terminal_screen_get_current_dir (TerminalScreen *screen);
-char *terminal_screen_get_current_dir_with_fallback (TerminalScreen *screen);
void terminal_screen_set_font (TerminalScreen *screen);
void terminal_screen_set_font_scale (TerminalScreen *screen,
diff --git a/src/terminal-window.c b/src/terminal-window.c
index 75e5fd8..da806b4 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -2584,6 +2584,7 @@ profile_set_callback (TerminalScreen *screen,
return;
terminal_window_update_set_profile_menu_active_profile (window);
+ terminal_window_update_icon (window);
}
static void
@@ -2844,11 +2845,6 @@ void
terminal_window_set_icon (TerminalWindow *window,
const char *icon)
{
- TerminalWindowPrivate *priv = window->priv;
-
- g_free (priv->icon);
- priv->icon = g_strdup (icon);
-
if (icon == NULL || icon[0] == '\0')
return;
@@ -2868,6 +2864,40 @@ terminal_window_set_icon (TerminalWindow *window,
}
}
+void
+terminal_window_set_icon_from_cli (TerminalWindow *window,
+ const char *icon)
+{
+ TerminalWindowPrivate *priv = window->priv;
+
+ g_free (priv->icon);
+ priv->icon = g_strdup (icon);
+
+ terminal_window_set_icon (window, icon);
+}
+
+void
+terminal_window_update_icon (TerminalWindow *window)
+{
+ TerminalWindowPrivate *priv = window->priv;
+ TerminalProfile *profile;
+ const char *icon;
+
+ /* The --icon flag takes precedence over the profile icon */
+ if (priv->icon != NULL && priv->icon[0] != '\0')
+ return;
+
+ if (priv->active_screen == NULL ||
+ !(profile = terminal_screen_get_profile (priv->active_screen)))
+ return;
+
+ icon = terminal_profile_get_property_string (profile, TERMINAL_PROFILE_ICON);
+ if (icon != NULL && icon[0] != '\0')
+ terminal_window_set_icon (window, icon);
+ else
+ gtk_window_set_icon_name (GTK_WINDOW (window), MATE_TERMINAL_ICON_NAME);
+}
+
GtkWidget *
terminal_window_get_notebook (TerminalWindow *window)
{
@@ -3254,6 +3284,7 @@ notebook_page_selected_callback (GtkWidget *notebook,
sync_screen_icon_title_set (screen, NULL, window);
sync_screen_icon_title (screen, NULL, window);
sync_screen_title (screen, NULL, window);
+ terminal_window_update_icon (window);
/* set size of window to current grid size */
_terminal_debug_print (TERMINAL_DEBUG_GEOMETRY,
@@ -3657,7 +3688,7 @@ file_new_window_callback (GtkAction *action,
new_window = terminal_app_new_window (app, gtk_widget_get_screen (GTK_WIDGET (window)));
- new_working_directory = terminal_screen_get_current_dir_with_fallback (priv->active_screen);
+ new_working_directory = terminal_screen_get_current_dir (priv->active_screen);
terminal_app_new_terminal (app, new_window, profile,
NULL, NULL,
new_working_directory,
@@ -3689,7 +3720,7 @@ file_new_tab_callback (GtkAction *action,
if (_terminal_profile_get_forgotten (profile))
return;
- new_working_directory = terminal_screen_get_current_dir_with_fallback (priv->active_screen);
+ new_working_directory = terminal_screen_get_current_dir (priv->active_screen);
terminal_app_new_terminal (app, window, profile,
NULL, NULL,
new_working_directory,
diff --git a/src/terminal-window.h b/src/terminal-window.h
index 86b8e28..4ffe2b9 100644
--- a/src/terminal-window.h
+++ b/src/terminal-window.h
@@ -78,8 +78,11 @@ void terminal_window_set_menubar_visible (TerminalWindow *window,
gboolean setting);
gboolean terminal_window_get_menubar_visible (TerminalWindow *window);
-void terminal_window_set_icon (TerminalWindow *window,
- const char *icon);
+void terminal_window_set_icon (TerminalWindow *window,
+ const char *icon);
+void terminal_window_set_icon_from_cli (TerminalWindow *window,
+ const char *icon);
+void terminal_window_update_icon (TerminalWindow *window);
void terminal_window_switch_screen (TerminalWindow *window,
TerminalScreen *screen);