~midori/midori/gtk3WebKit2only

« back to all changes in this revision

Viewing changes to midori/midori-bookmarks-db.c

  • Committer: André Auzi
  • Date: 2014-02-26 21:22:00 UTC
  • mto: This revision was merged to the branch mainline in revision 6759.
  • Revision ID: aauzi@free.fr-20140226212200-sdtk540dkfwse1yj
properly commit bookmarks-db signleton to the application

Show diffs side-by-side

added added

removed removed

Lines of Context:
181
181
midori_bookmarks_db_get_item_parent (MidoriBookmarksDb* bookmarks,
182
182
                                     gpointer    item)
183
183
{
 
184
    gint64 parentid = katze_item_get_meta_integer (KATZE_ITEM (item), "parentid");
 
185
    KatzeItem *search = katze_item_new ();
184
186
    KatzeArray* parent;
185
 
    gint64 parentid;
186
 
 
187
 
    parentid = katze_item_get_meta_integer (KATZE_ITEM (item), "parentid");
188
 
 
189
 
    if (parentid == 0)
 
187
 
 
188
    if (!parentid)
 
189
    {
 
190
        parentid = katze_item_get_meta_integer (KATZE_ITEM (bookmarks), "id");
 
191
        katze_item_set_meta_integer (KATZE_ITEM (item), "parentid", parentid);
 
192
    }
 
193
 
 
194
    katze_item_set_meta_integer(search, "id", parentid);
 
195
 
 
196
    parent = KATZE_ARRAY (g_hash_table_lookup (bookmarks->all_items, search));
 
197
 
 
198
    g_object_unref (search);
 
199
 
 
200
    if (!parent)
190
201
    {
191
202
        parent = KATZE_ARRAY (bookmarks);
 
203
        katze_item_set_meta_integer (KATZE_ITEM (item), "parentid",
 
204
            katze_item_get_meta_integer (KATZE_ITEM (bookmarks), "id"));
192
205
    }
193
206
    else
194
207
    {
267
280
 
268
281
    g_return_if_fail (parent);
269
282
 
270
 
    katze_array_update (parent);
 
283
    if (IS_MIDORI_BOOKMARKS_DB (parent))
 
284
        KATZE_ARRAY_CLASS (midori_bookmarks_db_parent_class)->update (parent);
 
285
    else
 
286
        katze_array_update (parent);
271
287
}
272
288
 
273
289
/**
710
726
    g_return_val_if_fail (errmsg != NULL, NULL);
711
727
 
712
728
    database = midori_bookmarks_database_new (&error);
713
 
    
 
729
 
714
730
    if (error != NULL)
715
731
    {
716
732
        *errmsg = g_strdup (error->message);
724
740
    if (midori_debug ("bookmarks"))
725
741
        sqlite3_trace (db, midori_bookmarks_db_dbtracer, NULL);
726
742
 
727
 
    bookmarks = MIDORI_BOOKMARKS_DB (g_object_new (TYPE_MIDORI_BOOKMARKS_DB, NULL));
 
743
    bookmarks = MIDORI_BOOKMARKS_DB (g_object_new (TYPE_MIDORI_BOOKMARKS_DB,
 
744
            "type", KATZE_TYPE_ITEM,
 
745
            NULL));
728
746
    bookmarks->db = db;
729
747
 
730
748
    g_object_set_data (G_OBJECT (bookmarks), "db", db);
1097
1115
                                                      value, id,
1098
1116
                                                      recursive);
1099
1117
}
 
1118
 
 
1119
/**
 
1120
 * midori_bookmarks_db_populate_folder:
 
1121
 **/
 
1122
 
 
1123
void
 
1124
midori_bookmarks_db_populate_folder (MidoriBookmarksDb* bookmarks,
 
1125
    KatzeArray *folder)
 
1126
{
 
1127
    const gchar* id = katze_item_get_meta_string (KATZE_ITEM (folder), "id");
 
1128
    const gchar *condition;
 
1129
    KatzeArray* array;
 
1130
    KatzeItem* item;
 
1131
    GList* list;
 
1132
 
 
1133
    if (id == NULL)
 
1134
    {
 
1135
        condition = "parentid is NULL";
 
1136
    }
 
1137
    else
 
1138
    {
 
1139
        condition = "parentid = %q";
 
1140
    }
 
1141
 
 
1142
    array = midori_bookmarks_db_query_recursive (bookmarks,
 
1143
        "id, title, parentid, uri, app, pos_panel, pos_bar", condition, id, FALSE);
 
1144
 
 
1145
    if (IS_MIDORI_BOOKMARKS_DB (folder))
 
1146
    {
 
1147
        KATZE_ARRAY_FOREACH_ITEM_L (item, folder, list)
 
1148
        {
 
1149
            KATZE_ARRAY_CLASS (midori_bookmarks_db_parent_class)->remove_item (folder, item);
 
1150
        }
 
1151
 
 
1152
        KATZE_ARRAY_FOREACH_ITEM_L (item, array, list)
 
1153
        {
 
1154
            KATZE_ARRAY_CLASS (midori_bookmarks_db_parent_class)->add_item (folder, item);
 
1155
        }
 
1156
    }
 
1157
    else
 
1158
    {
 
1159
        katze_array_clear(folder);
 
1160
 
 
1161
        KATZE_ARRAY_FOREACH_ITEM_L (item, array, list)
 
1162
        {
 
1163
            katze_array_add_item (folder, item);
 
1164
        }
 
1165
    }
 
1166
 
 
1167
    g_object_unref (array);
 
1168
}