diff options
-rw-r--r-- | ChangeLog | 35 | ||||
-rwxr-xr-x | lib/widgets/ephy-editable-toolbar.c | 81 | ||||
-rwxr-xr-x | lib/widgets/ephy-toolbars-group.c | 51 | ||||
-rwxr-xr-x | src/toolbar.c | 15 |
4 files changed, 172 insertions, 10 deletions
@@ -1,5 +1,40 @@ 2003-02-21 Marco Pesenti Gritti <marco@it.gnome.org> + * lib/widgets/ephy-editable-toolbar.c: (find_action), + (impl_get_action), (ui_update), (queue_ui_update), + (drag_data_received_cb), (drag_data_delete_cb), (drag_data_get_cb), + (connect_item_drag_source), (disconnect_item_drag_source), + (setup_toolbar), (setup_item), (ensure_toolbar_min_size), + (do_merge), (ensure_action), (group_changed_cb), + (ephy_editable_toolbar_set_group), + (ephy_editable_toolbar_set_merge), (hide_editor), + (editor_close_cb), (editor_add_toolbar_cb), + (editor_drag_data_received_cb), (editor_drag_data_delete_cb), + (setup_editor), (add_to_list), (update_editor_sheet), + (update_editor_position), (button_press_cb), (show_editor), + (set_action_sensitive), (ephy_editable_toolbar_edit): + * lib/widgets/ephy-toolbars-group.c: (ephy_toolbars_group_to_xml), + (toolbars_group_save), (toolbars_item_new), (free_toolbar_node), + (free_item_node), (ephy_toolbars_group_add_item), + (ephy_toolbars_group_add_toolbar), (load_defaults), (load_toolbar), + (ephy_toolbars_group_to_string), + (ephy_toolbars_group_remove_toolbar), + (ephy_toolbars_group_remove_item), + (ephy_toolbars_group_set_source), (is_item_in_toolbars), + (ephy_toolbars_group_foreach_available), + (ephy_toolbars_group_foreach_toolbar), + (ephy_toolbars_group_foreach_item), (ephy_toolbars_group_get_path): + * src/toolbar.c: (toolbar_get_action): + + Add lots of debug code to solve these damned crashes. + Dont create multiple actions for the same bookmark. + There are two crashes that I can repro now. 1 Adding bookmarks + with more then one toolbar opened, and then open tbe. + 2 Add multiple "links" to the same bookmark and then close. + But I'm sure xan can find more ;) + +2003-02-21 Marco Pesenti Gritti <marco@it.gnome.org> + * lib/widgets/ephy-autocompletion-window.c: (hack_tree_view_move_selection): diff --git a/lib/widgets/ephy-editable-toolbar.c b/lib/widgets/ephy-editable-toolbar.c index c8b2d9f9e..bb3288805 100755 --- a/lib/widgets/ephy-editable-toolbar.c +++ b/lib/widgets/ephy-editable-toolbar.c @@ -122,6 +122,9 @@ find_action (EphyEditableToolbar *t, const char *name) GList *l = t->priv->merge->action_groups; EggAction *action = NULL; + g_return_val_if_fail (IS_EPHY_EDITABLE_TOOLBAR (t), NULL); + g_return_val_if_fail (name != NULL, NULL); + for (; l != NULL; l = l->next) { EggAction *tmp; @@ -141,6 +144,8 @@ impl_get_action (EphyEditableToolbar *etoolbar, { EggAction *action; + g_return_val_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar), NULL); + if (type == NULL) { action = find_action (etoolbar, name); @@ -158,6 +163,8 @@ ui_update (gpointer data) { EphyEditableToolbar *etoolbar = EPHY_EDITABLE_TOOLBAR (data); + g_return_val_if_fail (etoolbar != NULL, FALSE); + if (etoolbar->priv->toolbars_dirty) { LOG ("Update ui: toolbars") @@ -185,6 +192,8 @@ ui_update (gpointer data) static void queue_ui_update (EphyEditableToolbar *etoolbar) { + g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar)); + g_idle_add (ui_update, etoolbar); } @@ -205,11 +214,14 @@ drag_data_received_cb (GtkWidget *widget, GdkAtom target; EggAction *action; + g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar)); + toolbar = (EphyToolbarsToolbar *)g_object_get_data (G_OBJECT (widget), "toolbar_data"); if (!toolbar) { sibling = (EphyToolbarsItem *)g_object_get_data (G_OBJECT (widget), "item_data"); + g_return_if_fail (sibling != NULL); parent = sibling->parent; } else @@ -218,6 +230,8 @@ drag_data_received_cb (GtkWidget *widget, parent = toolbar; } + g_return_if_fail (parent != NULL); + target = gtk_drag_dest_find_target (widget, context, NULL); if (target == gdk_atom_intern (EPHY_DND_URL_TYPE, FALSE)) { @@ -229,7 +243,6 @@ drag_data_received_cb (GtkWidget *widget, { ephy_toolbars_group_add_item (etoolbar->priv->group, parent, sibling, action->name); - etoolbar->priv->toolbars_dirty = TRUE; queue_ui_update (etoolbar); } @@ -242,7 +255,10 @@ drag_data_delete_cb (GtkWidget *widget, { EphyToolbarsItem *node; + g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar)); + node = (EphyToolbarsItem *)g_object_get_data (G_OBJECT (widget), "item_data"); + g_return_if_fail (node != NULL); ephy_toolbars_group_remove_item (etoolbar->priv->group, node); etoolbar->priv->toolbars_dirty = TRUE; @@ -260,6 +276,8 @@ drag_data_get_cb (GtkWidget *widget, EggAction *action; const char *target; + g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar)); + action = EGG_ACTION (g_object_get_data (G_OBJECT (widget), "egg-action")); target = action->name; @@ -275,6 +293,9 @@ connect_item_drag_source (EphyToolbarsItem *item, EphyEditableToolbar *etoolbar) { GtkWidget *toolitem; + g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar)); + g_return_if_fail (item != NULL); + toolitem = item->widget; if (!g_object_get_data (G_OBJECT (toolitem), "drag_source_set")) @@ -296,6 +317,9 @@ disconnect_item_drag_source (EphyToolbarsItem *item, EphyEditableToolbar *etoolb { GtkWidget *toolitem; + g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar)); + g_return_if_fail (item != NULL); + toolitem = item->widget; if (g_object_get_data (G_OBJECT (toolitem), "drag_source_set")) @@ -318,10 +342,15 @@ setup_toolbar (EphyToolbarsToolbar *toolbar, EphyEditableToolbar *etoolbar) GtkWidget *widget; char *path; + g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar)); + g_return_if_fail (toolbar != NULL); + path = ephy_toolbars_group_get_path (etoolbar->priv->group, toolbar); + g_return_if_fail (path != NULL); widget = egg_menu_merge_get_widget (etoolbar->priv->merge, path); g_object_set_data (G_OBJECT (widget), "toolbar_data", toolbar); + g_return_if_fail (toolbar != NULL); toolbar->widget = widget; if (!g_object_get_data (G_OBJECT (widget), "drag_dest_set")) @@ -348,9 +377,14 @@ setup_item (EphyToolbarsItem *item, EphyEditableToolbar *etoolbar) GtkWidget *toolitem; char *path; + g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar)); + g_return_if_fail (item != NULL); + path = ephy_toolbars_group_get_path (etoolbar->priv->group, item); + g_return_if_fail (path != NULL); toolitem = egg_menu_merge_get_widget (etoolbar->priv->merge, path); + g_return_if_fail (toolitem != NULL); item->widget = toolitem; g_object_set_data (G_OBJECT (toolitem), "item_data", item); @@ -377,6 +411,9 @@ ensure_toolbar_min_size (EphyToolbarsToolbar *toolbar, EphyEditableToolbar *t) { GtkWidget *widget; + g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (t)); + g_return_if_fail (toolbar != NULL); + widget = toolbar->widget; if (EGG_TOOLBAR (widget)->num_children == 0) @@ -395,9 +432,10 @@ do_merge (EphyEditableToolbar *t) char *str; guint ui_id; - g_return_if_fail (t != NULL); + g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (t)); str = ephy_toolbars_group_to_string (t->priv->group); + g_return_if_fail (str != NULL); LOG ("Merge UI\n%s", str) @@ -440,12 +478,18 @@ do_merge (EphyEditableToolbar *t) static void ensure_action (EphyToolbarsItem *item, EphyEditableToolbar *t) { + g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (t)); + g_return_if_fail (item != NULL); + ephy_editable_toolbar_get_action (t, NULL, item->action); } static void group_changed_cb (EphyToolbarsGroup *group, EphyEditableToolbar *t) { + g_return_if_fail (IS_EPHY_TOOLBARS_GROUP (group)); + g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (t)); + t->priv->toolbars_dirty = TRUE; ephy_toolbars_group_foreach_item (t->priv->group, @@ -458,6 +502,9 @@ group_changed_cb (EphyToolbarsGroup *group, EphyEditableToolbar *t) static void ephy_editable_toolbar_set_group (EphyEditableToolbar *t, EphyToolbarsGroup *group) { + g_return_if_fail (IS_EPHY_TOOLBARS_GROUP (group)); + g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (t)); + t->priv->group = group; g_signal_connect (group, "changed", @@ -468,6 +515,9 @@ ephy_editable_toolbar_set_group (EphyEditableToolbar *t, EphyToolbarsGroup *grou static void ephy_editable_toolbar_set_merge (EphyEditableToolbar *t, EggMenuMerge *merge) { + g_return_if_fail (EGG_IS_MENU_MERGE (merge)); + g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (t)); + t->priv->merge = merge; LOG ("Got MenuMerge") @@ -663,6 +713,8 @@ editor_get_dimensions (EphyEditableToolbar *etoolbar, GtkWidget *toolbar, static void hide_editor (EphyEditableToolbar *etoolbar) { + g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar)); + gtk_grab_remove (GTK_WIDGET (etoolbar->priv->editor)); gtk_widget_hide (GTK_WIDGET (etoolbar->priv->editor)); } @@ -670,6 +722,8 @@ hide_editor (EphyEditableToolbar *etoolbar) static void editor_close_cb (GtkWidget *button, EphyEditableToolbar *etoolbar) { + g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar)); + etoolbar->priv->edit_mode = FALSE; ephy_toolbars_group_foreach_item (etoolbar->priv->group, (EphyToolbarsGroupForeachItemFunc) @@ -681,6 +735,8 @@ editor_close_cb (GtkWidget *button, EphyEditableToolbar *etoolbar) static void editor_add_toolbar_cb (GtkWidget *button, EphyEditableToolbar *etoolbar) { + g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar)); + ephy_toolbars_group_add_toolbar (etoolbar->priv->group); etoolbar->priv->toolbars_dirty = TRUE; @@ -698,6 +754,8 @@ editor_drag_data_received_cb (GtkWidget *widget, guint time_, EphyEditableToolbar *etoolbar) { + g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar)); + etoolbar->priv->editor_sheet_dirty = TRUE; etoolbar->priv->editor_pos_dirty = TRUE; queue_ui_update (etoolbar); @@ -708,6 +766,8 @@ editor_drag_data_delete_cb (GtkWidget *widget, GdkDragContext *context, EphyEditableToolbar *etoolbar) { + g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar)); + etoolbar->priv->editor_sheet_dirty = TRUE; etoolbar->priv->editor_pos_dirty = TRUE; queue_ui_update (etoolbar); @@ -726,6 +786,8 @@ setup_editor (EphyEditableToolbar *etoolbar) GtkWidget *button; GtkWidget *frame; + g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar)); + editor = gtk_window_new (GTK_WINDOW_POPUP); etoolbar->priv->editor = editor; frame = gtk_frame_new (NULL); @@ -783,6 +845,8 @@ setup_editor (EphyEditableToolbar *etoolbar) static void add_to_list (EphyToolbarsItem *item, GList **l) { + g_return_if_fail (item != NULL); + *l = g_list_append (*l, item); } @@ -795,6 +859,8 @@ update_editor_sheet (EphyEditableToolbar *etoolbar) GtkWidget *table; GtkWidget *viewport; + g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar)); + viewport = GTK_BIN (etoolbar->priv->scrolled_window)->child; if (viewport) { @@ -835,6 +901,7 @@ update_editor_sheet (EphyEditableToolbar *etoolbar) action = ephy_editable_toolbar_get_action (etoolbar, NULL, node->action); + g_return_if_fail (action != NULL); event_box = gtk_event_box_new (); gtk_widget_show (event_box); @@ -885,6 +952,8 @@ update_editor_position (EphyEditableToolbar *etoolbar) GtkWidget *editor; int x, y, height, width; + g_return_val_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar), FALSE); + editor_get_dimensions (etoolbar, etoolbar->priv->last_toolbar, &x, &y, &width, &height); editor = etoolbar->priv->editor; @@ -904,6 +973,8 @@ button_press_cb (GtkWidget *w, GtkWidget *widget; GtkWidget *toolitem; + g_return_val_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar), FALSE); + widget = gtk_get_event_widget (event); toolitem = gtk_widget_get_ancestor (widget, EGG_TYPE_TOOL_ITEM); @@ -928,6 +999,7 @@ show_editor (EphyEditableToolbar *etoolbar) { GtkWidget *editor = etoolbar->priv->editor; + g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar)); g_return_if_fail (editor != NULL); gtk_widget_show (GTK_WIDGET (editor)); @@ -943,6 +1015,9 @@ set_action_sensitive (EphyToolbarsItem *item, EphyEditableToolbar *etoolbar) { EggAction *action; + g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar)); + g_return_if_fail (item != NULL); + if (!item->separator) { action = find_action (etoolbar, item->action); @@ -953,6 +1028,8 @@ set_action_sensitive (EphyToolbarsItem *item, EphyEditableToolbar *etoolbar) void ephy_editable_toolbar_edit (EphyEditableToolbar *etoolbar) { + g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar)); + etoolbar->priv->edit_mode = TRUE; ephy_toolbars_group_foreach_item (etoolbar->priv->group, (EphyToolbarsGroupForeachItemFunc) diff --git a/lib/widgets/ephy-toolbars-group.c b/lib/widgets/ephy-toolbars-group.c index 753aca4a1..e923044f1 100755 --- a/lib/widgets/ephy-toolbars-group.c +++ b/lib/widgets/ephy-toolbars-group.c @@ -79,6 +79,8 @@ ephy_toolbars_group_to_xml (EphyToolbarsGroup *t) GNode *l1, *l2, *tl; xmlDocPtr doc; + g_return_val_if_fail (IS_EPHY_TOOLBARS_GROUP (t), NULL); + tl = t->priv->toolbars; xmlIndentTreeOutput = TRUE; @@ -116,6 +118,8 @@ toolbars_group_save (EphyToolbarsGroup *t) { xmlDocPtr doc; + g_return_if_fail (IS_EPHY_TOOLBARS_GROUP (t)); + doc = ephy_toolbars_group_to_xml (t); xmlSaveFormatFile (t->priv->user, doc, 1); xmlFreeDoc (doc); @@ -137,6 +141,8 @@ toolbars_item_new (const char *action, gboolean separator) { EphyToolbarsItem *item; + g_return_val_if_fail (action != NULL, NULL); + item = g_new0 (EphyToolbarsItem, 1); item->action = g_strdup (action); item->separator = separator; @@ -148,12 +154,16 @@ toolbars_item_new (const char *action, gboolean separator) static void free_toolbar_node (EphyToolbarsToolbar *toolbar) { + g_return_if_fail (toolbar != NULL); + g_free (toolbar); } static void free_item_node (EphyToolbarsItem *item) { + g_return_if_fail (item != NULL); + g_free (item->action); g_free (item); } @@ -187,12 +197,17 @@ ephy_toolbars_group_add_item (EphyToolbarsGroup *t, GNode *parent_node; GNode *sibling_node = NULL; + g_return_if_fail (IS_EPHY_TOOLBARS_GROUP (t)); + g_return_if_fail (parent != NULL); + g_return_if_fail (name != NULL); + parent_node = g_node_find (t->priv->toolbars, G_IN_ORDER, G_TRAVERSE_ALL, parent); if (sibling) { sibling_node = g_node_find (t->priv->toolbars, G_IN_ORDER, G_TRAVERSE_ALL, sibling); + g_return_if_fail (sibling_node != NULL); } add_action (t, parent_node, sibling_node, name); @@ -245,7 +260,10 @@ ephy_toolbars_group_add_toolbar (EphyToolbarsGroup *t) { GNode *node; + g_return_val_if_fail (IS_EPHY_TOOLBARS_GROUP (t), NULL); + node = add_toolbar (t); + g_return_val_if_fail (node != NULL, NULL); toolbars_group_save (t); @@ -280,6 +298,8 @@ load_defaults (EphyToolbarsGroup *t) xmlNodePtr root; const char *xml_filepath; + g_return_if_fail (IS_EPHY_TOOLBARS_GROUP (t)); + LOG ("Load default toolbar info") xml_filepath = t->priv->defaults; @@ -314,6 +334,8 @@ load_toolbar (EphyToolbarsGroup *t) xmlNodePtr root; const char *xml_filepath = t->priv->user; + g_return_if_fail (IS_EPHY_TOOLBARS_GROUP (t)); + LOG ("Load custom toolbar") if (!g_file_test (xml_filepath, G_FILE_TEST_EXISTS)) return; @@ -333,8 +355,12 @@ ephy_toolbars_group_to_string (EphyToolbarsGroup *t) char *result; int k = 0; + g_return_val_if_fail (IS_EPHY_TOOLBARS_GROUP (t), NULL); + tl = t->priv->toolbars; + g_return_val_if_fail (tl != NULL, NULL); + s = g_string_new (NULL); g_string_append (s, "<Root>"); for (l1 = tl->children; l1 != NULL; l1 = l1->next) @@ -455,7 +481,11 @@ ephy_toolbars_group_remove_toolbar (EphyToolbarsGroup *t, { GNode *node; + g_return_if_fail (IS_EPHY_TOOLBARS_GROUP (t)); + g_return_if_fail (toolbar != NULL); + node = g_node_find (t->priv->toolbars, G_IN_ORDER, G_TRAVERSE_ALL, toolbar); + g_return_if_fail (node != NULL); free_toolbar_node (node->data); g_node_destroy (node); @@ -470,7 +500,11 @@ ephy_toolbars_group_remove_item (EphyToolbarsGroup *t, { GNode *node; + g_return_if_fail (IS_EPHY_TOOLBARS_GROUP (t)); + g_return_if_fail (item != NULL); + node = g_node_find (t->priv->toolbars, G_IN_ORDER, G_TRAVERSE_ALL, item); + g_return_if_fail (node != NULL); free_toolbar_node (node->data); g_node_destroy (node); @@ -484,6 +518,10 @@ ephy_toolbars_group_set_source (EphyToolbarsGroup *group, const char *defaults, const char *user) { + g_return_if_fail (IS_EPHY_TOOLBARS_GROUP (group)); + g_return_if_fail (defaults != NULL); + g_return_if_fail (user != NULL); + group->priv->defaults = g_strdup (defaults); group->priv->user = g_strdup (user); @@ -496,6 +534,9 @@ is_item_in_toolbars (EphyToolbarsGroup *group, const char *action) { GNode *l1, *l2; + g_return_val_if_fail (IS_EPHY_TOOLBARS_GROUP (group), FALSE); + g_return_val_if_fail (action != NULL, FALSE); + for (l1 = group->priv->toolbars->children; l1 != NULL; l1 = l1->next) { for (l2 = l1->children; l2 != NULL; l2 = l2->next) @@ -517,6 +558,8 @@ ephy_toolbars_group_foreach_available (EphyToolbarsGroup *group, { GNode *l1; + g_return_if_fail (IS_EPHY_TOOLBARS_GROUP (group)); + for (l1 = group->priv->available_actions->children; l1 != NULL; l1 = l1->next) { EphyToolbarsItem *item; @@ -537,6 +580,8 @@ ephy_toolbars_group_foreach_toolbar (EphyToolbarsGroup *group, { GNode *l1; + g_return_if_fail (IS_EPHY_TOOLBARS_GROUP (group)); + for (l1 = group->priv->toolbars->children; l1 != NULL; l1 = l1->next) { func (l1->data, data); @@ -550,6 +595,8 @@ ephy_toolbars_group_foreach_item (EphyToolbarsGroup *group, { GNode *l1, *l2; + g_return_if_fail (IS_EPHY_TOOLBARS_GROUP (group)); + for (l1 = group->priv->toolbars->children; l1 != NULL; l1 = l1->next) { for (l2 = l1->children; l2 != NULL; l2 = l2->next) @@ -567,7 +614,10 @@ ephy_toolbars_group_get_path (EphyToolbarsGroup *t, char *path = NULL; EphyToolbarsItem *titem; + g_return_val_if_fail (IS_EPHY_TOOLBARS_GROUP (t), NULL); + node = g_node_find (t->priv->toolbars, G_IN_ORDER, G_TRAVERSE_ALL, item); + g_return_val_if_fail (node != NULL, NULL); titem = (EphyToolbarsItem *)node->data; switch (g_node_depth (node)) @@ -591,4 +641,3 @@ ephy_toolbars_group_get_path (EphyToolbarsGroup *t, return path; } - diff --git a/src/toolbar.c b/src/toolbar.c index 5929d718a..eecac5c11 100755 --- a/src/toolbar.c +++ b/src/toolbar.c @@ -184,13 +184,6 @@ toolbar_get_action (EphyEditableToolbar *etoolbar, g_list_foreach (uris, (GFunc)g_free, NULL); g_list_free (uris); } - else if (g_str_has_prefix (name, "GoBookmarkId")) - { - if (ephy_str_to_int (name + strlen ("GoBookmarkId"), &id)) - { - action = get_bookmark_action (t, bookmarks, id); - } - } if (action == NULL) { @@ -198,6 +191,14 @@ toolbar_get_action (EphyEditableToolbar *etoolbar, (parent_class)->get_action (etoolbar, type, name); } + if (action == NULL && g_str_has_prefix (name, "GoBookmarkId")) + { + if (ephy_str_to_int (name + strlen ("GoBookmarkId"), &id)) + { + action = get_bookmark_action (t, bookmarks, id); + } + } + return action; } |