anjuta r3919 - in trunk: . plugins/terminal



Author: sgranjoux
Date: Tue May  6 20:12:49 2008
New Revision: 3919
URL: http://svn.gnome.org/viewvc/anjuta?rev=3919&view=rev

Log:
	* plugins/terminal/anjuta-terminal-plugin.glade,
	plugins/terminal/terminal.c:
	The terminal configuration default option doesn't work (#530031)
	Combobox for terminal choose not working (#530032)


Modified:
   trunk/ChangeLog
   trunk/plugins/terminal/anjuta-terminal-plugin.glade
   trunk/plugins/terminal/terminal.c

Modified: trunk/plugins/terminal/anjuta-terminal-plugin.glade
==============================================================================
--- trunk/plugins/terminal/anjuta-terminal-plugin.glade	(original)
+++ trunk/plugins/terminal/anjuta-terminal-plugin.glade	Tue May  6 20:12:49 2008
@@ -1,148 +1,78 @@
-<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
-<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd";>
-
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--*- mode: xml -*-->
 <glade-interface>
-<requires lib="gnome"/>
-
-<widget class="GtkWindow" id="preferences_dialog_terminal">
-  <property name="title" translatable="yes">window8</property>
-  <property name="type">GTK_WINDOW_TOPLEVEL</property>
-  <property name="window_position">GTK_WIN_POS_NONE</property>
-  <property name="modal">False</property>
-  <property name="resizable">True</property>
-  <property name="destroy_with_parent">False</property>
-
-  <child>
-    <widget class="GtkFrame" id="Terminal">
-      <property name="border_width">5</property>
-      <property name="visible">True</property>
-      <property name="label_xalign">0</property>
-      <property name="label_yalign">0.5</property>
-      <property name="shadow_type">GTK_SHADOW_NONE</property>
-
-      <child>
-	<widget class="GtkTable" id="table24">
-	  <property name="border_width">10</property>
-	  <property name="visible">True</property>
-	  <property name="n_rows">2</property>
-	  <property name="n_columns">2</property>
-	  <property name="homogeneous">False</property>
-	  <property name="row_spacing">5</property>
-	  <property name="column_spacing">5</property>
-
-	  <child>
-	    <widget class="GtkLabel" id="label167">
-	      <property name="visible">True</property>
-	      <property name="label" translatable="yes">Use GNOME terminal profile:</property>
-	      <property name="use_underline">False</property>
-	      <property name="use_markup">False</property>
-	      <property name="justify">GTK_JUSTIFY_LEFT</property>
-	      <property name="wrap">False</property>
-	      <property name="selectable">False</property>
-	      <property name="xalign">0</property>
-	      <property name="yalign">0.5</property>
-	      <property name="xpad">0</property>
-	      <property name="ypad">0</property>
-	    </widget>
-	    <packing>
-	      <property name="left_attach">0</property>
-	      <property name="right_attach">1</property>
-	      <property name="top_attach">0</property>
-	      <property name="bottom_attach">1</property>
-	      <property name="x_options">fill</property>
-	      <property name="y_options"></property>
-	    </packing>
-	  </child>
-
-	  <child>
-	    <widget class="GtkCombo" id="profile_list_combo">
-	      <property name="visible">True</property>
-	      <property name="value_in_list">False</property>
-	      <property name="allow_empty">False</property>
-	      <property name="case_sensitive">True</property>
-	      <property name="enable_arrow_keys">True</property>
-	      <property name="enable_arrows_always">False</property>
-
-	      <child internal-child="entry">
-		<widget class="GtkEntry" id="preferences_entry:text:Default:0:terminal.profile">
-		  <property name="visible">True</property>
-		  <property name="can_focus">True</property>
-		  <property name="editable">False</property>
-		  <property name="visibility">True</property>
-		  <property name="max_length">0</property>
-		  <property name="text" translatable="yes"></property>
-		  <property name="has_frame">True</property>
-		  <property name="activates_default">False</property>
-		</widget>
-	      </child>
-
-	      <child internal-child="list">
-		<widget class="GtkList" id="combo-list25">
-		  <property name="visible">True</property>
-		  <property name="selection_mode">GTK_SELECTION_BROWSE</property>
-
-		  <child>
-		    <widget class="GtkListItem" id="listitem2855">
-		      <property name="visible">True</property>
-		      <property name="can_focus">True</property>
-		      <property name="label" translatable="yes">Default</property>
-		    </widget>
-		  </child>
-		</widget>
-	      </child>
-	    </widget>
-	    <packing>
-	      <property name="left_attach">1</property>
-	      <property name="right_attach">2</property>
-	      <property name="top_attach">0</property>
-	      <property name="bottom_attach">1</property>
-	      <property name="y_options"></property>
-	    </packing>
-	  </child>
-
-	  <child>
-	    <widget class="GtkCheckButton" id="preferences_toggle:bool:1:0:terminal.default.profile">
-	      <property name="visible">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="label" translatable="yes">Use currently selected profile in GNOME terminal</property>
-	      <property name="use_underline">True</property>
-	      <property name="relief">GTK_RELIEF_NORMAL</property>
-	      <property name="active">False</property>
-	      <property name="inconsistent">False</property>
-	      <property name="draw_indicator">True</property>
-	    </widget>
-	    <packing>
-	      <property name="left_attach">0</property>
-	      <property name="right_attach">2</property>
-	      <property name="top_attach">1</property>
-	      <property name="bottom_attach">2</property>
-	      <property name="x_options">fill</property>
-	      <property name="y_options"></property>
-	    </packing>
-	  </child>
-	</widget>
-      </child>
-
-      <child>
-	<widget class="GtkLabel" id="label166">
-	  <property name="visible">True</property>
-	  <property name="label" translatable="yes">&lt;b&gt;Terminal options&lt;/b&gt;</property>
-	  <property name="use_underline">False</property>
-	  <property name="use_markup">True</property>
-	  <property name="justify">GTK_JUSTIFY_LEFT</property>
-	  <property name="wrap">False</property>
-	  <property name="selectable">False</property>
-	  <property name="xalign">0.5</property>
-	  <property name="yalign">0.5</property>
-	  <property name="xpad">0</property>
-	  <property name="ypad">0</property>
-	</widget>
-	<packing>
-	  <property name="type">label_item</property>
-	</packing>
-      </child>
-    </widget>
-  </child>
-</widget>
-
+  <widget class="GtkWindow" id="preferences_dialog_terminal">
+    <property name="title" translatable="yes">window8</property>
+    <child>
+      <widget class="GtkFrame" id="Terminal">
+        <property name="visible">True</property>
+        <property name="border_width">5</property>
+        <property name="label_xalign">0</property>
+        <property name="shadow_type">GTK_SHADOW_NONE</property>
+        <child>
+          <widget class="GtkTable" id="table24">
+            <property name="visible">True</property>
+            <property name="border_width">10</property>
+            <property name="n_rows">2</property>
+            <property name="n_columns">2</property>
+            <property name="column_spacing">5</property>
+            <property name="row_spacing">5</property>
+            <child>
+              <widget class="GtkComboBox" id="profile_list_combo">
+                <property name="visible">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="items" translatable="yes">Default
+
+</property>
+              </widget>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkCheckButton" id="preferences_toggle:bool:1:0:terminal.default.profile">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="label" translatable="yes">Use currently selected profile in GNOME terminal</property>
+                <property name="use_underline">True</property>
+                <property name="response_id">0</property>
+                <property name="draw_indicator">True</property>
+              </widget>
+              <packing>
+                <property name="right_attach">2</property>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="label167">
+                <property name="visible">True</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">Use GNOME terminal profile:</property>
+              </widget>
+              <packing>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+          </widget>
+        </child>
+        <child>
+          <widget class="GtkLabel" id="label166">
+            <property name="visible">True</property>
+            <property name="label" translatable="yes">&lt;b&gt;Terminal options&lt;/b&gt;</property>
+            <property name="use_markup">True</property>
+          </widget>
+          <packing>
+            <property name="type">label_item</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
 </glade-interface>

Modified: trunk/plugins/terminal/terminal.c
==============================================================================
--- trunk/plugins/terminal/terminal.c	(original)
+++ trunk/plugins/terminal/terminal.c	Tue May  6 20:12:49 2008
@@ -134,11 +134,12 @@
 	char *text;
 	int value;
 	gboolean setting;
-	GdkColor color;
+	GdkColor color[2];
+	GdkColor* foreground;
+	GdkColor* background;
 	GtkWidget *vte;
 	gchar *profile;
 	AnjutaPreferences *pref;
-	GSList *profiles;
 	
 	pref = term->prefs;
 	vte = term->term;
@@ -147,43 +148,20 @@
 	g_return_if_fail (client != NULL);
 	
 	/* Update the currently available list of terminal profiles */
-	profiles = gconf_client_get_list (client, GCONF_PROFILE_LIST,
-											  GCONF_VALUE_STRING, NULL);
-	if (profiles)
-	{
-		if (term->pref_profile_combo)
-		{
-			GList *list = NULL;
-			GSList *node = profiles;
-			while (node)
-			{
-				if (node->data)
-					list = g_list_append (list, node->data);
-				node = g_slist_next (node);
-			}
-			gtk_combo_set_popdown_strings (GTK_COMBO (term->pref_profile_combo),
-										   list);
-			g_list_free (list);
-		}
-		g_slist_foreach (profiles, (GFunc)g_free, NULL);
-		g_slist_free (profiles);
-	}
 	setting = anjuta_preferences_get_int (pref,
 										  PREFS_TERMINAL_PROFILE_USE_DEFAULT);
 	if (setting)
 	{
 		/* Use the currently selected profile in gnome-terminal */
 		text = gconf_client_get_string (client, GCONF_DEFAULT_PROFILE, NULL);
-		if (!text)
-			text = g_strdup ("Default");
 	}
 	else
 	{
 		/* Otherwise use the user selected profile */
 		text = anjuta_preferences_get (pref, PREFS_TERMINAL_PROFILE);
-		if (!text)
-			text = g_strdup ("Default");
 	}
+	if (!text || (*text == '\0')) 
+			text = g_strdup ("Default");
 	profile = text;
 	
 	vte_terminal_set_mouse_autohide (VTE_TERMINAL (vte), TRUE);
@@ -197,8 +175,7 @@
 	} else {
 		text = GET_PROFILE_STRING (GCONF_VTE_TERMINAL_FONT);
 	}
-	if (text && GTK_WIDGET (vte)->window)
-		vte_terminal_set_font_from_string (VTE_TERMINAL (vte), text);
+	vte_terminal_set_font_from_string (VTE_TERMINAL (vte), text);
 	g_free (text);
 	
 	setting = GET_PROFILE_BOOL (GCONF_CURSOR_BLINK);
@@ -254,18 +231,21 @@
 	text = GET_PROFILE_STRING (GCONF_BACKGROUND_COLOR);
 	if (text)
 	{
-		gdk_color_parse (text, &color);
-		vte_terminal_set_color_background (VTE_TERMINAL (vte), &color);
+		gdk_color_parse (text, &color[0]);
 		g_free (text);
 	}
+	background = text ? &color[0] : NULL;
 	text = GET_PROFILE_STRING (GCONF_FOREGROUND_COLOR);
 	if (text)
 	{
-		gdk_color_parse (text, &color);
-		vte_terminal_set_color_foreground (VTE_TERMINAL (vte), &color);
-		vte_terminal_set_color_bold (VTE_TERMINAL (vte), &color);
+		gdk_color_parse (text, &color[1]);
 		g_free (text);
 	}
+	foreground = text ? &color[1] : NULL;
+	/* vte_terminal_set_colors works even if the terminal widget is not realized
+	 * which is not the case with vte_terminal_set_color_foreground and
+	 * vte_terminal_set_color_background */
+	vte_terminal_set_colors (VTE_TERMINAL (vte), foreground, background, NULL, 0);
 	g_free (profile);
 	g_object_unref (client);
 }
@@ -364,8 +344,6 @@
 	g_list_foreach (args_list, (GFunc)g_free, NULL);
 	g_list_free (args_list);
 	
-	preferences_changed (term_plugin->prefs, term_plugin);
-	
 	if (term_plugin->widget_added_to_shell)
 		anjuta_shell_present_widget (ANJUTA_PLUGIN (term_plugin)->shell,
 									 term_plugin->frame, NULL);
@@ -646,6 +624,12 @@
 	/* terminal_focus_cb (term_plugin->term, NULL, term_plugin); */
 	term_plugin->widget_added_to_shell = TRUE;
 	initialized = TRUE;
+
+	/* Set all terminal preferences, at that time the terminal widget is
+	 * not realized, a few vte functions are not working. Another
+	 * possibility could be to call this when the widget is realized */
+	preferences_changed (term_plugin->prefs, term_plugin);
+	
 	return TRUE;
 }
 
@@ -758,19 +742,74 @@
 }
 
 static void
+on_add_string_in_store (gpointer data, gpointer user_data)
+{
+	GtkListStore* model = (GtkListStore *)user_data;
+	GtkTreeIter iter;
+	
+	gtk_list_store_append (model, &iter);
+	gtk_list_store_set (model, &iter, 0, (const gchar *)data, -1);
+}
+
+static void
+on_concat_string (gpointer data, gpointer user_data)
+{
+	GString* str = (GString *)user_data;	
+	
+	if (str->len != 0)
+		g_string_append_c (str, ',');
+	g_string_append (str, data);
+}
+
+static void
 ipreferences_merge(IAnjutaPreferences* ipref, AnjutaPreferences* prefs, GError** e)
 {
+	GSList *profiles;
+	GConfClient *client;	
+	GString *default_value;
+	
 	/* Create the terminal preferences page */
 	TerminalPlugin* term_plugin = ANJUTA_PLUGIN_TERMINAL (ipref);
 	GladeXML *gxml = glade_xml_new (PREFS_GLADE, "preferences_dialog_terminal", NULL);
 	anjuta_preferences_add_page (term_plugin->prefs, gxml,
 									"Terminal", _("Terminal"), ICON_FILE);
+	
 	term_plugin->pref_profile_combo = glade_xml_get_widget (gxml, "profile_list_combo");
+
+	/* Update the currently available list of terminal profiles */
+	client = gconf_client_get_default ();
+	profiles = gconf_client_get_list (client, GCONF_PROFILE_LIST,
+									  GCONF_VALUE_STRING, NULL);
+	default_value = g_string_new (NULL);
+	if (profiles)
+	{
+		GtkListStore *store;
+			
+		store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (term_plugin->pref_profile_combo)));
+		
+		gtk_list_store_clear (store);
+		g_slist_foreach (profiles, on_add_string_in_store, store);
+		g_slist_foreach (profiles, on_concat_string, default_value);
+		g_slist_foreach (profiles, (GFunc)g_free, NULL);
+		g_slist_free (profiles);
+		
+	}
+	anjuta_preferences_register_property_raw (term_plugin->prefs,
+											  term_plugin->pref_profile_combo,
+											  PREFS_TERMINAL_PROFILE,
+											  default_value->str,
+											  1,
+											  ANJUTA_PROPERTY_OBJECT_TYPE_COMBO,
+											  ANJUTA_PROPERTY_DATA_TYPE_TEXT);
+	g_string_free (default_value, TRUE);
+		
 	term_plugin->pref_default_button =
 		glade_xml_get_widget (gxml,
 						"preferences_toggle:bool:1:0:terminal.default.profile");
+	use_default_profile_cb (GTK_TOGGLE_BUTTON (term_plugin->pref_default_button), term_plugin);
 	g_signal_connect (G_OBJECT(term_plugin->pref_default_button), "toggled",
 						  G_CALLBACK (use_default_profile_cb), term_plugin);
+	
 	g_object_unref (gxml);
 }
 



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