]> spindle.queued.net Git - midori/commitdiff
Implement cm_skip_leading_dot() to avoid code duplication
authorEnrico Tröger <enrico.troeger@uvena.de>
Thu, 7 Jan 2010 23:10:26 +0000 (00:10 +0100)
committerChristian Dywan <christian@twotoasts.de>
Thu, 7 Jan 2010 23:16:56 +0000 (00:16 +0100)
extensions/cookie-manager/cookie-manager-page.c

index 3d5cc19f2d54c421d24d67450cb39767a958624e..c394efd0df3fc60f96db7314c21dbc3224ec4945 100644 (file)
@@ -528,6 +528,12 @@ static void cm_button_delete_all_clicked_cb(GtkToolButton *button, CookieManager
 }
 
 
+static const gchar *cm_skip_leading_dot(const gchar *text)
+{
+       return (*text == '.') ? text + 1 : text;
+}
+
+
 static void cm_tree_drag_data_get_cb(GtkWidget *widget, GdkDragContext *drag_context,
                                                                         GtkSelectionData *data, guint info, guint ltime,
                                                                         CookieManagerPage *cmp)
@@ -554,7 +560,8 @@ static void cm_tree_drag_data_get_cb(GtkWidget *widget, GdkDragContext *drag_con
        if (gtk_tree_store_iter_is_valid(priv->store, &iter_store))
        {
                SoupCookie *cookie;
-               gchar *name, *text;
+               gchar *name;
+               const gchar *text;
 
                gtk_tree_model_get(model, &iter,
                        COOKIE_MANAGER_COL_NAME, &name,
@@ -563,8 +570,7 @@ static void cm_tree_drag_data_get_cb(GtkWidget *widget, GdkDragContext *drag_con
 
                if (cookie == NULL && name != NULL)
                {
-                       /* skip a leading dot */
-                       text = (*name == '.') ? name + 1 : name;
+                       text = cm_skip_leading_dot(name);
 
                        gtk_selection_data_set_text(data, text, -1);
                }
@@ -613,8 +619,7 @@ static gchar *cm_get_domain_description_text(const gchar *domain, gint cookie_co
 {
        gchar *str, *text;
 
-       if (*domain == '.')
-               domain++; /* skip a leading dot */
+       domain = cm_skip_leading_dot(domain);
 
        text = g_markup_printf_escaped(
                _("<b>Domain</b>: %s\n<b>Cookies</b>: %d"),