[Xfce4-commits] <midori:master> Merge build_thumbnail_path into Midori.SpeedDial

Christian Dywan noreply at xfce.org
Sun Sep 9 22:36:08 CEST 2012


Updating branch refs/heads/master
         to fefc3b2cbe463815a554ea8490390ba46177d056 (commit)
       from 1ad675e24ed02cacea7aa00fead8e9f4f1941d67 (commit)

commit fefc3b2cbe463815a554ea8490390ba46177d056
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sun Sep 9 21:50:31 2012 +0200

    Merge build_thumbnail_path into Midori.SpeedDial

 midori/midori-speeddial.vala |   14 +++++++++-----
 midori/sokoke.c              |   17 -----------------
 midori/sokoke.h              |    3 ---
 3 files changed, 9 insertions(+), 25 deletions(-)

diff --git a/midori/midori-speeddial.vala b/midori/midori-speeddial.vala
index b532f36..92f30dd 100644
--- a/midori/midori-speeddial.vala
+++ b/midori/midori-speeddial.vala
@@ -15,7 +15,6 @@ namespace Katze {
 
 namespace Sokoke {
     extern static string js_script_eval (void* ctx, string script, void* error);
-    extern static string build_thumbnail_path (string uri);
 }
 
 namespace Midori {
@@ -95,7 +94,7 @@ namespace Midori {
                         string uri = keyfile.get_string (tile, "uri");
                         if (img != null && uri[0] != '\0' && uri[0] != '#') {
                             uchar[] decoded = Base64.decode (img);
-                            FileUtils.set_data (Sokoke.build_thumbnail_path (uri), decoded);
+                            FileUtils.set_data (build_thumbnail_path (uri), decoded);
                         }
                         keyfile.remove_key (tile, "img");
                     }
@@ -137,7 +136,7 @@ namespace Midori {
 
             Katze.mkdir_with_parents (Path.build_path (Path.DIR_SEPARATOR_S,
                 Paths.get_cache_dir (), "thumbnails"), 0700);
-            string filename = Sokoke.build_thumbnail_path (uri);
+            string filename = build_thumbnail_path (uri);
             try {
                 img.save (filename, "png", null, "compression", "7", null);
             }
@@ -147,6 +146,11 @@ namespace Midori {
             save ();
         }
 
+        string build_thumbnail_path (string filename) {
+            string thumbnail = Checksum.compute_for_string (ChecksumType.MD5, filename) + ".png";
+            return Path.build_filename (Paths.get_cache_dir (), "thumbnails", thumbnail);
+        }
+
         public unowned string get_html (bool close_buttons_left, GLib.Object view) throws Error {
             bool load_missing = true;
 
@@ -211,7 +215,7 @@ namespace Midori {
                         string uri = keyfile.get_string (tile, "uri");
                         if (uri != null && uri.str ("://") != null && tile.has_prefix ("Dial ")) {
                             string title = keyfile.get_string (tile, "title");
-                            string thumb_filename = Sokoke.build_thumbnail_path (uri);
+                            string thumb_filename = build_thumbnail_path (uri);
                             uint slot = tile.substring (5, -1).to_int ();
                             string encoded;
                             try {
@@ -265,7 +269,7 @@ namespace Midori {
 
                 if (action == "delete") {
                     string uri = keyfile.get_string (dial_id, "uri");
-                    string file_path = Sokoke.build_thumbnail_path (uri);
+                    string file_path = build_thumbnail_path (uri);
                     keyfile.remove_group (dial_id);
                     FileUtils.unlink (file_path);
                 }
diff --git a/midori/sokoke.c b/midori/sokoke.c
index f476f3c..ee3d4e4 100644
--- a/midori/sokoke.c
+++ b/midori/sokoke.c
@@ -1219,23 +1219,6 @@ sokoke_widget_copy_clipboard (GtkWidget*   widget,
     gtk_clipboard_set_text (clipboard, text ? text : "", -1);
 }
 
-gchar*
-sokoke_build_thumbnail_path (const gchar* name)
-{
-    gchar* path = NULL;
-    if (name != NULL)
-    {
-        gchar* checksum = g_compute_checksum_for_string (G_CHECKSUM_MD5, name, -1);
-        gchar* filename = g_strdup_printf ("%s.png", checksum);
-
-        path = g_build_filename (midori_paths_get_cache_dir (), "thumbnails", filename, NULL);
-
-        g_free (filename);
-        g_free (checksum);
-    }
-    return path;
-}
-
 static gboolean
 sokoke_entry_has_placeholder_text (GtkEntry* entry)
 {
diff --git a/midori/sokoke.h b/midori/sokoke.h
index ca411c5..1f00345 100644
--- a/midori/sokoke.h
+++ b/midori/sokoke.h
@@ -137,9 +137,6 @@ void
 sokoke_widget_copy_clipboard (GtkWidget*   widget,
                               const gchar* text);
 
-gchar*
-sokoke_build_thumbnail_path (const gchar* name);
-
 GtkWidget*
 sokoke_search_entry_new               (const gchar*        placeholder_text);
 


More information about the Xfce4-commits mailing list