gtkhtml r8907 - trunk/gtkhtml



Author: mcrha
Date: Thu Jul 31 08:35:54 2008
New Revision: 8907
URL: http://svn.gnome.org/viewvc/gtkhtml?rev=8907&view=rev

Log:
2008-07-31  Milan Crha  <mcrha redhat com>

	** Fix for bug #545559

	* htmlengine.c: (html_engine_finalize):
	* htmlengine-edit-cursor.h: (html_engine_set_cursor_blink_timeout):
	* htmlengine-edit-cursor.c: (html_engine_set_cursor_blink_timeout),
	(html_engine_setup_blinking_cursor),
	(html_engine_stop_blinking_cursor),
	(html_engine_reset_blinking_cursor):
	* gtkhtml.c: (client_notify_cursor_blink), (gtk_html_class_init):
	Respect Gnome settings regarding cursor blinking.



Modified:
   trunk/gtkhtml/ChangeLog
   trunk/gtkhtml/gtkhtml.c
   trunk/gtkhtml/htmlengine-edit-cursor.c
   trunk/gtkhtml/htmlengine-edit-cursor.h
   trunk/gtkhtml/htmlengine.c

Modified: trunk/gtkhtml/gtkhtml.c
==============================================================================
--- trunk/gtkhtml/gtkhtml.c	(original)
+++ trunk/gtkhtml/gtkhtml.c	Thu Jul 31 08:35:54 2008
@@ -2629,6 +2629,15 @@
 }
 
 static void
+client_notify_cursor_blink (GConfClient* client, guint cnxn_id, GConfEntry* entry, gpointer data)
+{
+	if (gconf_client_get_bool (client, "/desktop/gnome/interface/cursor_blink", NULL))
+		html_engine_set_cursor_blink_timeout (gconf_client_get_int (client, "/desktop/gnome/interface/cursor_blink_time", NULL) / 2);
+	else
+		html_engine_set_cursor_blink_timeout (0);
+}
+
+static void
 gtk_html_direction_changed (GtkWidget *widget, GtkTextDirection previous_dir)
 {
 	GtkHTML *html = GTK_HTML (widget);
@@ -2667,6 +2676,7 @@
 	GtkLayoutClass    *layout_class;
 	GtkContainerClass *container_class;
 	gchar *filename;
+	GConfClient *client;
 
 	html_class = (GtkHTMLClass *) klass;
 #ifdef USE_PROPS
@@ -3023,8 +3033,17 @@
 	g_free (filename);
 	html_class->emacs_bindings = gtk_binding_set_find ("gtkhtml-bindings-emacs");
 	read_key_theme (html_class);
-	gconf_client_notify_add (gconf_client_get_default (), "/desktop/gnome/interface/gtk_key_theme",
+
+	client = gconf_client_get_default ();
+
+	gconf_client_notify_add (client, "/desktop/gnome/interface/gtk_key_theme",
 				 client_notify_key_theme, html_class, NULL, &gconf_error);
+
+	gconf_client_notify_add (client, "/desktop/gnome/interface/cursor_blink", client_notify_cursor_blink, NULL, NULL, NULL);
+	gconf_client_notify_add (client, "/desktop/gnome/interface/cursor_blink_time", client_notify_cursor_blink, NULL, NULL, NULL);
+	client_notify_cursor_blink (client, 0, NULL, NULL);
+
+	g_object_unref (client);
 }
 
 static void

Modified: trunk/gtkhtml/htmlengine-edit-cursor.c
==============================================================================
--- trunk/gtkhtml/htmlengine-edit-cursor.c	(original)
+++ trunk/gtkhtml/htmlengine-edit-cursor.c	Thu Jul 31 08:35:54 2008
@@ -33,8 +33,6 @@
 #include "htmltable.h"
 #include "htmlembedded.h"
 
-#define BLINK_TIMEOUT 500
-
 static GdkColor table_stipple_active_on      = { 0, 0,      0,      0xffff };
 static GdkColor table_stipple_active_off     = { 0, 0xffff, 0xffff, 0xffff };
 static GdkColor table_stipple_non_active_on  = { 0, 0xaaaa, 0xaaaa, 0xaaaa };
@@ -48,6 +46,14 @@
 static GdkColor image_stipple_active_on      = { 0, 0xffff, 0,      0 };
 static GdkColor image_stipple_active_off     = { 0, 0xffff, 0xffff, 0xffff };
 
+static gint blink_timeout = 500;
+
+void
+html_engine_set_cursor_blink_timeout (gint timeout)
+{
+	blink_timeout = timeout;
+}
+
 void
 html_engine_hide_cursor  (HTMLEngine *engine)
 {
@@ -372,7 +378,10 @@
 	engine->blinking_status = FALSE;
 
 	blink_timeout_cb (engine);
-	engine->blinking_timer_id = g_timeout_add (BLINK_TIMEOUT, blink_timeout_cb, engine);
+	if (blink_timeout > 0)
+		engine->blinking_timer_id = g_timeout_add (blink_timeout, blink_timeout_cb, engine);
+	else
+		engine->blinking_timer_id = -1;
 }
 
 void
@@ -387,7 +396,8 @@
 		engine->blinking_status = FALSE;
 	}
 
-	g_source_remove (engine->blinking_timer_id);
+	if (engine->blinking_timer_id != -1)
+		g_source_remove (engine->blinking_timer_id);
 	engine->blinking_timer_id = 0;
 }
 
@@ -403,6 +413,16 @@
 
 	html_engine_show_cursor (engine);
 	engine->blinking_status = TRUE;
-	g_source_remove (engine->blinking_timer_id);
-	engine->blinking_timer_id = g_timeout_add (BLINK_TIMEOUT, blink_timeout_cb, engine);
+
+	if (engine->blinking_timer_id != -1)
+		g_source_remove (engine->blinking_timer_id);
+
+	if (blink_timeout > 0)
+		engine->blinking_timer_id = g_timeout_add (blink_timeout, blink_timeout_cb, engine);
+	else {
+		engine->blinking_timer_id = -1;
+		/* show the cursor */
+		engine->blinking_status = FALSE;
+		blink_timeout_cb (engine);
+	}
 }

Modified: trunk/gtkhtml/htmlengine-edit-cursor.h
==============================================================================
--- trunk/gtkhtml/htmlengine-edit-cursor.h	(original)
+++ trunk/gtkhtml/htmlengine-edit-cursor.h	Thu Jul 31 08:35:54 2008
@@ -24,6 +24,8 @@
 
 #include "htmltypes.h"
 
+void html_engine_set_cursor_blink_timeout (gint timeout);
+
 void  html_engine_hide_cursor            (HTMLEngine *engine);
 void  html_engine_show_cursor            (HTMLEngine *engine);
 void  html_engine_draw_cell_cursor       (HTMLEngine *engine);

Modified: trunk/gtkhtml/htmlengine.c
==============================================================================
--- trunk/gtkhtml/htmlengine.c	(original)
+++ trunk/gtkhtml/htmlengine.c	Thu Jul 31 08:35:54 2008
@@ -3811,7 +3811,8 @@
 		engine->thaw_idle_id = 0;
 	}
 	if (engine->blinking_timer_id != 0) {
-		g_source_remove (engine->blinking_timer_id);
+		if (engine->blinking_timer_id != -1)
+			g_source_remove (engine->blinking_timer_id);
 		engine->blinking_timer_id = 0;
 	}
 	if (engine->redraw_idle_id != 0) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]