Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Jiří Techet techet@gmail.com Date: Wed, 29 Apr 2015 20:23:35 UTC Commit: 9f0bfec04526b07882ab644830bef4c9c8ddebba https://github.com/geany/geany/commit/9f0bfec04526b07882ab644830bef4c9c8ddeb...
Log Message: ----------- Add "dirty" terminal indication
Right now users are confused when various VTE actions don't work because there's no indication that the terminal is in the non-clean state.
Visualise "modified" terminal in the same way as modified document - by a red label in the tab so it's clearer when terminal isn't clean.
Avoid quick red flashes when pressing enter by delaying the color change a bit.
Modified Paths: -------------- data/geany.css data/geany.gtkrc src/vte.c
Modified: data/geany.css 5 lines changed, 5 insertions(+), 0 deletions(-) =================================================================== @@ -37,3 +37,8 @@ #geany-document-status-readonly { color: #007f00; } + +/* red "Terminal" label when terminal dirty */ +#geany-terminal-dirty { + color: #ff0000; +}
Modified: data/geany.gtkrc 3 lines changed, 3 insertions(+), 0 deletions(-) =================================================================== @@ -39,3 +39,6 @@ style "geany-document-status-readonly-style" { widget "*.geany-document-status-changed" style "geany-document-status-changed-style" widget "*.geany-document-status-disk-changed" style "geany-document-status-disk-changed-style" widget "*.geany-document-status-readonly" style "geany-document-status-readonly-style" + +# red "Terminal" label when terminal dirty +widget "*.geany-terminal-dirty" style "geany-document-status-changed-style"
Modified: src/vte.c 44 lines changed, 38 insertions(+), 6 deletions(-) =================================================================== @@ -63,6 +63,8 @@ static gboolean clean = TRUE; static GModule *module = NULL; static struct VteFunctions *vf; static gchar *gtk_menu_key_accel = NULL; +static GtkWidget *terminal_label = NULL; +static guint terminal_label_update_source = 0;
/* use vte wordchars to select paths */ static const gchar VTE_WORDCHARS[] = "-A-Za-z0-9,./?%&#:_"; @@ -295,7 +297,8 @@ static void create_vte(void) vte_start(vte);
gtk_widget_show_all(hbox); - gtk_notebook_insert_page(GTK_NOTEBOOK(msgwindow.notebook), hbox, gtk_label_new(_("Terminal")), MSG_VTE); + terminal_label = gtk_label_new(_("Terminal")); + gtk_notebook_insert_page(GTK_NOTEBOOK(msgwindow.notebook), hbox, terminal_label, MSG_VTE);
g_signal_connect_after(vte, "realize", G_CALLBACK(on_vte_realize), NULL); } @@ -323,13 +326,42 @@ void vte_close(void) }
+static gboolean set_dirty_idle(gpointer user_data) +{ + gtk_widget_set_name(terminal_label, "geany-terminal-dirty"); + terminal_label_update_source = 0; + return FALSE; +} + + +static void set_clean(gboolean value) +{ + if (clean != value) + { + if (terminal_label) + { + if (terminal_label_update_source > 0) + { + g_source_remove(terminal_label_update_source); + terminal_label_update_source = 0; + } + if (value) + gtk_widget_set_name(terminal_label, NULL); + else + terminal_label_update_source = g_timeout_add(150, set_dirty_idle, NULL); + } + clean = value; + } +} + + static gboolean vte_keyrelease_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) { if (ui_is_keyval_enter_or_return(event->keyval) || ((event->keyval == GDK_c) && (event->state & GDK_CONTROL_MASK))) { /* assume any text on the prompt has been executed when pressing Enter/Return */ - clean = TRUE; + set_clean(TRUE); } return FALSE; } @@ -359,7 +391,7 @@ static gboolean vte_keypress_cb(GtkWidget *widget, GdkEventKey *event, gpointer
static void vte_commit_cb(VteTerminal *vte, gchar *arg1, guint arg2, gpointer user_data) { - clean = FALSE; + set_clean(FALSE); }
@@ -382,7 +414,7 @@ static void vte_start(GtkWidget *widget) else pid = 0; /* use 0 as invalid pid */
- clean = TRUE; + set_clean(TRUE); }
@@ -395,7 +427,7 @@ static void vte_restart(GtkWidget *widget) pid = 0; } vf->vte_terminal_reset(VTE_TERMINAL(widget), TRUE, TRUE); - clean = TRUE; + set_clean(TRUE); }
@@ -628,7 +660,7 @@ gboolean vte_send_cmd(const gchar *cmd) if (clean) { vf->vte_terminal_feed_child(VTE_TERMINAL(vc->vte), cmd, strlen(cmd)); - clean = TRUE; /* vte_terminal_feed_child() also marks the vte as not clean */ + set_clean(TRUE); /* vte_terminal_feed_child() also marks the vte as not clean */ return TRUE; } else
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).