[Xfce4-commits] <midori:master> Allow re-ordering of search engines

Christian Dywan noreply at xfce.org
Sun Mar 13 17:38:01 CET 2011


Updating branch refs/heads/master
         to f2b5e82ce473fd6c4f5e418bdaed8975732a8350 (commit)
       from fb681fac09654338bbc90dda5fa3b8283aa9096d (commit)

commit f2b5e82ce473fd6c4f5e418bdaed8975732a8350
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sun Mar 13 17:36:28 2011 +0100

    Allow re-ordering of search engines

 midori/main.c                |   11 +++++++
 midori/midori-searchaction.c |   68 ++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 77 insertions(+), 2 deletions(-)

diff --git a/midori/main.c b/midori/main.c
index e4ca398..5ce2c2b 100644
--- a/midori/main.c
+++ b/midori/main.c
@@ -650,6 +650,15 @@ midori_search_engines_modify_cb (KatzeArray* array,
 }
 
 static void
+midori_search_engines_move_item_cb (KatzeArray* array,
+                                    gpointer    item,
+                                    gint        position,
+                                    KatzeArray* search_engines)
+{
+    midori_search_engines_modify_cb (array, item, search_engines);
+}
+
+static void
 midori_trash_add_item_cb (KatzeArray* trash,
                           GObject*    item)
 {
@@ -2282,6 +2291,8 @@ main (int    argc,
             KATZE_ARRAY_FOREACH_ITEM (item, search_engines)
                 g_signal_connect_after (item, "notify",
                     G_CALLBACK (midori_search_engines_modify_cb), search_engines);
+            g_signal_connect_after (search_engines, "move-item",
+                G_CALLBACK (midori_search_engines_move_item_cb), search_engines);
         }
     }
     g_signal_connect_after (trash, "add-item",
diff --git a/midori/midori-searchaction.c b/midori/midori-searchaction.c
index 8487234..4a94bb6 100644
--- a/midori/midori-searchaction.c
+++ b/midori/midori-searchaction.c
@@ -1096,6 +1096,68 @@ midori_search_action_dialog_remove_cb (GtkWidget*          widget,
 }
 
 static void
+midori_search_action_dialog_move_up_cb (GtkWidget*          widget,
+                                        MidoriSearchAction* search_action)
+{
+    KatzeArray* search_engines;
+    GtkWidget* treeview;
+    GtkTreeSelection* selection;
+    GtkTreeModel* liststore;
+    GtkTreeIter iter, prev;
+    GtkTreePath* path;
+    KatzeItem* item;
+    gint i;
+
+    search_engines = search_action->search_engines;
+    treeview = search_action->treeview;
+    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
+
+    if (gtk_tree_selection_get_selected (selection, &liststore, &iter))
+    {
+        path = gtk_tree_model_get_path (liststore, &iter);
+        if(gtk_tree_path_prev(path))
+        {
+            gtk_tree_model_get (liststore, &iter, 0, &item, -1);
+            gtk_tree_model_get_iter (liststore, &prev, path);
+            gtk_list_store_swap (GTK_LIST_STORE(liststore), &iter, &prev);
+
+            i = katze_array_get_item_index (search_engines, item);
+            katze_array_move_item (search_engines, item, i - 1);
+        }
+        gtk_tree_path_free (path);
+    }
+}
+
+static void
+midori_search_action_dialog_move_down_cb (GtkWidget*          widget,
+                                          MidoriSearchAction* search_action)
+{
+    KatzeArray* search_engines;
+    GtkWidget* treeview;
+    GtkTreeSelection* selection;
+    GtkTreeModel* liststore;
+    GtkTreeIter iter, next;
+    KatzeItem* item;
+    gint i;
+
+    search_engines = search_action->search_engines;
+    treeview = search_action->treeview;
+    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
+    if (gtk_tree_selection_get_selected (selection, &liststore, &iter))
+    {
+        next = iter;
+        if (gtk_tree_model_iter_next (liststore, &next))
+        {
+            gtk_tree_model_get (liststore, &iter, 0, &item, -1);
+            gtk_list_store_swap (GTK_LIST_STORE(liststore), &iter, &next);
+
+            i = katze_array_get_item_index (search_engines, item);
+            katze_array_move_item (search_engines, item, i + 1);
+        }
+    }
+}
+
+static void
 midori_search_action_dialog_default_cb (GtkWidget*          widget,
                                         MidoriSearchAction* search_action)
 {
@@ -1349,10 +1411,12 @@ midori_search_action_get_dialog (MidoriSearchAction* search_action)
     button = gtk_label_new (""); /* This is an invisible separator */
     gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 12);
     button = gtk_button_new_from_stock (GTK_STOCK_GO_DOWN);
-    gtk_widget_set_sensitive (button, FALSE);
+    g_signal_connect (button, "clicked",
+        G_CALLBACK (midori_search_action_dialog_move_down_cb), search_action);
     gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
     button = gtk_button_new_from_stock (GTK_STOCK_GO_UP);
-    gtk_widget_set_sensitive (button, FALSE);
+    g_signal_connect (button, "clicked",
+        G_CALLBACK (midori_search_action_dialog_move_up_cb), search_action);
     gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
 
     #if HAVE_OSX



More information about the Xfce4-commits mailing list