From 26d1ed1f62e1c3229729bb79673f1b424a4dd8d9 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Fri, 18 Apr 2003 10:19:22 +0000 Subject: Do not install two copies of epiphany.png 2003-04-18 Marco Pesenti Gritti * data/art/Makefile.am: Do not install two copies of epiphany.png * embed/ephy-history.c: (ephy_history_save), (ephy_history_set_page_title): Use host name as title for sites, not the real title. * lib/ephy-state.c: (ephy_state_add_window), (paned_size_allocate_cb), (ephy_state_add_paned): * lib/ephy-state.h: Add a way to persist paned. * lib/widgets/ephy-node-view.h: * lib/widgets/ephy-node-view.c: (ephy_node_view_sort_func), (provide_text_weight), (ephy_node_view_add_column), (ephy_node_view_has_selection): Improve add_column api a bit to support both auto sorting and user sorting. * src/bookmarks/ephy-bookmarks-editor.c: (ephy_bookmarks_editor_construct): Updates for changed api. * src/ephy-history-window.c: (ephy_history_window_construct): Set a max size for title/location. Not very good, but the best we can do with current treeview api prolly. Persist the paned size. Make columns user sortable. --- ChangeLog | 38 +++++++++++++++++ data/art/Makefile.am | 1 - embed/ephy-history.c | 33 +-------------- lib/ephy-state.c | 58 +++++++++++++++++++++++++ lib/ephy-state.h | 4 ++ lib/widgets/ephy-node-view.c | 79 +++++++++++++++-------------------- lib/widgets/ephy-node-view.h | 15 +++---- src/bookmarks/ephy-bookmarks-editor.c | 8 ++-- src/ephy-history-window.c | 35 ++++++++++------ 9 files changed, 171 insertions(+), 100 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6090cddd6..f46b3b77e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,41 @@ +2003-04-18 Marco Pesenti Gritti + + * data/art/Makefile.am: + + Do not install two copies of epiphany.png + + * embed/ephy-history.c: (ephy_history_save), + (ephy_history_set_page_title): + + Use host name as title for sites, not the real + title. + + * lib/ephy-state.c: (ephy_state_add_window), + (paned_size_allocate_cb), (ephy_state_add_paned): + * lib/ephy-state.h: + + Add a way to persist paned. + + * lib/widgets/ephy-node-view.h: + * lib/widgets/ephy-node-view.c: (ephy_node_view_sort_func), + (provide_text_weight), (ephy_node_view_add_column), + (ephy_node_view_has_selection): + + Improve add_column api a bit to support both auto sorting + and user sorting. + + * src/bookmarks/ephy-bookmarks-editor.c: + (ephy_bookmarks_editor_construct): + + Updates for changed api. + + * src/ephy-history-window.c: (ephy_history_window_construct): + + Set a max size for title/location. Not very good, but the + best we can do with current treeview api prolly. + Persist the paned size. + Make columns user sortable. + 2003-04-17 Marco Pesenti Gritti * data/ui/Makefile.am: diff --git a/data/art/Makefile.am b/data/art/Makefile.am index 8e5bc397e..853dce68e 100644 --- a/data/art/Makefile.am +++ b/data/art/Makefile.am @@ -1,7 +1,6 @@ art_DATA = \ epiphany-secure.png \ epiphany-unsecure.png \ - epiphany.png \ epiphany-fullscreen.png \ epiphany-bookmark-page.png \ epiphany-entry.png \ diff --git a/embed/ephy-history.c b/embed/ephy-history.c index 056d04c13..3bb69db7f 100644 --- a/embed/ephy-history.c +++ b/embed/ephy-history.c @@ -287,6 +287,7 @@ ephy_history_save (EphyHistory *eb) EphyNode *kid; kid = g_ptr_array_index (children, i); + if (kid == eb->priv->pages) continue; ephy_node_save_to_xml (kid, root); } @@ -486,33 +487,6 @@ ephy_history_new () return tab; } -static void -ephy_history_host_set_title (EphyHistory *eh, - EphyNode *host, - EphyNode *page, - const char *title) -{ - const char *real_url; - const char *host_url; - GValue value = { 0, }; - - real_url = ephy_node_get_property_string - (page, EPHY_NODE_PAGE_PROP_LOCATION); - host_url = ephy_node_get_property_string - (host, EPHY_NODE_PAGE_PROP_LOCATION); - - if (real_url && host_url && - strcmp (real_url, host_url) == 0) - { - - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, title); - ephy_node_set_property (host, EPHY_NODE_PAGE_PROP_TITLE, - &value); - g_value_unset (&value); - } -} - static void ephy_history_host_visited (EphyHistory *eh, EphyNode *host, @@ -800,11 +774,6 @@ ephy_history_set_page_title (EphyHistory *gh, host_id = ephy_node_get_property_int (node, EPHY_NODE_PAGE_PROP_HOST_ID); - if (host_id >= 0) - { - ephy_history_host_set_title (gh, ephy_node_get_from_id (host_id), - node, title); - } } void diff --git a/lib/ephy-state.c b/lib/ephy-state.c index 5debe8cf5..e89c2db88 100644 --- a/lib/ephy-state.c +++ b/lib/ephy-state.c @@ -26,6 +26,7 @@ #include #include +#include #define STATES_FILE "states.xml" @@ -270,6 +271,63 @@ ephy_state_add_window (GtkWidget *window, G_CALLBACK (window_state_event_cb), node, 0); } +static gboolean +paned_size_allocate_cb (GtkWidget *paned, + GtkAllocation *allocation, + EphyNode *node) +{ + int width; + GValue value = { 0, }; + + width = gtk_paned_get_position (GTK_PANED (paned)); + + g_value_init (&value, G_TYPE_INT); + g_value_set_int (&value, width); + ephy_node_set_property (node, EPHY_NODE_STATE_PROP_WIDTH, + &value); + g_value_unset (&value); + + return FALSE; +} + +void +ephy_state_add_paned (GtkWidget *paned, + const char *name, + int default_width) +{ + EphyNode *node; + int width; + + ensure_states (); + + node = find_by_name (name); + if (node == NULL) + { + GValue value = { 0, }; + + node = ephy_node_new (); + ephy_node_add_child (states, node); + + g_value_init (&value, G_TYPE_STRING); + g_value_set_string (&value, name); + ephy_node_set_property (node, EPHY_NODE_STATE_PROP_NAME, + &value); + g_value_unset (&value); + + g_value_init (&value, G_TYPE_INT); + g_value_set_int (&value, default_width); + ephy_node_set_property (node, EPHY_NODE_STATE_PROP_WIDTH, + &value); + g_value_unset (&value); + } + + width = ephy_node_get_property_int (node, EPHY_NODE_STATE_PROP_WIDTH); + gtk_paned_set_position (GTK_PANED (paned), width); + + g_signal_connect_object (paned, "size_allocate", + G_CALLBACK (paned_size_allocate_cb), node, 0); +} + void ephy_state_save (void) { diff --git a/lib/ephy-state.h b/lib/ephy-state.h index 7e05e6106..9d6388ac4 100644 --- a/lib/ephy-state.h +++ b/lib/ephy-state.h @@ -31,6 +31,10 @@ void ephy_state_add_window (GtkWidget *window, int default_width, int default_heigth); +void ephy_state_add_paned (GtkWidget *paned, + const char *name, + int default_width); + void ephy_state_save (void); G_END_DECLS diff --git a/lib/widgets/ephy-node-view.c b/lib/widgets/ephy-node-view.c index 1d8eba5cd..3d52afd21 100644 --- a/lib/widgets/ephy-node-view.c +++ b/lib/widgets/ephy-node-view.c @@ -64,7 +64,6 @@ struct EphyNodeViewPrivate int default_sort_column_id; int priority_prop_id; - int priority_column_id; gboolean editing; int editable_property; @@ -659,7 +658,6 @@ ephy_node_view_sort_func (GtkTreeModel *model, GValue a_value = {0, }; GValue b_value = {0, }; gchar *stra, *strb; - gtk_tree_model_get_value (model, a, column, &a_value); gtk_tree_model_get_value (model, b, column, &b_value); @@ -702,24 +700,6 @@ ephy_node_view_sort_func (GtkTreeModel *model, } -static gboolean -set_sort_column_id (EphyNodeView *view) -{ - GList *sort_order = NULL; - sort_order = g_list_append (sort_order, GINT_TO_POINTER (view->priv->priority_column_id)); - sort_order = g_list_append (sort_order, GINT_TO_POINTER (view->priv->default_sort_column_id)); - - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (view->priv->sortmodel), - GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, - GTK_SORT_ASCENDING); - gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (view->priv->sortmodel), - ephy_node_view_sort_func, - sort_order, - (GtkDestroyNotify) g_list_free); - - return FALSE; -} - static void provide_priority (EphyNode *node, GValue *value, EphyNodeView *view) { @@ -744,9 +724,13 @@ provide_text_weight (EphyNode *node, GValue *value, EphyNodeView *view) (node, view->priv->priority_prop_id); if (priority == EPHY_NODE_VIEW_ALL_PRIORITY || priority == EPHY_NODE_VIEW_SPECIAL_PRIORITY) + { g_value_set_int (value, PANGO_WEIGHT_BOLD); + } else + { g_value_set_int (value, PANGO_WEIGHT_NORMAL); + } } GtkTreeViewColumn * @@ -755,14 +739,14 @@ ephy_node_view_add_column (EphyNodeView *view, GType value_type, int prop_id, int priority_prop_id, - gboolean editable, - gboolean sortable) + EphyNodeViewFlags flags) { GtkTreeViewColumn *gcolumn; GtkCellRenderer *renderer; int column; - g_return_val_if_fail (!editable || view->priv->editable_renderer == NULL, NULL); + g_return_val_if_fail (!(flags & EPHY_NODE_VIEW_EDITABLE) || + view->priv->editable_renderer == NULL, NULL); column = ephy_tree_model_node_add_prop_column (view->priv->nodemodel, value_type, prop_id); @@ -770,7 +754,7 @@ ephy_node_view_add_column (EphyNodeView *view, gcolumn = (GtkTreeViewColumn *) gtk_tree_view_column_new (); renderer = gtk_cell_renderer_text_new (); - if (editable) + if (flags & EPHY_NODE_VIEW_EDITABLE) { view->priv->editable_renderer = renderer; view->priv->editable_column = gcolumn; @@ -782,10 +766,12 @@ ephy_node_view_add_column (EphyNodeView *view, gtk_tree_view_column_set_attributes (gcolumn, renderer, "text", column, NULL); - if (priority_prop_id > 0) + if (priority_prop_id >= 0) { int wcol; + view->priv->priority_prop_id = priority_prop_id; + wcol = ephy_tree_model_node_add_func_column (view->priv->nodemodel, G_TYPE_INT, (EphyTreeModelNodeValueFunc) provide_text_weight, @@ -794,25 +780,41 @@ ephy_node_view_add_column (EphyNodeView *view, "weight", wcol); } - gtk_tree_view_column_set_sizing (gcolumn, - GTK_TREE_VIEW_COLUMN_AUTOSIZE); gtk_tree_view_column_set_title (gcolumn, title); gtk_tree_view_append_column (GTK_TREE_VIEW (view), gcolumn); - if (sortable) + if (flags & EPHY_NODE_VIEW_USER_SORT) + { + GList *order = NULL; + + order = g_list_append (order, GINT_TO_POINTER (column)); + gtk_tree_sortable_set_sort_func + (GTK_TREE_SORTABLE (view->priv->sortmodel), + column, ephy_node_view_sort_func, + order, (GtkDestroyNotify)g_list_free); + gtk_tree_view_column_set_sort_column_id (gcolumn, column); + } + else if (flags & EPHY_NODE_VIEW_AUTO_SORT) { int scol; + GList *order = NULL; scol = ephy_tree_model_node_add_func_column (view->priv->nodemodel, G_TYPE_INT, (EphyTreeModelNodeValueFunc) provide_priority, view); - view->priv->priority_column_id = scol; - view->priv->priority_prop_id = priority_prop_id; - view->priv->default_sort_column_id = column; - g_idle_add ((GSourceFunc) set_sort_column_id, view); + order = g_list_append (order, GINT_TO_POINTER (scol)); + order = g_list_append (order, GINT_TO_POINTER (column)); + gtk_tree_sortable_set_default_sort_func + (GTK_TREE_SORTABLE (view->priv->sortmodel), + ephy_node_view_sort_func, + order, (GtkDestroyNotify)g_list_free); + gtk_tree_sortable_set_sort_column_id + (GTK_TREE_SORTABLE (view->priv->sortmodel), + GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, + GTK_SORT_ASCENDING); } return gcolumn; @@ -1084,16 +1086,3 @@ ephy_node_view_has_selection (EphyNodeView *view, gboolean *multiple) return rows > 0; } - -void -ephy_node_view_enable_sort (EphyNodeView *view, - GtkTreeIterCompareFunc sort_func, - gpointer data, - GtkDestroyNotify destroy) -{ - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (view->priv->sortmodel), - GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, - GTK_SORT_ASCENDING); - gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (view->priv->sortmodel), - sort_func, data, destroy); -} diff --git a/lib/widgets/ephy-node-view.h b/lib/widgets/ephy-node-view.h index 148b376b1..47a71d463 100644 --- a/lib/widgets/ephy-node-view.h +++ b/lib/widgets/ephy-node-view.h @@ -52,6 +52,13 @@ typedef enum EPHY_NODE_VIEW_NORMAL_PRIORITY } EphyNodeViewPriority; +typedef enum +{ + EPHY_NODE_VIEW_AUTO_SORT = 1, + EPHY_NODE_VIEW_USER_SORT = 2, + EPHY_NODE_VIEW_EDITABLE = 4 +} EphyNodeViewFlags; + typedef struct { GtkTreeViewClass parent; @@ -74,8 +81,7 @@ GtkTreeViewColumn *ephy_node_view_add_column (EphyNodeView *view, GType value_type, int prop_id, int priority_prop_id, - gboolean editable, - gboolean sortable); + EphyNodeViewFlags flags); void ephy_node_view_add_icon_column (EphyNodeView *view, EphyTreeModelNodeValueFunc func); @@ -106,11 +112,6 @@ gboolean ephy_node_view_is_editing (EphyNodeView *view, gboolean ephy_node_view_is_target (EphyNodeView *view); -void ephy_node_view_enable_sort (EphyNodeView *view, - GtkTreeIterCompareFunc sort_func, - gpointer data, - GtkDestroyNotify destroy); - G_END_DECLS #endif /* EPHY_NODE_VIEW_H */ diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c index 25fd53357..d8887eaa7 100644 --- a/src/bookmarks/ephy-bookmarks-editor.c +++ b/src/bookmarks/ephy-bookmarks-editor.c @@ -945,7 +945,8 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor) G_TYPE_STRING, EPHY_NODE_KEYWORD_PROP_NAME, EPHY_NODE_KEYWORD_PROP_PRIORITY, - TRUE, TRUE); + EPHY_NODE_VIEW_AUTO_SORT | + EPHY_NODE_VIEW_EDITABLE); gtk_container_add (GTK_CONTAINER (scrolled_window), key_view); gtk_widget_set_size_request (key_view, 130, -1); gtk_widget_show (key_view); @@ -998,8 +999,9 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor) EPHY_NODE_BMK_PROP_LOCATION); ephy_node_view_add_icon_column (EPHY_NODE_VIEW (bm_view), provide_favicon); ephy_node_view_add_column (EPHY_NODE_VIEW (bm_view), _("Title"), - G_TYPE_STRING, EPHY_NODE_BMK_PROP_TITLE, - -1, TRUE, TRUE); + G_TYPE_STRING, EPHY_NODE_BMK_PROP_TITLE, -1, + EPHY_NODE_VIEW_AUTO_SORT | + EPHY_NODE_VIEW_EDITABLE); gtk_container_add (GTK_CONTAINER (scrolled_window), bm_view); gtk_widget_show (bm_view); editor->priv->bm_view = bm_view; diff --git a/src/ephy-history-window.c b/src/ephy-history-window.c index 10e06e592..34d8e19f6 100644 --- a/src/ephy-history-window.c +++ b/src/ephy-history-window.c @@ -512,6 +512,7 @@ menu_activate_cb (EphyNodeView *view, static void ephy_history_window_construct (EphyHistoryWindow *editor) { + GtkTreeViewColumn *col; GtkTreeSelection *selection; GtkWidget *vbox, *hpaned; GtkWidget *pages_view, *sites_view; @@ -523,10 +524,6 @@ ephy_history_window_construct (EphyHistoryWindow *editor) const char *icon_path; int i; - ephy_state_add_window (GTK_WIDGET(editor), - "history_window", - 450, 400); - gtk_window_set_title (GTK_WINDOW (editor), _("History")); icon_path = ephy_file ("epiphany-history.png"); @@ -582,6 +579,8 @@ ephy_history_window_construct (EphyHistoryWindow *editor) gtk_paned_add1 (GTK_PANED (hpaned), scrolled_window); gtk_widget_show (scrolled_window); sites_view = ephy_node_view_new (node, NULL); + ephy_node_view_select_node (EPHY_NODE_VIEW (sites_view), + ephy_history_get_pages (editor->priv->history)); ephy_node_view_enable_drag_source (EPHY_NODE_VIEW (sites_view), page_drag_types, n_page_drag_types, @@ -590,9 +589,9 @@ ephy_history_window_construct (EphyHistoryWindow *editor) 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_LOCATION, + EPHY_NODE_PAGE_PROP_TITLE, EPHY_NODE_PAGE_PROP_PRIORITY, - FALSE, FALSE); + EPHY_NODE_VIEW_AUTO_SORT); gtk_container_add (GTK_CONTAINER (scrolled_window), sites_view); gtk_widget_show (sites_view); editor->priv->sites_view = sites_view; @@ -628,12 +627,17 @@ ephy_history_window_construct (EphyHistoryWindow *editor) page_drag_types, n_page_drag_types, EPHY_NODE_PAGE_PROP_LOCATION); - ephy_node_view_add_column (EPHY_NODE_VIEW (pages_view), _("Title"), - G_TYPE_STRING, EPHY_NODE_PAGE_PROP_TITLE, - -1, FALSE, FALSE); - ephy_node_view_add_column (EPHY_NODE_VIEW (pages_view), _("Location"), - G_TYPE_STRING, EPHY_NODE_PAGE_PROP_LOCATION, - -1, FALSE, FALSE); + col = ephy_node_view_add_column (EPHY_NODE_VIEW (pages_view), _("Title"), + G_TYPE_STRING, EPHY_NODE_PAGE_PROP_TITLE, + -1, EPHY_NODE_VIEW_USER_SORT); + gtk_tree_view_column_set_max_width (col, 250); + col = ephy_node_view_add_column (EPHY_NODE_VIEW (pages_view), _("Location"), + G_TYPE_STRING, EPHY_NODE_PAGE_PROP_LOCATION, + -1, EPHY_NODE_VIEW_USER_SORT); + gtk_tree_view_column_set_max_width (col, 200); +/* col = ephy_node_view_add_column (EPHY_NODE_VIEW (pages_view), _("Last Visit"), + G_TYPE_STRING, EPHY_NODE_PAGE_PROP_LAST_VISIT, + -1, EPHY_NODE_VIEW_USER_SORT);*/ gtk_container_add (GTK_CONTAINER (scrolled_window), pages_view); gtk_widget_show (pages_view); editor->priv->pages_view = pages_view; @@ -645,6 +649,13 @@ ephy_history_window_construct (EphyHistoryWindow *editor) "show_popup", G_CALLBACK (ephy_history_window_show_popup_cb), editor); + + ephy_state_add_window (GTK_WIDGET (editor), + "history_window", + 450, 400); + ephy_state_add_paned (GTK_WIDGET (hpaned), + "history_paned", + 130); } void -- cgit v1.2.3