SF.net SVN: geany:[3339] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Sun Dec 7 19:11:36 UTC 2008


Revision: 3339
          http://geany.svn.sourceforge.net/geany/?rev=3339&view=rev
Author:   eht16
Date:     2008-12-07 19:11:36 +0000 (Sun, 07 Dec 2008)

Log Message:
-----------
Some cleanup in vte.c.
Add a setting for the VTE to enable/disable a blinking cursor.
This is useful for future VTE versions where the cursor blinks by default which might be not be desirable.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/keyfile.c
    trunk/src/prefs.c
    trunk/src/vte.c
    trunk/src/vte.h

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-12-07 19:11:13 UTC (rev 3338)
+++ trunk/ChangeLog	2008-12-07 19:11:36 UTC (rev 3339)
@@ -2,6 +2,10 @@
 
  * src/callbacks.c:
    Fix pressing escape in the sidebar and toolbar focus the editor.
+ * src/keyfile.c, src/prefs.c, src/vte.c, src/vte.h:
+   Add a setting for the VTE to enable/disable a blinking cursor.
+   This is useful for future VTE versions where the cursor blinks
+   by default which might be not be desirable.
 
 
 2008-12-06  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>

Modified: trunk/src/keyfile.c
===================================================================
--- trunk/src/keyfile.c	2008-12-07 19:11:13 UTC (rev 3338)
+++ trunk/src/keyfile.c	2008-12-07 19:11:36 UTC (rev 3339)
@@ -397,6 +397,7 @@
 		g_key_file_set_boolean(config, "VTE", "follow_path", vc->follow_path);
 		g_key_file_set_boolean(config, "VTE", "run_in_vte", vc->run_in_vte);
 		g_key_file_set_boolean(config, "VTE", "skip_run_script", vc->skip_run_script);
+		g_key_file_set_boolean(config, "VTE", "cursor_blinks", vc->cursor_blinks);
 		g_key_file_set_integer(config, "VTE", "scrollback_lines", vc->scrollback_lines);
 		g_key_file_set_string(config, "VTE", "font", vc->font);
 		g_key_file_set_string(config, "VTE", "shell", vc->shell);
@@ -683,6 +684,7 @@
 		vc->follow_path = utils_get_setting_boolean(config, "VTE", "follow_path", FALSE);
 		vc->run_in_vte = utils_get_setting_boolean(config, "VTE", "run_in_vte", FALSE);
 		vc->skip_run_script = utils_get_setting_boolean(config, "VTE", "skip_run_script", FALSE);
+		vc->cursor_blinks = utils_get_setting_boolean(config, "VTE", "cursor_blinks", FALSE);
 		vc->scrollback_lines = utils_get_setting_integer(config, "VTE", "scrollback_lines", 500);
 		vc->colour_fore = g_new0(GdkColor, 1);
 		vc->colour_back = g_new0(GdkColor, 1);

Modified: trunk/src/prefs.c
===================================================================
--- trunk/src/prefs.c	2008-12-07 19:11:13 UTC (rev 3338)
+++ trunk/src/prefs.c	2008-12-07 19:11:36 UTC (rev 3339)
@@ -724,6 +724,9 @@
 
 		widget = lookup_widget(ui_widgets.prefs_dialog, "check_skip_script");
 		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), vc->skip_run_script);
+
+		widget = lookup_widget(ui_widgets.prefs_dialog, "check_cursor_blinks");
+		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), vc->cursor_blinks);
 	}
 #endif
 }
@@ -1089,6 +1092,9 @@
 			widget = lookup_widget(ui_widgets.prefs_dialog, "check_skip_script");
 			vc->skip_run_script = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
 
+			widget = lookup_widget(ui_widgets.prefs_dialog, "check_cursor_blinks");
+			vc->cursor_blinks = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+
 			vte_apply_user_settings();
 		}
 #endif

Modified: trunk/src/vte.c
===================================================================
--- trunk/src/vte.c	2008-12-07 19:11:13 UTC (rev 3338)
+++ trunk/src/vte.c	2008-12-07 19:11:36 UTC (rev 3339)
@@ -61,27 +61,24 @@
 static const gchar VTE_WORDCHARS[] = "-A-Za-z0-9,./?%&#:_";
 
 
-/* taken from original vte.h to make my life easier ;-) */
-
-typedef struct _VteTerminalPrivate VteTerminalPrivate;
-
+/* Incomplete VteTerminal struct from vte/vte.h. */
 typedef struct _VteTerminal VteTerminal;
 struct _VteTerminal
 {
 	GtkWidget widget;
 	GtkAdjustment *adjustment;
-	glong char_width, char_height;
-	glong char_ascent, char_descent;
-	glong row_count, column_count;
-	gchar *window_title;
-	gchar *icon_title;
-	VteTerminalPrivate *pvt;
 };
 
 #define VTE_TERMINAL(obj) (GTK_CHECK_CAST((obj), VTE_TYPE_TERMINAL, VteTerminal))
 #define VTE_TYPE_TERMINAL (vf->vte_terminal_get_type())
 
+typedef enum {
+        VTE_CURSOR_BLINK_SYSTEM,
+        VTE_CURSOR_BLINK_ON,
+        VTE_CURSOR_BLINK_OFF
+} VteTerminalCursorBlinkMode;
 
+
 /* store function pointers in a struct to avoid a strange segfault if they are stored directly
  * if accessed directly, gdb says the segfault arrives at old_tab_width(prefs.c), don't ask me */
 struct VteFunctions
@@ -107,6 +104,9 @@
 	void (*vte_terminal_set_color_background) (VteTerminal *terminal, const GdkColor *background);
 	void (*vte_terminal_feed_child) (VteTerminal *terminal, const char *data, glong length);
 	void (*vte_terminal_im_append_menuitems) (VteTerminal *terminal, GtkMenuShell *menushell);
+	void (*vte_terminal_set_cursor_blink_mode) (VteTerminal *terminal,
+												VteTerminalCursorBlinkMode mode);
+	void (*vte_terminal_set_cursor_blinks) (VteTerminal *terminal, gboolean blink);
 };
 
 
@@ -415,6 +415,18 @@
 }
 
 
+static void vte_set_cursor_blink_mode(void)
+{
+	if (vf->vte_terminal_set_cursor_blink_mode != NULL)
+		/* vte >= 0.17.1 */
+		vf->vte_terminal_set_cursor_blink_mode(VTE_TERMINAL(vc->vte),
+			(vc->cursor_blinks) ? VTE_CURSOR_BLINK_ON : VTE_CURSOR_BLINK_OFF);
+	else
+		/* vte < 0.17.1 */
+		vf->vte_terminal_set_cursor_blinks(VTE_TERMINAL(vc->vte), vc->cursor_blinks);
+}
+
+
 static void vte_register_symbols(GModule *mod)
 {
 	g_module_symbol(mod, "vte_terminal_new", (void*)&vf->vte_terminal_new);
@@ -436,6 +448,11 @@
 	g_module_symbol(mod, "vte_terminal_set_color_background", (void*)&vf->vte_terminal_set_color_background);
 	g_module_symbol(mod, "vte_terminal_feed_child", (void*)&vf->vte_terminal_feed_child);
 	g_module_symbol(mod, "vte_terminal_im_append_menuitems", (void*)&vf->vte_terminal_im_append_menuitems);
+	g_module_symbol(mod, "vte_terminal_set_cursor_blink_mode", (void*)&vf->vte_terminal_set_cursor_blink_mode);
+	if (vf->vte_terminal_set_cursor_blink_mode == NULL)
+		/* vte_terminal_set_cursor_blink_mode() is only available since 0.17.1, so if we don't find
+		 * this symbol, we are probably on an older version and use the old API instead */
+		g_module_symbol(mod, "vte_terminal_set_cursor_blinks", (void*)&vf->vte_terminal_set_cursor_blinks);
 }
 
 
@@ -451,6 +468,7 @@
 	vf->vte_terminal_set_font_from_string(VTE_TERMINAL(vc->vte), vc->font);
 	vf->vte_terminal_set_color_foreground(VTE_TERMINAL(vc->vte), vc->colour_fore);
 	vf->vte_terminal_set_color_background(VTE_TERMINAL(vc->vte), vc->colour_back);
+	vte_set_cursor_blink_mode();
 
 	override_menu_key();
 }
@@ -678,7 +696,7 @@
 		GtkWidget *notebook, *vbox, *label, *alignment, *table, *frame, *box;
 		GtkWidget *font_term, *color_fore, *color_back, *spin_scrollback;
 		GtkWidget *check_scroll_key, *check_scroll_out, *check_follow_path;
-		GtkWidget *check_enable_bash_keys, *check_ignore_menu_key;
+		GtkWidget *check_enable_bash_keys, *check_ignore_menu_key, *check_cursor_blinks;
 		GtkWidget *check_run_in_vte, *check_skip_script, *entry_shell, *button_shell, *image_shell;
 		GtkObject *spin_scrollback_adj;
 
@@ -788,6 +806,10 @@
 		ui_widget_set_tooltip_text(check_scroll_out, _("Whether to scroll to the bottom when output is generated."));
 		gtk_container_add(GTK_CONTAINER(box), check_scroll_out);
 
+		check_cursor_blinks = gtk_check_button_new_with_mnemonic(_("Cursor blinks"));
+		ui_widget_set_tooltip_text(check_cursor_blinks, _("Whether to blink the cursor"));
+		gtk_container_add(GTK_CONTAINER(box), check_cursor_blinks);
+
 		check_enable_bash_keys = gtk_check_button_new_with_mnemonic(_("Override Geany keybindings"));
 		ui_widget_set_tooltip_text(check_enable_bash_keys,
 			_("Allows the VTE to receive keyboard shortcuts (apart from focus commands)."));
@@ -832,6 +854,8 @@
 				g_object_ref(check_scroll_key),	(GDestroyNotify) g_object_unref);
 		g_object_set_data_full(G_OBJECT(ui_widgets.prefs_dialog), "check_scroll_out",
 				g_object_ref(check_scroll_out),	(GDestroyNotify) g_object_unref);
+		g_object_set_data_full(G_OBJECT(ui_widgets.prefs_dialog), "check_cursor_blinks",
+				g_object_ref(check_cursor_blinks),	(GDestroyNotify) g_object_unref);
 		g_object_set_data_full(G_OBJECT(ui_widgets.prefs_dialog), "check_enable_bash_keys",
 				g_object_ref(check_enable_bash_keys),	(GDestroyNotify) g_object_unref);
 		g_object_set_data_full(G_OBJECT(ui_widgets.prefs_dialog), "check_ignore_menu_key",

Modified: trunk/src/vte.h
===================================================================
--- trunk/src/vte.h	2008-12-07 19:11:13 UTC (rev 3338)
+++ trunk/src/vte.h	2008-12-07 19:11:36 UTC (rev 3339)
@@ -57,6 +57,7 @@
 	gboolean run_in_vte;
 	gboolean skip_run_script;
 	gboolean enable_bash_keys;
+	gboolean cursor_blinks;
 	gint scrollback_lines;
 	gchar *emulation;
 	gchar *shell;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list