[Xfce4-commits] <midori:master> Add optional use_markup and stock_id to Midori.Extension

Christian Dywan noreply at xfce.org
Thu Nov 29 02:46:02 CET 2012


Updating branch refs/heads/master
         to 62557d327cfbe450b82ce2b0c2ca989faa066b31 (commit)
       from e3673ce2d8811be455eabb53160674de725ec314 (commit)

commit 62557d327cfbe450b82ce2b0c2ca989faa066b31
Author: Christian Dywan <christian at twotoasts.de>
Date:   Thu Nov 29 02:43:05 2012 +0100

    Add optional use_markup and stock_id to Midori.Extension
    
    The extension panel will not escape if use_markup is set.
    
    tock_id will replace the default icon if set.

 midori/midori-extension.c  |   35 +++++++++++++++++++++++++++++++++++
 midori/midori.vapi         |    4 ++++
 panels/midori-extensions.c |   13 ++++++++++---
 3 files changed, 49 insertions(+), 3 deletions(-)

diff --git a/midori/midori-extension.c b/midori/midori-extension.c
index 57e9772..8c2c7b5 100644
--- a/midori/midori-extension.c
+++ b/midori/midori-extension.c
@@ -21,8 +21,10 @@ G_DEFINE_TYPE (MidoriExtension, midori_extension, G_TYPE_OBJECT);
 
 struct _MidoriExtensionPrivate
 {
+    gchar* stock_id;
     gchar* name;
     gchar* description;
+    gboolean use_markup;
     gchar* version;
     gchar* authors;
     gchar* website;
@@ -125,8 +127,10 @@ enum
 {
     PROP_0,
 
+    PROP_STOCK_ID,
     PROP_NAME,
     PROP_DESCRIPTION,
+    PROP_USE_MARKUP,
     PROP_VERSION,
     PROP_AUTHORS,
     PROP_WEBSITE,
@@ -212,6 +216,15 @@ midori_extension_class_init (MidoriExtensionClass* class)
     flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS;
 
     g_object_class_install_property (gobject_class,
+                                     PROP_STOCK_ID,
+                                     g_param_spec_string (
+                                     "stock-id",
+                                     "Stock ID",
+                                     "An optional icon stock ID",
+                                     NULL,
+                                     flags));
+
+    g_object_class_install_property (gobject_class,
                                      PROP_NAME,
                                      g_param_spec_string (
                                      "name",
@@ -230,6 +243,15 @@ midori_extension_class_init (MidoriExtensionClass* class)
                                      flags));
 
     g_object_class_install_property (gobject_class,
+                                     PROP_USE_MARKUP,
+                                     g_param_spec_boolean (
+                                     "use-markup",
+                                     "Use Markup",
+                                     "Whether to use Pango markup",
+                                     FALSE,
+                                     flags));
+
+    g_object_class_install_property (gobject_class,
                                      PROP_VERSION,
                                      g_param_spec_string (
                                      "version",
@@ -418,6 +440,7 @@ midori_extension_finalize (GObject* object)
     MidoriExtension* extension = MIDORI_EXTENSION (object);
 
     katze_object_assign (extension->priv->app, NULL);
+    katze_assign (extension->priv->stock_id, NULL);
     katze_assign (extension->priv->name, NULL);
     katze_assign (extension->priv->description, NULL);
     katze_assign (extension->priv->version, NULL);
@@ -442,12 +465,18 @@ midori_extension_set_property (GObject*      object,
 
     switch (prop_id)
     {
+    case PROP_STOCK_ID:
+        katze_assign (extension->priv->stock_id, g_value_dup_string (value));
+        break;
     case PROP_NAME:
         katze_assign (extension->priv->name, g_value_dup_string (value));
         break;
     case PROP_DESCRIPTION:
         katze_assign (extension->priv->description, g_value_dup_string (value));
         break;
+    case PROP_USE_MARKUP:
+        extension->priv->use_markup = g_value_get_boolean (value);
+        break;
     case PROP_VERSION:
     {
         /* Don't show version suffix if it matches the running Midori */
@@ -489,12 +518,18 @@ midori_extension_get_property (GObject*    object,
 
     switch (prop_id)
     {
+    case PROP_STOCK_ID:
+        g_value_set_string (value, extension->priv->stock_id);
+        break;
     case PROP_NAME:
         g_value_set_string (value, extension->priv->name);
         break;
     case PROP_DESCRIPTION:
         g_value_set_string (value, extension->priv->description);
         break;
+    case PROP_USE_MARKUP:
+        g_value_set_boolean (value, extension->priv->use_markup);
+        break;
     case PROP_VERSION:
         g_value_set_string (value, extension->priv->version);
         break;
diff --git a/midori/midori.vapi b/midori/midori.vapi
index 4ca9055..a7ecf08 100644
--- a/midori/midori.vapi
+++ b/midori/midori.vapi
@@ -113,10 +113,14 @@ namespace Midori {
         public void set_string (string name, string value);
 
         [NoAccessorMethod]
+        public string? stock_id { get; set; }
+        [NoAccessorMethod]
         public string name { get; set; }
         [NoAccessorMethod]
         public string description { get; set; }
         [NoAccessorMethod]
+        public bool use_markup { get; set; }
+        [NoAccessorMethod]
         public string version { get; set; }
         [NoAccessorMethod]
         public string authors { get; set; }
diff --git a/panels/midori-extensions.c b/panels/midori-extensions.c
index f9100d1..cd5d70c 100644
--- a/panels/midori-extensions.c
+++ b/panels/midori-extensions.c
@@ -231,12 +231,15 @@ midori_extensions_treeview_render_icon_cb (GtkTreeViewColumn* column,
                                            GtkWidget*         treeview)
 {
     MidoriExtension* extension;
+    gchar* stock_id;
     gtk_tree_model_get (model, iter, 0, &extension, -1);
 
-    g_object_set (renderer, "stock-id", STOCK_EXTENSION,
+    stock_id = katze_object_get_object (extension, "stock-id");
+    g_object_set (renderer, "stock-id", stock_id ? stock_id : STOCK_EXTENSION,
                             "stock-size", GTK_ICON_SIZE_BUTTON,
                             "sensitive", midori_extension_is_prepared (extension),
                             "xpad", 4, NULL);
+    g_free (stock_id);
     g_object_unref (extension);
 }
 
@@ -276,8 +279,12 @@ midori_extensions_treeview_render_text_cb (GtkTreeViewColumn* column,
     name = katze_object_get_string (extension, "name");
     version = katze_object_get_string (extension, "version");
     desc = katze_object_get_string (extension, "description");
-    text = g_markup_printf_escaped ("<b>%s</b> %s\n%s",
-        name, version && *version ? version : "", desc);
+    if (katze_object_get_boolean (extension, "use-markup"))
+        text = g_strdup_printf ("<b>%s</b> %s\n%s",
+            name, version && *version ? version : "", desc);
+    else
+        text = g_markup_printf_escaped ("<b>%s</b> %s\n%s",
+            name, version && *version ? version : "", desc);
     g_free (name);
     g_free (version);
     g_free (desc);


More information about the Xfce4-commits mailing list