diff options
-rw-r--r-- | ChangeLog | 23 | ||||
-rw-r--r-- | lib/widgets/ephy-node-view.c | 19 | ||||
-rw-r--r-- | lib/widgets/ephy-node-view.h | 82 | ||||
-rw-r--r-- | lib/widgets/ephy-tree-model-sort.c | 51 | ||||
-rw-r--r-- | lib/widgets/ephy-tree-model-sort.h | 10 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmark-action.c | 11 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarks-editor.c | 37 | ||||
-rw-r--r-- | src/bookmarks/ephy-topics-selector.c | 2 | ||||
-rw-r--r-- | src/ephy-encoding-dialog.c | 2 | ||||
-rw-r--r-- | src/ephy-history-window.c | 52 |
10 files changed, 174 insertions, 115 deletions
@@ -1,3 +1,26 @@ +2005-01-21 Jorn Baayen <jbaayen@gnome.org> + + * lib/widgets/ephy-node-view.c: (ephy_node_view_add_column), + (ephy_node_view_enable_drag_source): + * lib/widgets/ephy-node-view.h: + * lib/widgets/ephy-tree-model-sort.c: (ephy_tree_model_sort_init), + (ephy_tree_model_sort_multi_row_draggable), + (ephy_tree_model_sort_set_base_drag_column_id), + (ephy_tree_model_sort_set_extra_drag_column_id), + (each_property_get_data_binder): + * lib/widgets/ephy-tree-model-sort.h: + * src/bookmarks/ephy-bookmark-action.c: (drag_data_get_cb): + * src/bookmarks/ephy-bookmarks-editor.c: + (ephy_bookmarks_editor_construct): + * src/bookmarks/ephy-topics-selector.c: + (ephy_topics_selector_constructor): + * src/ephy-encoding-dialog.c: (ephy_encoding_dialog_init): + * src/ephy-history-window.c: (ephy_history_window_construct): + + Add proper _NETSCAPE_URL drag support, supplying the URL as well as + the title. As a side effect most data_columns in NodeViews have been + obsoleted. Fixes #163937. + 2005-01-20 Adam Hooper <adamh@cvs.gnome.org> * src/ephy-statusbar.c: (ephy_statusbar_add_widget), diff --git a/lib/widgets/ephy-node-view.c b/lib/widgets/ephy-node-view.c index 5f01667d7..9a4291bdc 100644 --- a/lib/widgets/ephy-node-view.c +++ b/lib/widgets/ephy-node-view.c @@ -1158,13 +1158,14 @@ ephy_node_view_add_data_column (EphyNodeView *view, return column; } -GtkTreeViewColumn * +int ephy_node_view_add_column (EphyNodeView *view, const char *title, GType value_type, guint prop_id, EphyNodeViewFlags flags, - EphyTreeModelNodeValueFunc icon_func) + EphyTreeModelNodeValueFunc icon_func, + GtkTreeViewColumn **ret) { GtkTreeViewColumn *gcolumn; @@ -1236,7 +1237,10 @@ ephy_node_view_add_column (EphyNodeView *view, gtk_tree_view_column_set_sort_column_id (gcolumn, column); } - return gcolumn; + if (ret != NULL) + *ret = gcolumn; + + return column; } void @@ -1409,7 +1413,8 @@ void ephy_node_view_enable_drag_source (EphyNodeView *view, GtkTargetEntry *types, int n_types, - int column) + int base_drag_column, + int extra_drag_column) { GtkWidget *treeview; @@ -1420,8 +1425,10 @@ ephy_node_view_enable_drag_source (EphyNodeView *view, view->priv->source_target_list = gtk_target_list_new (types, n_types); - ephy_tree_model_sort_set_column_id (EPHY_TREE_MODEL_SORT (view->priv->sortmodel), - column); + ephy_tree_model_sort_set_base_drag_column_id (EPHY_TREE_MODEL_SORT (view->priv->sortmodel), + base_drag_column); + ephy_tree_model_sort_set_extra_drag_column_id (EPHY_TREE_MODEL_SORT (view->priv->sortmodel), + extra_drag_column); g_signal_connect_object (G_OBJECT (view), "button_release_event", diff --git a/lib/widgets/ephy-node-view.h b/lib/widgets/ephy-node-view.h index d5a4590eb..dab2f6da8 100644 --- a/lib/widgets/ephy-node-view.h +++ b/lib/widgets/ephy-node-view.h @@ -71,61 +71,63 @@ typedef struct void (*node_dropped) (EphyNodeView *view, EphyNode *node, GList *uris); } EphyNodeViewClass; -GType ephy_node_view_get_type (void); +GType ephy_node_view_get_type (void); -GtkWidget *ephy_node_view_new (EphyNode *root, - EphyNodeFilter *filter); +GtkWidget *ephy_node_view_new (EphyNode *root, + EphyNodeFilter *filter); -void ephy_node_view_enable_dnd (EphyNodeView *view); +void ephy_node_view_enable_dnd (EphyNodeView *view); -void ephy_node_view_add_toggle (EphyNodeView *view, - EphyTreeModelNodeValueFunc value_func, - gpointer data); +void ephy_node_view_add_toggle (EphyNodeView *view, + EphyTreeModelNodeValueFunc value_func, + gpointer data); -GtkTreeViewColumn *ephy_node_view_add_column (EphyNodeView *view, - const char *title, - GType value_type, - guint prop_id, - EphyNodeViewFlags flags, - EphyTreeModelNodeValueFunc icon_func); +int ephy_node_view_add_column (EphyNodeView *view, + const char *title, + GType value_type, + guint prop_id, + EphyNodeViewFlags flags, + EphyTreeModelNodeValueFunc icon_func, + GtkTreeViewColumn **column); -int ephy_node_view_add_data_column (EphyNodeView *view, - GType value_type, - guint prop_id, - EphyTreeModelNodeValueFunc func, - gpointer data); +int ephy_node_view_add_data_column (EphyNodeView *view, + GType value_type, + guint prop_id, + EphyTreeModelNodeValueFunc func, + gpointer data); -void ephy_node_view_set_sort (EphyNodeView *view, - GType value_type, - guint prop_id, - GtkSortType sort_type); +void ephy_node_view_set_sort (EphyNodeView *view, + GType value_type, + guint prop_id, + GtkSortType sort_type); -void ephy_node_view_set_priority (EphyNodeView *view, - guint priority_prop_id); +void ephy_node_view_set_priority (EphyNodeView *view, + guint priority_prop_id); -void ephy_node_view_remove (EphyNodeView *view); +void ephy_node_view_remove (EphyNodeView *view); -GList *ephy_node_view_get_selection (EphyNodeView *view); +GList *ephy_node_view_get_selection (EphyNodeView *view); -void ephy_node_view_select_node (EphyNodeView *view, - EphyNode *node); +void ephy_node_view_select_node (EphyNodeView *view, + EphyNode *node); -void ephy_node_view_enable_drag_source (EphyNodeView *view, - GtkTargetEntry *types, - int n_types, - int column_id); +void ephy_node_view_enable_drag_source (EphyNodeView *view, + GtkTargetEntry *types, + int n_types, + int base_drag_column_id, + int extra_drag_column_id); -void ephy_node_view_enable_drag_dest (EphyNodeView *view, - GtkTargetEntry *types, - int n_types); +void ephy_node_view_enable_drag_dest (EphyNodeView *view, + GtkTargetEntry *types, + int n_types); -void ephy_node_view_edit (EphyNodeView *view, - gboolean remove_if_cancelled); +void ephy_node_view_edit (EphyNodeView *view, + gboolean remove_if_cancelled); -gboolean ephy_node_view_is_target (EphyNodeView *view); +gboolean ephy_node_view_is_target (EphyNodeView *view); -void ephy_node_view_popup (EphyNodeView *view, - GtkWidget *menu); +void ephy_node_view_popup (EphyNodeView *view, + GtkWidget *menu); G_END_DECLS diff --git a/lib/widgets/ephy-tree-model-sort.c b/lib/widgets/ephy-tree-model-sort.c index c20af59d0..1c9ae1e4f 100644 --- a/lib/widgets/ephy-tree-model-sort.c +++ b/lib/widgets/ephy-tree-model-sort.c @@ -48,7 +48,8 @@ static gboolean ephy_tree_model_sort_multi_drag_data_delete (EggTreeMultiDragSou struct _EphyTreeModelSortPrivate { char *str_list; - int drag_column_id; + int base_drag_column_id; + int extra_drag_column_id; }; static GObjectClass *parent_class = NULL; @@ -108,7 +109,8 @@ ephy_tree_model_sort_init (EphyTreeModelSort *ma) { ma->priv = EPHY_TREE_MODEL_SORT_GET_PRIVATE (ma); - ma->priv->drag_column_id = -1; + ma->priv->base_drag_column_id = -1; + ma->priv->extra_drag_column_id = -1; } static void @@ -146,14 +148,21 @@ ephy_tree_model_sort_multi_drag_source_init (EggTreeMultiDragSourceIface *iface) static gboolean ephy_tree_model_sort_multi_row_draggable (EggTreeMultiDragSource *drag_source, GList *path_list) { - return (EPHY_TREE_MODEL_SORT (drag_source)->priv->drag_column_id > 0); + return (EPHY_TREE_MODEL_SORT (drag_source)->priv->base_drag_column_id >= 0); } void -ephy_tree_model_sort_set_column_id (EphyTreeModelSort *ms, - int id) +ephy_tree_model_sort_set_base_drag_column_id (EphyTreeModelSort *ms, + int id) { - ms->priv->drag_column_id = id; + ms->priv->base_drag_column_id = id; +} + +void +ephy_tree_model_sort_set_extra_drag_column_id (EphyTreeModelSort *ms, + int id) +{ + ms->priv->extra_drag_column_id = id; } static gboolean @@ -171,29 +180,41 @@ each_property_get_data_binder (EphyDragEachSelectedItemDataGet iteratee, GList *path_list = (GList *) (context[0]); GList *i; EphyTreeModelSort *model = EPHY_TREE_MODEL_SORT (context[1]); - GValue value = {0, }; + GValue base_value = {0, }, extra_value = {0, }; for (i = path_list; i != NULL; i = i->next) { GtkTreeIter iter; GtkTreePath *path = NULL; - const char *svalue; + const char *base_data, *extra_data; path = gtk_tree_row_reference_get_path (i->data); gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, path); + gtk_tree_model_get_value (GTK_TREE_MODEL (model), &iter, - model->priv->drag_column_id, - &value); - svalue = g_value_get_string (&value); + model->priv->base_drag_column_id, + &base_value); + base_data = g_value_get_string (&base_value); + + if (model->priv->extra_drag_column_id >= 0) { + gtk_tree_model_get_value (GTK_TREE_MODEL (model), &iter, + model->priv->extra_drag_column_id, + &extra_value); + extra_data = g_value_get_string (&extra_value); + } else + extra_data = NULL; - g_return_if_fail (svalue != NULL); + g_return_if_fail (base_data != NULL); - LOG ("Data get %s", svalue) + LOG ("Data get %s (%s)", base_data, extra_data) - iteratee (svalue, NULL, data); + iteratee (base_data, extra_data, data); gtk_tree_path_free (path); - g_value_unset (&value); + g_value_unset (&base_value); + + if (model->priv->extra_drag_column_id >= 0) + g_value_unset (&extra_value); } } diff --git a/lib/widgets/ephy-tree-model-sort.h b/lib/widgets/ephy-tree-model-sort.h index c24fc214b..d985b089d 100644 --- a/lib/widgets/ephy-tree-model-sort.h +++ b/lib/widgets/ephy-tree-model-sort.h @@ -50,12 +50,14 @@ typedef struct void (*node_from_iter) (EphyTreeModelSort *model, GtkTreeIter *iter, void **node); } EphyTreeModelSortClass; -GType ephy_tree_model_sort_get_type (void); +GType ephy_tree_model_sort_get_type (void); -GtkTreeModel *ephy_tree_model_sort_new (GtkTreeModel *child_model); +GtkTreeModel *ephy_tree_model_sort_new (GtkTreeModel *child_model); -void ephy_tree_model_sort_set_column_id (EphyTreeModelSort *ms, - int id); +void ephy_tree_model_sort_set_base_drag_column_id (EphyTreeModelSort *ms, + int id); +void ephy_tree_model_sort_set_extra_drag_column_id (EphyTreeModelSort *ms, + int id); G_END_DECLS diff --git a/src/bookmarks/ephy-bookmark-action.c b/src/bookmarks/ephy-bookmark-action.c index f219853d6..876c386f4 100644 --- a/src/bookmarks/ephy-bookmark-action.c +++ b/src/bookmarks/ephy-bookmark-action.c @@ -402,7 +402,8 @@ drag_data_get_cb (GtkWidget *widget, GdkDragContext *context, GtkSelectionData *selection_data, guint info, guint32 time, EphyBookmarkAction *action) { - const char *address; + const char *address, *title; + char *data; g_return_if_fail (action->priv->node != NULL); @@ -410,8 +411,14 @@ drag_data_get_cb (GtkWidget *widget, GdkDragContext *context, EPHY_NODE_BMK_PROP_LOCATION); g_return_if_fail (address != NULL); + title = ephy_node_get_property_string (action->priv->node, + EPHY_NODE_BMK_PROP_TITLE); + g_return_if_fail (title != NULL); + + data = g_strdup_printf ("%s\n%s", address, title); gtk_selection_data_set (selection_data, selection_data->target, 8, - (unsigned char *) address, strlen (address)); + (unsigned char *) data, strlen (data)); + g_free (data); } static int diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c index 550212608..4bc02e83d 100644 --- a/src/bookmarks/ephy-bookmarks-editor.c +++ b/src/bookmarks/ephy-bookmarks-editor.c @@ -1575,7 +1575,7 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor) EphyNode *node; GtkUIManager *ui_merge; GtkActionGroup *action_group; - int col_id, details_value; + int col_id, url_col_id, title_col_id, details_value; ephy_gui_ensure_window_group (GTK_WINDOW (editor)); @@ -1645,9 +1645,16 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor) col_id = ephy_node_view_add_data_column (EPHY_NODE_VIEW (key_view), G_TYPE_STRING, -1, provide_keyword_uri, editor); + ephy_node_view_add_column (EPHY_NODE_VIEW (key_view), _("Topics"), + G_TYPE_STRING, + EPHY_NODE_KEYWORD_PROP_NAME, + EPHY_NODE_VIEW_SHOW_PRIORITY | + EPHY_NODE_VIEW_EDITABLE | + EPHY_NODE_VIEW_SEARCHABLE, NULL, NULL); ephy_node_view_enable_drag_source (EPHY_NODE_VIEW (key_view), topic_drag_types, - n_topic_drag_types, col_id); + n_topic_drag_types, + col_id, -1); ephy_node_view_enable_drag_dest (EPHY_NODE_VIEW (key_view), topic_drag_dest_types, n_topic_drag_dest_types); @@ -1657,12 +1664,6 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor) "changed", G_CALLBACK (view_selection_changed_cb), editor); - ephy_node_view_add_column (EPHY_NODE_VIEW (key_view), _("Topics"), - G_TYPE_STRING, - EPHY_NODE_KEYWORD_PROP_NAME, - EPHY_NODE_VIEW_SHOW_PRIORITY | - EPHY_NODE_VIEW_EDITABLE | - EPHY_NODE_VIEW_SEARCHABLE, NULL); ephy_node_view_set_priority (EPHY_NODE_VIEW (key_view), EPHY_NODE_KEYWORD_PROP_PRIORITY); ephy_node_view_set_sort (EPHY_NODE_VIEW (key_view), G_TYPE_STRING, @@ -1713,24 +1714,20 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor) /* Bookmarks View */ bm_view = ephy_node_view_new (node, editor->priv->bookmarks_filter); add_focus_monitor (editor, bm_view); - col_id = ephy_node_view_add_data_column (EPHY_NODE_VIEW (bm_view), - G_TYPE_STRING, - EPHY_NODE_BMK_PROP_LOCATION, - NULL, NULL); - ephy_node_view_enable_drag_source (EPHY_NODE_VIEW (bm_view), - bmk_drag_types, - n_bmk_drag_types, - col_id); - editor->priv->title_col = ephy_node_view_add_column + title_col_id = ephy_node_view_add_column (EPHY_NODE_VIEW (bm_view), _("Title"), G_TYPE_STRING, EPHY_NODE_BMK_PROP_TITLE, EPHY_NODE_VIEW_EDITABLE | EPHY_NODE_VIEW_SEARCHABLE, - provide_favicon); - editor->priv->address_col = ephy_node_view_add_column + provide_favicon, &(editor->priv->title_col)); + url_col_id = ephy_node_view_add_column (EPHY_NODE_VIEW (bm_view), _("Address"), G_TYPE_STRING, EPHY_NODE_BMK_PROP_LOCATION, - 0, NULL); + 0, NULL, &(editor->priv->address_col)); + ephy_node_view_enable_drag_source (EPHY_NODE_VIEW (bm_view), + bmk_drag_types, + n_bmk_drag_types, + url_col_id, title_col_id); ephy_node_view_set_sort (EPHY_NODE_VIEW (bm_view), G_TYPE_STRING, EPHY_NODE_BMK_PROP_TITLE, GTK_SORT_ASCENDING); gtk_container_add (GTK_CONTAINER (scrolled_window), bm_view); diff --git a/src/bookmarks/ephy-topics-selector.c b/src/bookmarks/ephy-topics-selector.c index 6e16946ab..57cee2cd0 100644 --- a/src/bookmarks/ephy-topics-selector.c +++ b/src/bookmarks/ephy-topics-selector.c @@ -200,7 +200,7 @@ ephy_topics_selector_constructor (GType type, EPHY_NODE_KEYWORD_PROP_NAME, EPHY_NODE_VIEW_SHOW_PRIORITY | EPHY_NODE_VIEW_EDITABLE | - EPHY_NODE_VIEW_SEARCHABLE, NULL); + EPHY_NODE_VIEW_SEARCHABLE, NULL, NULL); ephy_node_view_set_sort (EPHY_NODE_VIEW (selector), G_TYPE_STRING, EPHY_NODE_KEYWORD_PROP_NAME, GTK_SORT_ASCENDING); diff --git a/src/ephy-encoding-dialog.c b/src/ephy-encoding-dialog.c index 2e3a301eb..8d9f1cb71 100644 --- a/src/ephy-encoding-dialog.c +++ b/src/ephy-encoding-dialog.c @@ -311,7 +311,7 @@ ephy_encoding_dialog_init (EphyEncodingDialog *dialog) G_TYPE_STRING, EPHY_NODE_ENCODING_PROP_TITLE_ELIDED, EPHY_NODE_VIEW_SEARCHABLE, - NULL); + NULL, NULL); ephy_node_view_set_sort (EPHY_NODE_VIEW (treeview), G_TYPE_STRING, EPHY_NODE_ENCODING_PROP_TITLE_ELIDED, diff --git a/src/ephy-history-window.c b/src/ephy-history-window.c index 01f864338..3343c5a04 100644 --- a/src/ephy-history-window.c +++ b/src/ephy-history-window.c @@ -1189,7 +1189,7 @@ ephy_history_window_construct (EphyHistoryWindow *editor) EphyNode *node; GtkUIManager *ui_merge; GtkActionGroup *action_group; - int col_id, details_value; + int url_col_id, title_col_id, details_value; gtk_window_set_title (GTK_WINDOW (editor), _("History")); gtk_window_set_icon_name (GTK_WINDOW (editor), EPHY_STOCK_HISTORY); @@ -1249,21 +1249,24 @@ ephy_history_window_construct (EphyHistoryWindow *editor) editor->priv->sites_filter = ephy_node_filter_new (); sites_view = ephy_node_view_new (node, editor->priv->sites_filter); add_focus_monitor (editor, sites_view); - col_id = ephy_node_view_add_data_column (EPHY_NODE_VIEW (sites_view), - G_TYPE_STRING, - EPHY_NODE_PAGE_PROP_LOCATION, - NULL, NULL); + url_col_id = ephy_node_view_add_data_column (EPHY_NODE_VIEW (sites_view), + G_TYPE_STRING, + EPHY_NODE_PAGE_PROP_LOCATION, + NULL, NULL); + title_col_id = ephy_node_view_add_column (EPHY_NODE_VIEW (sites_view), _("Sites"), + G_TYPE_STRING, + EPHY_NODE_PAGE_PROP_TITLE, + EPHY_NODE_VIEW_SEARCHABLE | + EPHY_NODE_VIEW_SHOW_PRIORITY, + provide_favicon, + NULL); ephy_node_view_enable_drag_source (EPHY_NODE_VIEW (sites_view), page_drag_types, - n_page_drag_types, col_id); + n_page_drag_types, + url_col_id, + title_col_id); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (sites_view)); gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE); - ephy_node_view_add_column (EPHY_NODE_VIEW (sites_view), _("Sites"), - G_TYPE_STRING, - EPHY_NODE_PAGE_PROP_TITLE, - EPHY_NODE_VIEW_SEARCHABLE | - EPHY_NODE_VIEW_SHOW_PRIORITY, - provide_favicon); ephy_node_view_set_priority (EPHY_NODE_VIEW (sites_view), EPHY_NODE_PAGE_PROP_PRIORITY); ephy_node_view_set_sort (EPHY_NODE_VIEW (sites_view), G_TYPE_STRING, @@ -1313,24 +1316,21 @@ ephy_history_window_construct (EphyHistoryWindow *editor) add_focus_monitor (editor, pages_view); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (pages_view)); gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (pages_view), TRUE); - col_id = ephy_node_view_add_data_column (EPHY_NODE_VIEW (pages_view), - G_TYPE_STRING, - EPHY_NODE_PAGE_PROP_LOCATION, - NULL, NULL); - ephy_node_view_enable_drag_source (EPHY_NODE_VIEW (pages_view), - page_drag_types, - n_page_drag_types, col_id); - col = ephy_node_view_add_column (EPHY_NODE_VIEW (pages_view), _("Title"), - G_TYPE_STRING, EPHY_NODE_PAGE_PROP_TITLE, - EPHY_NODE_VIEW_SORTABLE | - EPHY_NODE_VIEW_SEARCHABLE, NULL); + title_col_id = ephy_node_view_add_column (EPHY_NODE_VIEW (pages_view), _("Title"), + G_TYPE_STRING, EPHY_NODE_PAGE_PROP_TITLE, + EPHY_NODE_VIEW_SORTABLE | + EPHY_NODE_VIEW_SEARCHABLE, NULL, &col); gtk_tree_view_column_set_max_width (col, 250); editor->priv->title_col = col; - col = ephy_node_view_add_column (EPHY_NODE_VIEW (pages_view), _("Address"), - G_TYPE_STRING, EPHY_NODE_PAGE_PROP_LOCATION, - EPHY_NODE_VIEW_SORTABLE, NULL); + url_col_id = ephy_node_view_add_column (EPHY_NODE_VIEW (pages_view), _("Address"), + G_TYPE_STRING, EPHY_NODE_PAGE_PROP_LOCATION, + EPHY_NODE_VIEW_SORTABLE, NULL, &col); gtk_tree_view_column_set_max_width (col, 200); editor->priv->address_col = col; + ephy_node_view_enable_drag_source (EPHY_NODE_VIEW (pages_view), + page_drag_types, + n_page_drag_types, + url_col_id, title_col_id); ephy_node_view_set_sort (EPHY_NODE_VIEW (pages_view), G_TYPE_INT, EPHY_NODE_PAGE_PROP_LAST_VISIT, GTK_SORT_DESCENDING); |