]> spindle.queued.net Git - midori/commitdiff
Implement a font combobox and use it for Default Font Family.
authorChristian Dywan <christian@twotoasts.de>
Sun, 20 Apr 2008 16:12:39 +0000 (18:12 +0200)
committerChristian Dywan <christian@twotoasts.de>
Sun, 20 Apr 2008 16:13:20 +0000 (18:13 +0200)
katze/katze-utils.c
src/main.c
src/midori-preferences.c

index da7f089d1dac50bd01b688bf49e268dc19430238..8f9e8c80d2e036b3453b4c8f342ee22e06f79aa4 100644 (file)
@@ -48,6 +48,15 @@ proxy_uri_file_set_cb (GtkFileChooser* button,
     g_object_set (object, property, file, NULL);
 }
 
+static gchar*
+proxy_combo_box_text_changed_cb (GtkComboBox* button, GObject* object)
+{
+    gchar* text = gtk_combo_box_get_active_text (button);
+    const gchar* property = g_object_get_data (G_OBJECT (button), "property");
+    g_object_set (object, property, text, NULL);
+    return FALSE;
+}
+
 static gboolean
 proxy_entry_focus_out_event_cb (GtkEntry*      entry,
                                 GdkEventFocus* event,
@@ -62,7 +71,7 @@ proxy_entry_focus_out_event_cb (GtkEntry*      entry,
 static gboolean
 proxy_spin_button_changed_cb (GtkSpinButton* button, GObject* object)
 {
-    gdouble value = gtk_spin_button_get_value (button);
+    gint value = gtk_spin_button_get_value_as_int (button);
     const gchar* property = g_object_get_data (G_OBJECT (button), "property");
     g_object_set (object, property, value, NULL);
     return FALSE;
@@ -96,6 +105,8 @@ proxy_combo_box_changed_cb (GtkComboBox* button, GObject* object)
  *         choosing an existing folder.
  *     "uri": the widget created will be particularly suitable for
  *         choosing an existing filename, encoded as an URI.
+ *     "font": the widget created will be particularly suitable for
+ *         choosing a font from installed fonts.
  *
  * Any other values for @hint are silently ignored.
  *
@@ -167,6 +178,27 @@ katze_property_proxy (gpointer     object,
         g_signal_connect (widget, "file-set",
                           G_CALLBACK (proxy_uri_file_set_cb), object);
     }
+    else if (type == G_TYPE_PARAM_STRING && _hint == g_intern_string ("font"))
+    {
+        widget = gtk_combo_box_new_text ();
+        PangoContext* context = gtk_widget_get_pango_context (widget);
+        PangoFontFamily** families;
+        int n_families;
+        pango_context_list_families (context, &families, &n_families);
+        g_object_get (object, property, &string, NULL);
+        gint i = 0;
+        while (i < n_families)
+        {
+            const gchar* font = pango_font_family_get_name (families[i]);
+            gtk_combo_box_append_text (GTK_COMBO_BOX (widget), font);
+            if (string && !strcmp (font, string))
+                gtk_combo_box_set_active (GTK_COMBO_BOX (widget), i);
+            i++;
+        }
+        g_signal_connect (widget, "changed",
+                          G_CALLBACK (proxy_combo_box_text_changed_cb), object);
+        g_free (families);
+    }
     else if (type == G_TYPE_PARAM_STRING)
     {
         widget = gtk_entry_new ();
@@ -182,7 +214,7 @@ katze_property_proxy (gpointer     object,
         widget = gtk_spin_button_new_with_range (
             G_PARAM_SPEC_INT (pspec)->minimum,
             G_PARAM_SPEC_INT (pspec)->maximum, 1);
-        gdouble value;
+        gint value;
         g_object_get (object, property, &value, NULL);
         gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value);
         g_signal_connect (widget, "changed",
index 55f77559bab536c69a25907047c6a80f30cc2be1..a4b0715d94c017f4d81c5b22b8e41eff3d6c664b 100644 (file)
@@ -53,7 +53,7 @@ static void stock_items_init(void)
         { STOCK_TAB_NEW,        N_("New _Tab"), 0, 0, NULL },
         { STOCK_WINDOW_NEW,     N_("New _Window"), 0, 0, NULL },
         #if !GTK_CHECK_VERSION(2, 10, 0)
-        { GTK_STOCK_SELECT_ALL, N_("Select _All", 0, 0, NULL },
+        { GTK_STOCK_SELECT_ALL, N_("Select _All"), 0, 0, NULL },
         #endif
         #if !GTK_CHECK_VERSION(2, 8, 0)
         { GTK_STOCK_FULLSCREEN, N_("_Fullscreen"), 0, 0, NULL },
index e623453acfabd1c9d5cf26ae9e2e697422a94ca7..1fd72966b9d3092862b0ae7e3d94a41e83b02adc 100644 (file)
@@ -264,7 +264,7 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
     label = katze_property_label (settings, "default-font-family");
     INDENTED_ADD (label, 0, 1, 0, 1);
     hbox = gtk_hbox_new (FALSE, 4);
-    button = katze_property_proxy (settings, "default-font-family", NULL);
+    button = katze_property_proxy (settings, "default-font-family", "font");
     gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
     entry = katze_property_proxy (settings, "default-font-size", NULL);
     gtk_box_pack_end (GTK_BOX (hbox), entry, FALSE, FALSE, 4);