[Xfce4-commits] <midori:master> No need to check for rows and columns in speed dial now

Christian Dywan noreply at xfce.org
Mon Oct 17 02:52:04 CEST 2011


Updating branch refs/heads/master
         to 7b4f2254ff733f62f4dc3b8e4f1de2ade1929549 (commit)
       from 3fa294d1001dd7df9e54fec69883d2574be5235c (commit)

commit 7b4f2254ff733f62f4dc3b8e4f1de2ade1929549
Author: Paweł Forysiuk <tuxator at o2.pl>
Date:   Wed Oct 12 14:39:18 2011 +0200

    No need to check for rows and columns in speed dial now

 midori/midori-browser.c |   17 ++++++++++++-----
 midori/midori-view.c    |   19 ++-----------------
 2 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index bd0db5c..fbcfcdb 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -1091,12 +1091,19 @@ midori_browser_speed_dial_get_next_free_slot (MidoriView* view)
 {
     MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (view));
     GKeyFile* key_file;
-    guint cols, rows, slot = 1;
+    guint slot_count = 0, slot = 1, i;
+    gchar** groups;
 
     g_object_get (browser, "speed-dial", &key_file, NULL);
-    rows = g_key_file_get_integer (key_file, "settings", "rows", NULL);
-    cols = g_key_file_get_integer (key_file, "settings", "columns", NULL);
-    while (slot <= cols * rows)
+
+    groups = g_key_file_get_groups (key_file, NULL);
+    for (i = 0; groups[i]; i++)
+    {
+        if (g_key_file_has_key (key_file, groups[i], "uri", NULL))
+            slot_count++;
+    }
+
+    while (slot <= slot_count)
     {
         gchar* dial_id = g_strdup_printf ("Dial %d", slot);
         if (!g_key_file_has_group (key_file, dial_id))
@@ -1107,7 +1114,7 @@ midori_browser_speed_dial_get_next_free_slot (MidoriView* view)
         g_free (dial_id);
         slot++;
     }
-    return NULL;
+    return g_strdup_printf ("s%d", slot_count + 1);
 }
 
 static void
diff --git a/midori/midori-view.c b/midori/midori-view.c
index 315894b..aa61231 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -3686,7 +3686,7 @@ prepare_speed_dial_html (MidoriView* view)
     MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (view));
     GKeyFile* key_file;
     GString* markup = NULL;
-    guint rows, cols, slot = 1;
+    guint slot = 1;
     guint slot_count = 1, i, grid_index = 3, slot_size;
     gchar* speed_dial_head;
     gchar* file_path;
@@ -3708,11 +3708,7 @@ prepare_speed_dial_html (MidoriView* view)
             "{title}", _("Speed Dial"),
             "{click_to_add}", _("Click to add a shortcut"),
             "{enter_shortcut_address}", _("Enter shortcut address"),
-            "{enter_shortcut_name}", _("Enter shortcut title"),
             "{are_you_sure}", _("Are you sure you want to delete this shortcut?"),
-            "{set_dial_size}", _("Set number of columns and rows"),
-            "{enter_dial_size}", _("Enter number of columns and rows:"),
-            "{invalid_dial_size}", _("Invalid input for the size of the speed dial"),
             NULL);
 
         markup = g_string_new (header);
@@ -3727,9 +3723,6 @@ prepare_speed_dial_html (MidoriView* view)
         return g_strdup ("");
     }
 
-    rows = g_key_file_get_integer (key_file, "settings", "rows", NULL);
-    cols = g_key_file_get_integer (key_file, "settings", "columns", NULL);
-
     groups = g_key_file_get_groups (key_file, NULL);
     for (i = 0; groups[i]; i++)
     {
@@ -3737,9 +3730,6 @@ prepare_speed_dial_html (MidoriView* view)
 	    slot_count++;
     }
 
-    g_string_append_printf (markup,
-        "<script>var columns=%d; var rows=%d;</script>", cols, rows);
-
     /* try to guess the best X by X grid  size */
     while ((grid_index * grid_index) < slot_count)
         grid_index++;
@@ -5495,12 +5485,7 @@ midori_view_speed_dial_save (MidoriView*  view,
     g_object_get (browser, "speed-dial", &key_file, NULL);
     action = parts[0];
 
-    if (g_str_equal (action, "size"))
-    {
-        g_key_file_set_string (key_file, "settings", "rows", parts[2]);
-        g_key_file_set_string (key_file, "settings", "columns", parts[1]);
-    }
-    else if (g_str_equal (action, "thumbsize"))
+    if (g_str_equal (action, "thumbsize"))
     {
         gchar* saved_size;
         gchar* thumb_size_type;


More information about the Xfce4-commits mailing list