~ubuntu-branches/ubuntu/oneiric/midori/oneiric-updates

« back to all changes in this revision

Viewing changes to midori/midori-searchaction.c

  • Committer: Bazaar Package Importer
  • Author(s): Micah Gersten
  • Date: 2011-05-18 21:07:34 UTC
  • mfrom: (1.1.16 upstream) (3.3.9 sid)
  • Revision ID: james.westby@ubuntu.com-20110518210734-232wzq1tc88gtz2p
Tags: 0.3.6-1ubuntu1
* Merge from debian unstable. (LP: #784944) Remaining changes:
  - debian/control:
    + Change build-depends from libwebkit-dev to libwebkitgtk-dev
  - debian/rules:
    + Change package query from libwebkit-dev to libwebkitgtk-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
399
399
        gtk_widget_show (dialog);
400
400
}
401
401
 
402
 
/* Private function, used by MidoriView */
403
 
/* static */ GdkPixbuf*
 
402
GdkPixbuf*
404
403
midori_search_action_get_icon (KatzeItem*    item,
405
404
                               GtkWidget*    widget,
406
405
                               const gchar** icon_name,
413
412
    if ((icon = katze_item_get_uri (item)) && (g_strstr_len (icon, 8, "://")))
414
413
        return katze_load_cached_icon (icon, widget);
415
414
 
 
415
    if (icon_name == NULL)
 
416
        return NULL;
416
417
 
417
418
    screen = gtk_widget_get_screen (widget);
418
419
    icon_theme = gtk_icon_theme_get_for_screen (screen);
674
675
                                         KatzeArray*         search_engines)
675
676
{
676
677
    GSList* proxies;
677
 
    GtkWidget* alignment;
678
 
    GtkWidget* entry;
679
678
 
680
679
    g_return_if_fail (MIDORI_IS_SEARCH_ACTION (search_action));
681
680
    g_return_if_fail (!search_engines ||
702
701
    proxies = gtk_action_get_proxies (GTK_ACTION (search_action));
703
702
    if (!proxies)
704
703
        return;
705
 
 
706
 
    do
707
 
    if (GTK_IS_TOOL_ITEM (proxies->data))
708
 
    {
709
 
        alignment = gtk_bin_get_child (GTK_BIN (proxies->data));
710
 
        entry = gtk_bin_get_child (GTK_BIN (alignment));
711
 
 
712
 
        /* FIXME: Unset the current item if it isn't in the list */
713
 
    }
714
 
    while ((proxies = g_slist_next (proxies)));
715
704
}
716
705
 
717
706
KatzeItem*
824
813
                                            GtkWidget*         treeview)
825
814
{
826
815
    KatzeItem* item;
827
 
    MidoriSearchAction* search_action;
828
816
    GdkPixbuf* icon;
829
817
    const gchar* icon_name;
830
818
 
831
819
    gtk_tree_model_get (model, iter, 0, &item, -1);
832
820
 
833
 
    search_action = g_object_get_data (G_OBJECT (treeview), "search-action");
834
821
    if ((icon = midori_search_action_get_icon (item, treeview, &icon_name, FALSE)))
835
822
    {
836
823
        g_object_set (renderer, "pixbuf", icon, "yalign", 0.25, NULL);
1034
1021
           we need to update the default search engine after editing it. */
1035
1022
        else if (item == midori_search_action_get_default_item (search_action))
1036
1023
            midori_search_action_set_default_item (search_action, item);
 
1024
        g_object_unref (item);
1037
1025
    }
1038
1026
    gtk_widget_destroy (dialog);
1039
1027
}
1096
1084
}
1097
1085
 
1098
1086
static void
 
1087
midori_search_action_dialog_move_up_cb (GtkWidget*          widget,
 
1088
                                        MidoriSearchAction* search_action)
 
1089
{
 
1090
    KatzeArray* search_engines;
 
1091
    GtkWidget* treeview;
 
1092
    GtkTreeSelection* selection;
 
1093
    GtkTreeModel* liststore;
 
1094
    GtkTreeIter iter, prev;
 
1095
    GtkTreePath* path;
 
1096
    KatzeItem* item;
 
1097
    gint i;
 
1098
 
 
1099
    search_engines = search_action->search_engines;
 
1100
    treeview = search_action->treeview;
 
1101
    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
 
1102
 
 
1103
    if (gtk_tree_selection_get_selected (selection, &liststore, &iter))
 
1104
    {
 
1105
        path = gtk_tree_model_get_path (liststore, &iter);
 
1106
        if(gtk_tree_path_prev(path))
 
1107
        {
 
1108
            gtk_tree_model_get (liststore, &iter, 0, &item, -1);
 
1109
            gtk_tree_model_get_iter (liststore, &prev, path);
 
1110
            gtk_list_store_swap (GTK_LIST_STORE(liststore), &iter, &prev);
 
1111
 
 
1112
            i = katze_array_get_item_index (search_engines, item);
 
1113
            katze_array_move_item (search_engines, item, i - 1);
 
1114
            g_object_unref (item);
 
1115
            /* If the index of the current item has changed it needs to be reset */
 
1116
            g_object_notify (G_OBJECT (search_action), "current-item");
 
1117
        }
 
1118
        gtk_tree_path_free (path);
 
1119
    }
 
1120
}
 
1121
 
 
1122
static void
 
1123
midori_search_action_dialog_move_down_cb (GtkWidget*          widget,
 
1124
                                          MidoriSearchAction* search_action)
 
1125
{
 
1126
    KatzeArray* search_engines;
 
1127
    GtkWidget* treeview;
 
1128
    GtkTreeSelection* selection;
 
1129
    GtkTreeModel* liststore;
 
1130
    GtkTreeIter iter, next;
 
1131
    KatzeItem* item;
 
1132
    gint i;
 
1133
 
 
1134
    search_engines = search_action->search_engines;
 
1135
    treeview = search_action->treeview;
 
1136
    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
 
1137
    if (gtk_tree_selection_get_selected (selection, &liststore, &iter))
 
1138
    {
 
1139
        next = iter;
 
1140
        if (gtk_tree_model_iter_next (liststore, &next))
 
1141
        {
 
1142
            gtk_tree_model_get (liststore, &iter, 0, &item, -1);
 
1143
            gtk_list_store_swap (GTK_LIST_STORE(liststore), &iter, &next);
 
1144
 
 
1145
            i = katze_array_get_item_index (search_engines, item);
 
1146
            katze_array_move_item (search_engines, item, i + 1);
 
1147
            g_object_unref (item);
 
1148
            /* If the index of the current item has changed it needs to be reset */
 
1149
            g_object_notify (G_OBJECT (search_action), "current-item");
 
1150
        }
 
1151
    }
 
1152
}
 
1153
 
 
1154
static void
1099
1155
midori_search_action_dialog_default_cb (GtkWidget*          widget,
1100
1156
                                        MidoriSearchAction* search_action)
1101
1157
{
1102
 
    KatzeArray* search_engines;
1103
1158
    GtkWidget* treeview;
1104
1159
    GtkTreeSelection* selection;
1105
1160
    GtkTreeModel* liststore;
1106
1161
    GtkTreeIter iter;
1107
1162
    KatzeItem* item;
1108
1163
 
1109
 
    search_engines = search_action->search_engines;
1110
1164
    treeview = search_action->treeview;
1111
1165
    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
1112
1166
    if (gtk_tree_selection_get_selected (selection, &liststore, &iter))
1170
1224
        }
1171
1225
        else
1172
1226
            valid = gtk_tree_model_iter_next (liststore, &iter);
 
1227
        g_object_unref (found_item);
1173
1228
    }
1174
1229
}
1175
1230
 
1349
1404
    button = gtk_label_new (""); /* This is an invisible separator */
1350
1405
    gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 12);
1351
1406
    button = gtk_button_new_from_stock (GTK_STOCK_GO_DOWN);
1352
 
    gtk_widget_set_sensitive (button, FALSE);
 
1407
    g_signal_connect (button, "clicked",
 
1408
        G_CALLBACK (midori_search_action_dialog_move_down_cb), search_action);
1353
1409
    gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
1354
1410
    button = gtk_button_new_from_stock (GTK_STOCK_GO_UP);
1355
 
    gtk_widget_set_sensitive (button, FALSE);
 
1411
    g_signal_connect (button, "clicked",
 
1412
        G_CALLBACK (midori_search_action_dialog_move_up_cb), search_action);
1356
1413
    gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
1357
1414
 
1358
1415
    #if HAVE_OSX