gtranslator r3668 - in trunk/src: . dialogs



Author: icq
Date: Mon Sep 22 09:41:57 2008
New Revision: 3668
URL: http://svn.gnome.org/viewvc/gtranslator?rev=3668&view=rev

Log:
2008-08-07  Ignacio Casal Quinteiro  <nacho resa gmail com>

	* dialogs/preferences-dialog.c (scheme_color_changed_cb),
	(setup_interface_pages), (gtranslator_preferences_dialog_init):
	* dialogs/preferences-dialog.glade:
	* prefs-manager-app.c (gtranslator_prefs_manager_app_init),
	(gtranslator_prefs_manager_scheme_color_changed):
	* prefs-manager.c:
	* prefs-manager.h:
	* view.c (gtranslator_view_init),
	(gtranslator_view_reload_scheme_color):
	* view.h:
	Added scheme color setting.

Modified:
   trunk/src/ChangeLog
   trunk/src/dialogs/preferences-dialog.c
   trunk/src/dialogs/preferences-dialog.glade
   trunk/src/prefs-manager-app.c
   trunk/src/prefs-manager.c
   trunk/src/prefs-manager.h
   trunk/src/view.c
   trunk/src/view.h

Modified: trunk/src/dialogs/preferences-dialog.c
==============================================================================
--- trunk/src/dialogs/preferences-dialog.c	(original)
+++ trunk/src/dialogs/preferences-dialog.c	Mon Sep 22 09:41:57 2008
@@ -38,6 +38,7 @@
 #include <gio/gio.h>
 #include <gtk/gtk.h>
 #include <string.h>
+#include <gtksourceview/gtksourcestyleschememanager.h>
 
 #define GTR_PREFERENCES_DIALOG_GET_PRIVATE(object)	(G_TYPE_INSTANCE_GET_PRIVATE ( \
 						 	(object),	\
@@ -105,6 +106,8 @@
 	
 	/*Inteface*/
 	GtkWidget *gdl_combobox;
+	GtkWidget *scheme_color_combobox;
+	GtkWidget *toolbar_combobox;
 	
 	/*Plugins*/
 	GtkWidget *plugins_box;
@@ -537,20 +540,52 @@
 }
 
 static void
+scheme_color_changed_cb (GtkComboBox *combobox,
+			 GtranslatorPreferencesDialog *dlg)
+{
+	g_return_if_fail (combobox == GTK_COMBO_BOX (dlg->priv->scheme_color_combobox));
+	
+	gtranslator_prefs_manager_set_scheme_color (gtk_combo_box_get_active_text (combobox));
+}
+
+static void
 setup_interface_pages(GtranslatorPreferencesDialog *dlg)
 {
 	gint gdl_style;
+	GtkSourceStyleSchemeManager *manager;
+	const gchar * const *scheme_ids;
+	const gchar * scheme_active;
+	gint i = 0;
 	
 	/*Set initial value*/
 	gdl_style = gtranslator_prefs_manager_get_gdl_style ();
 	if (gdl_style)
 		gtk_combo_box_set_active (GTK_COMBO_BOX (dlg->priv->gdl_combobox),
 					  gdl_style);
+	
+	/*
+	 * Scheme color
+	 */
+	manager = gtk_source_style_scheme_manager_get_default ();
+	scheme_ids = gtk_source_style_scheme_manager_get_scheme_ids (manager);
+	scheme_active = gtranslator_prefs_manager_get_scheme_color ();
+	while (scheme_ids [i] != NULL)
+	{
+		gtk_combo_box_append_text (GTK_COMBO_BOX (dlg->priv->scheme_color_combobox),
+					   scheme_ids[i]);
+		if (strcmp (scheme_ids[i], scheme_active) == 0)
+			gtk_combo_box_set_active (GTK_COMBO_BOX (dlg->priv->scheme_color_combobox),
+						  i);
+		i++;
+	}
 		
 	/*Connect signals*/
-	g_signal_connect(dlg->priv->gdl_combobox, "changed",
-			 G_CALLBACK (style_changed_cb),
-			 dlg);
+	g_signal_connect (dlg->priv->gdl_combobox, "changed",
+			  G_CALLBACK (style_changed_cb),
+			  dlg);
+	g_signal_connect (dlg->priv->scheme_color_combobox, "changed",
+			  G_CALLBACK (scheme_color_changed_cb),
+			  dlg);
 }
 
 /***************Translation Memory pages****************/
@@ -1174,6 +1209,8 @@
  		"sentence_length_spinbutton", &dlg->priv->sentence_length_spinbutton,
  		
 		"gdl_combobox", &dlg->priv->gdl_combobox,
+		"scheme_color_combobox", &dlg->priv->scheme_color_combobox,
+		"toolbar_combobox", &dlg->priv->toolbar_combobox,
 		
 		"plugins_box", &dlg->priv->plugins_box,
 		NULL);

Modified: trunk/src/dialogs/preferences-dialog.glade
==============================================================================
--- trunk/src/dialogs/preferences-dialog.glade	(original)
+++ trunk/src/dialogs/preferences-dialog.glade	Mon Sep 22 09:41:57 2008
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.5 on Mon Aug  4 09:30:40 2008 -->
+<!--Generated with glade3 3.4.5 on Thu Aug  7 09:18:41 2008 -->
 <glade-interface>
   <widget class="GtkDialog" id="preferences_dialog">
     <property name="border_width">5</property>
@@ -601,6 +601,110 @@
                     <property name="fill">False</property>
                   </packing>
                 </child>
+                <child>
+                  <widget class="GtkVBox" id="vbox12">
+                    <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="spacing">6</property>
+                    <child>
+                      <widget class="GtkLabel" id="label13">
+                        <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="xalign">0</property>
+                        <property name="label" translatable="yes">&lt;b&gt;Scheme color:&lt;/b&gt;</property>
+                        <property name="use_markup">True</property>
+                      </widget>
+                    </child>
+                    <child>
+                      <widget class="GtkHBox" id="hbox5">
+                        <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>
+                        <child>
+                          <widget class="GtkLabel" id="label14">
+                            <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="label" translatable="yes">    </property>
+                          </widget>
+                          <packing>
+                            <property name="expand">False</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="GtkComboBox" id="scheme_color_combobox">
+                            <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"></property>
+                          </widget>
+                          <packing>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </widget>
+                      <packing>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </widget>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkVBox" id="vbox13">
+                    <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="spacing">6</property>
+                    <child>
+                      <widget class="GtkLabel" id="label15">
+                        <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="xalign">0</property>
+                        <property name="label" translatable="yes">&lt;b&gt;Toolbar style:&lt;/b&gt;</property>
+                        <property name="use_markup">True</property>
+                      </widget>
+                    </child>
+                    <child>
+                      <widget class="GtkHBox" id="hbox6">
+                        <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>
+                        <child>
+                          <widget class="GtkLabel" id="label27">
+                            <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="label" translatable="yes">    </property>
+                          </widget>
+                          <packing>
+                            <property name="expand">False</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="GtkComboBox" id="toolbar_combobox">
+                            <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">Text
+Icons
+Text + Icons
+Gnome toolbar setting
+Tabs</property>
+                          </widget>
+                          <packing>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </widget>
+                      <packing>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </widget>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
               </widget>
               <packing>
                 <property name="position">3</property>
@@ -787,41 +891,45 @@
                                 <property name="n_columns">2</property>
                                 <property name="column_spacing">12</property>
                                 <child>
-                                  <widget class="GtkEntry" id="tm_lang_entry">
+                                  <placeholder/>
+                                </child>
+                                <child>
+                                  <widget class="GtkLabel" id="label24">
                                     <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
+                                    <property name="xalign">0</property>
+                                    <property name="label" translatable="yes">Max. difference in sentence length:</property>
                                   </widget>
                                   <packing>
-                                    <property name="left_attach">1</property>
-                                    <property name="right_attach">2</property>
-                                    <property name="top_attach">1</property>
-                                    <property name="bottom_attach">2</property>
+                                    <property name="top_attach">3</property>
+                                    <property name="bottom_attach">4</property>
+                                    <property name="x_options">GTK_FILL</property>
                                   </packing>
                                 </child>
                                 <child>
-                                  <widget class="GtkCheckButton" id="use_lang_profile_in_tm">
+                                  <widget class="GtkSpinButton" id="sentence_length_spinbutton">
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
-                                    <property name="label" translatable="yes">Use only files with this name:</property>
-                                    <property name="response_id">0</property>
-                                    <property name="draw_indicator">True</property>
+                                    <property name="adjustment">2 0 100 1 10 10</property>
                                   </widget>
                                   <packing>
-                                    <property name="top_attach">1</property>
-                                    <property name="bottom_attach">2</property>
+                                    <property name="left_attach">1</property>
+                                    <property name="right_attach">2</property>
+                                    <property name="top_attach">3</property>
+                                    <property name="bottom_attach">4</property>
+                                    <property name="x_options">GTK_FILL</property>
                                   </packing>
                                 </child>
                                 <child>
-                                  <widget class="GtkCheckButton" id="show_tm_options_checkbutton">
+                                  <widget class="GtkLabel" id="label23">
                                     <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="label" translatable="yes">Show options in translated messages</property>
-                                    <property name="response_id">0</property>
-                                    <property name="draw_indicator">True</property>
+                                    <property name="xalign">0</property>
+                                    <property name="label" translatable="yes">Max. # of missing words:</property>
                                   </widget>
-                                </child>
-                                <child>
-                                  <placeholder/>
+                                  <packing>
+                                    <property name="top_attach">2</property>
+                                    <property name="bottom_attach">3</property>
+                                    <property name="x_options">GTK_FILL</property>
+                                  </packing>
                                 </child>
                                 <child>
                                   <widget class="GtkSpinButton" id="missing_words_spinbutton">
@@ -837,41 +945,37 @@
                                   </packing>
                                 </child>
                                 <child>
-                                  <widget class="GtkLabel" id="label23">
+                                  <widget class="GtkCheckButton" id="show_tm_options_checkbutton">
                                     <property name="visible">True</property>
-                                    <property name="xalign">0</property>
-                                    <property name="label" translatable="yes">Max. # of missing words:</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="label" translatable="yes">Show options in translated messages</property>
+                                    <property name="response_id">0</property>
+                                    <property name="draw_indicator">True</property>
                                   </widget>
-                                  <packing>
-                                    <property name="top_attach">2</property>
-                                    <property name="bottom_attach">3</property>
-                                    <property name="x_options">GTK_FILL</property>
-                                  </packing>
                                 </child>
                                 <child>
-                                  <widget class="GtkSpinButton" id="sentence_length_spinbutton">
+                                  <widget class="GtkCheckButton" id="use_lang_profile_in_tm">
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
-                                    <property name="adjustment">2 0 100 1 10 10</property>
+                                    <property name="label" translatable="yes">Use only files with this name:</property>
+                                    <property name="response_id">0</property>
+                                    <property name="draw_indicator">True</property>
                                   </widget>
                                   <packing>
-                                    <property name="left_attach">1</property>
-                                    <property name="right_attach">2</property>
-                                    <property name="top_attach">3</property>
-                                    <property name="bottom_attach">4</property>
-                                    <property name="x_options">GTK_FILL</property>
+                                    <property name="top_attach">1</property>
+                                    <property name="bottom_attach">2</property>
                                   </packing>
                                 </child>
                                 <child>
-                                  <widget class="GtkLabel" id="label24">
+                                  <widget class="GtkEntry" id="tm_lang_entry">
                                     <property name="visible">True</property>
-                                    <property name="xalign">0</property>
-                                    <property name="label" translatable="yes">Max. difference in sentence length:</property>
+                                    <property name="can_focus">True</property>
                                   </widget>
                                   <packing>
-                                    <property name="top_attach">3</property>
-                                    <property name="bottom_attach">4</property>
-                                    <property name="x_options">GTK_FILL</property>
+                                    <property name="left_attach">1</property>
+                                    <property name="right_attach">2</property>
+                                    <property name="top_attach">1</property>
+                                    <property name="bottom_attach">2</property>
                                   </packing>
                                 </child>
                               </widget>

Modified: trunk/src/prefs-manager-app.c
==============================================================================
--- trunk/src/prefs-manager-app.c	(original)
+++ trunk/src/prefs-manager-app.c	Mon Sep 22 09:41:57 2008
@@ -68,6 +68,11 @@
 							GConfEntry  *entry,
 							gpointer     user_data);
 
+static void gtranslator_prefs_manager_scheme_color_changed (GConfClient *client,
+							    guint        cnxn_id, 
+							    GConfEntry  *entry, 
+							    gpointer     user_data);
+
 /* GUI state is serialized to a .desktop file, not in gconf */
 
 #define GTR_STATE_DEFAULT_WINDOW_STATE		0
@@ -443,7 +448,12 @@
 		gconf_client_notify_add (gtranslator_prefs_manager->gconf_client,
 					 GPM_AUTOSAVE,
 					 gtranslator_prefs_manager_autosave_changed,
-					 NULL, NULL, NULL);		
+					 NULL, NULL, NULL);
+		
+		gconf_client_notify_add (gtranslator_prefs_manager->gconf_client,
+					 GPM_SCHEME_COLOR,
+					 gtranslator_prefs_manager_scheme_color_changed,
+					 NULL, NULL, NULL);
 	}
 
 	return gtranslator_prefs_manager != NULL;	
@@ -691,3 +701,19 @@
 		g_list_free (tabs);
 	}
 }
+
+static void
+gtranslator_prefs_manager_scheme_color_changed (GConfClient *client,
+						guint        cnxn_id, 
+						GConfEntry  *entry, 
+						gpointer     user_data)
+{
+	GList *views, *l;
+	
+	views = gtranslator_application_get_views (GTR_APP, TRUE, TRUE);
+	
+	for (l = views; l != NULL; l = g_list_next (l))
+	{
+		gtranslator_view_reload_scheme_color (GTR_VIEW (l->data));
+	}
+}

Modified: trunk/src/prefs-manager.c
==============================================================================
--- trunk/src/prefs-manager.c	(original)
+++ trunk/src/prefs-manager.c	Mon Sep 22 09:41:57 2008
@@ -325,6 +325,10 @@
 		 GPM_GDL_STYLE,
 		 GPM_DEFAULT_GDL_STYLE)
 
+DEFINE_STRING_PREF (scheme_color,
+		    GPM_SCHEME_COLOR,
+		    GPM_DEFAULT_SCHEME_COLOR)
+
 /* Translation Memory */
 DEFINE_STRING_PREF (tm_dir,
 		    GPM_TM_DIR,

Modified: trunk/src/prefs-manager.h
==============================================================================
--- trunk/src/prefs-manager.h	(original)
+++ trunk/src/prefs-manager.h	Mon Sep 22 09:41:57 2008
@@ -85,6 +85,7 @@
 /* Interface */
 #define GPM_INTERFACE_DIR		GPM_PREFS_DIR "/interface"
 #define GPM_GDL_STYLE			GPM_INTERFACE_DIR "/gdl_style"
+#define GPM_SCHEME_COLOR		GPM_INTERFACE_DIR "/scheme_color"
 
 /* Fallback default values. Keep in sync with gtranslator.schemas */
 
@@ -122,6 +123,7 @@
 
 /* Interface */
 #define GPM_DEFAULT_GDL_STYLE           2 //Both icons and text
+#define GPM_DEFAULT_SCHEME_COLOR	"classic"
 
 /* Translation Memory */
 #define GPM_DEFAULT_TM_DIR              (const gchar*) ""
@@ -205,6 +207,10 @@
 void                     gtranslator_prefs_manager_set_gdl_style                (gint style);
 gint                     gtranslator_prefs_manager_get_gdl_style                (void);
 
+/*Scheme color*/
+void                     gtranslator_prefs_manager_set_scheme_color             (const gchar *scheme);
+const gchar *            gtranslator_prefs_manager_get_scheme_color             (void);
+
 /*Translation Memory*/
 void                     gtranslator_prefs_manager_set_tm_dir                   (const gchar *dir);
 const gchar *            gtranslator_prefs_manager_get_tm_dir                   (void);

Modified: trunk/src/view.c
==============================================================================
--- trunk/src/view.c	(original)
+++ trunk/src/view.c	Mon Sep 22 09:41:57 2008
@@ -40,6 +40,7 @@
 #include <gtksourceview/gtksourcelanguagemanager.h>
 #include <gtksourceview/gtksourceiter.h>
 #include <gtksourceview/gtksourcebuffer.h>
+#include <gtksourceview/gtksourcestyleschememanager.h>
 
 #ifdef HAVE_GTKSPELL
 #include <gtkspell/gtkspell.h>
@@ -150,6 +151,11 @@
 	{
 		gtranslator_view_set_font (view, TRUE, NULL);
 	}
+	
+	/*
+	 * Set scheme color according to preferences
+	 */
+	gtranslator_view_reload_scheme_color (view);
 }
 
 static void
@@ -802,3 +808,21 @@
 
 	return cont;
 }
+
+
+void
+gtranslator_view_reload_scheme_color (GtranslatorView *view)
+{
+	GtkSourceBuffer *buf;
+	GtkSourceStyleScheme *scheme;
+	GtkSourceStyleSchemeManager *manager;
+	const gchar *scheme_id;
+	
+	buf = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
+	manager = gtk_source_style_scheme_manager_get_default ();
+	
+	scheme_id = gtranslator_prefs_manager_get_scheme_color ();
+	scheme = gtk_source_style_scheme_manager_get_scheme (manager, scheme_id);
+	
+	gtk_source_buffer_set_style_scheme (buf, scheme);
+}
\ No newline at end of file

Modified: trunk/src/view.h
==============================================================================
--- trunk/src/view.h	(original)
+++ trunk/src/view.h	Mon Sep 22 09:41:57 2008
@@ -108,6 +108,8 @@
 gchar           *gtranslator_view_get_search_text        (GtranslatorView *view,
 							  guint         *flags);
 
+void             gtranslator_view_reload_scheme_color    (GtranslatorView *view);
+
 
 /* Search macros */
 #define GTR_SEARCH_IS_DONT_SET_FLAGS(sflags) ((sflags & GTR_SEARCH_DONT_SET_FLAGS) != 0)



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