~midori/midori/trunk

« back to all changes in this revision

Viewing changes to midori/midori-browser.c

  • Committer: André Auzi
  • Date: 2013-08-05 19:52:52 UTC
  • mto: This revision was merged to the branch mainline in revision 6406.
  • Revision ID: aauzi@free.fr-20130805195252-89hqx89j37gl7v61
Derive MidoriBookmarksDb from KatzeArray in order to implement update-item signal
Implements, partially, signal redirection to parent KatzeArray after database operations.
On update-item signal, both bookmarkbar and bookmarks panel update themself.

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
 
88
88
    MidoriWebSettings* settings;
89
89
    KatzeArray* proxy_array;
90
 
    KatzeArray* bookmarks;
 
90
    MidoriBookmarksDb* bookmarks;
91
91
    KatzeArray* trash;
92
92
    KatzeArray* search_engines;
93
93
    KatzeArray* history;
195
195
                                GtkToolbarStyle style);
196
196
 
197
197
static void
198
 
midori_browser_set_bookmarks (MidoriBrowser* browser,
199
 
                              KatzeArray*    bookmarks);
 
198
midori_browser_set_bookmarks (MidoriBrowser*     browser,
 
199
                              MidoriBookmarksDb* bookmarks);
200
200
 
201
201
static void
202
202
midori_browser_add_speed_dial (MidoriBrowser* browser);
863
863
}
864
864
 
865
865
static GtkWidget*
866
 
midori_bookmark_folder_button_new (KatzeArray* array,
 
866
midori_bookmark_folder_button_new (MidoriBookmarksDb* array,
867
867
                                   gint64      selected_parentid)
868
868
{
869
869
    GtkTreeStore* model;
1220
1220
        katze_item_set_meta_integer (bookmark, "parentid", selected);
1221
1221
 
1222
1222
        if (new_bookmark)
1223
 
            katze_array_add_item (browser->bookmarks, bookmark);
 
1223
            midori_bookmarks_db_add_item (browser->bookmarks, bookmark);
1224
1224
        else
1225
 
        {
1226
 
            midori_array_update_item (browser->bookmarks, bookmark);
1227
 
            midori_browser_update_history (bookmark, "bookmark", "modify");
1228
 
 
1229
 
            if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_toolbar)))
1230
 
                if (!gtk_widget_get_visible (browser->bookmarkbar))
1231
 
                    _action_set_active (browser, "Bookmarkbar", TRUE);
1232
 
            if (gtk_widget_get_visible (browser->bookmarkbar))
1233
 
                midori_bookmarkbar_populate (browser);
1234
 
        }
 
1225
            midori_bookmarks_db_update_item (browser->bookmarks, bookmark);
1235
1226
 
1236
1227
        return_status = TRUE;
1237
1228
    }
2508
2499
                                     "bookmarks",
2509
2500
                                     "Bookmarks",
2510
2501
                                     "The bookmarks folder, containing all bookmarks",
2511
 
                                     KATZE_TYPE_ARRAY,
 
2502
                                     TYPE_MIDORI_BOOKMARKS_DB,
2512
2503
                                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
2513
2504
 
2514
2505
    /**
3230
3221
    else
3231
3222
        condition = "parentid = %q";
3232
3223
 
3233
 
    bookmarks = midori_array_query_recursive  (browser->bookmarks,
3234
 
                                                 "id, title, parentid, uri, app, pos_panel, pos_bar", condition, id, FALSE);
 
3224
    bookmarks = midori_bookmarks_db_query_recursive (browser->bookmarks,
 
3225
        "id, title, parentid, uri, app, pos_panel, pos_bar", condition, id, FALSE);
3235
3226
    if (!bookmarks)
3236
3227
        return FALSE;
3237
3228
 
4258
4249
    KatzeItem* item;
4259
4250
 
4260
4251
    item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem");
4261
 
    katze_array_remove_item (browser->bookmarks, item);
 
4252
    midori_bookmarks_db_remove_item (browser->bookmarks, item);
4262
4253
}
4263
4254
 
4264
4255
static void
4270
4261
    MidoriContextAction* menu = midori_context_action_new ("BookmarkContextMenu", NULL, NULL, NULL);
4271
4262
    if (KATZE_ITEM_IS_FOLDER (item))
4272
4263
    {
4273
 
        gint child_bookmarks_count = midori_array_count_recursive (browser->bookmarks,
 
4264
        gint child_bookmarks_count = midori_bookmarks_db_count_recursive (browser->bookmarks,
4274
4265
            "uri <> ''", NULL, item, FALSE);
4275
4266
 
4276
4267
        GtkAction* action = gtk_action_new ("BookmarkOpenAllTabs", _("Open all in _Tabs"), NULL, STOCK_TAB_NEW);
4540
4531
            if (error)
4541
4532
                g_error_free (error);
4542
4533
        }
4543
 
        midori_bookmarks_import_array (browser->bookmarks, bookmarks, selected);
4544
 
 
 
4534
        midori_bookmarks_db_import_array (browser->bookmarks, bookmarks, selected);
4545
4535
        g_object_unref (bookmarks);
4546
4536
        g_free (path);
4547
4537
    }
4595
4585
        return;
4596
4586
 
4597
4587
    error = NULL;
4598
 
    bookmarks = midori_array_query_recursive (browser->bookmarks,
 
4588
    bookmarks = midori_bookmarks_db_query_recursive (browser->bookmarks,
4599
4589
        "*", "parentid IS NULL", NULL, TRUE);
4600
4590
    if (!midori_array_to_file (bookmarks, path, format, &error))
4601
4591
    {
7007
6997
}
7008
6998
 
7009
6999
static void
 
7000
midori_bookmarkbar_update_item_cb (KatzeArray*    bookmarks,
 
7001
                                   KatzeItem*     item,
 
7002
                                   MidoriBrowser* browser)
 
7003
{
 
7004
    if (gtk_widget_get_visible (browser->bookmarkbar))
 
7005
        midori_bookmarkbar_populate (browser);
 
7006
    midori_browser_update_history (item, "bookmark", "modify");
 
7007
}
 
7008
 
 
7009
static void
7010
7010
midori_bookmarkbar_remove_item_cb (KatzeArray*    bookmarks,
7011
7011
                                   KatzeItem*     item,
7012
7012
                                   MidoriBrowser* browser)
7038
7038
    gtk_toolbar_insert (GTK_TOOLBAR (browser->bookmarkbar),
7039
7039
                        gtk_separator_tool_item_new (), -1);
7040
7040
 
7041
 
    array = midori_array_query_recursive  (browser->bookmarks,
7042
 
                                             "id, parentid, title, uri, desc, app, toolbar, pos_panel, pos_bar", "toolbar = 1", NULL, FALSE);
 
7041
    array = midori_bookmarks_db_query_recursive (browser->bookmarks,
 
7042
        "id, parentid, title, uri, desc, app, toolbar, pos_panel, pos_bar", "toolbar = 1", NULL, FALSE);
7043
7043
    if (!array)
7044
7044
    {
7045
7045
        _action_set_sensitive (browser, "BookmarkAdd", FALSE);
7079
7079
 
7080
7080
static void
7081
7081
midori_browser_set_bookmarks (MidoriBrowser* browser,
7082
 
                              KatzeArray*    bookmarks)
 
7082
                              MidoriBookmarksDb*    bookmarks)
7083
7083
{
7084
7084
    MidoriWebSettings* settings;
7085
7085
 
7088
7088
        g_signal_handlers_disconnect_by_func (browser->bookmarks,
7089
7089
            midori_bookmarkbar_add_item_cb, browser);
7090
7090
        g_signal_handlers_disconnect_by_func (browser->bookmarks,
 
7091
            midori_bookmarkbar_update_item_cb, browser);
 
7092
        g_signal_handlers_disconnect_by_func (browser->bookmarks,
7091
7093
            midori_bookmarkbar_remove_item_cb, browser);
7092
7094
    }
7093
7095
 
7121
7123
    g_object_notify (G_OBJECT (settings), "show-bookmarkbar");
7122
7124
    g_signal_connect_after (bookmarks, "add-item",
7123
7125
        G_CALLBACK (midori_bookmarkbar_add_item_cb), browser);
 
7126
    g_signal_connect_after (bookmarks, "update-item",
 
7127
        G_CALLBACK (midori_bookmarkbar_update_item_cb), browser);
7124
7128
    g_signal_connect_after (bookmarks, "remove-item",
7125
7129
        G_CALLBACK (midori_bookmarkbar_remove_item_cb), browser);
7126
7130
}