[evolution] I#48 - Add 'Customize current view' into View->Current View menu



commit ec5e81dfc374d6346d7db3ecbd08146f9b45ee9a
Author: Milan Crha <mcrha redhat com>
Date:   Wed Feb 5 12:16:08 2020 +0100

    I#48 - Add 'Customize current view' into View->Current View menu
    
    Closes https://gitlab.gnome.org/GNOME/evolution/issues/48

 data/ui/evolution-shell.ui         |  2 ++
 src/e-util/e-table-header-item.c   | 22 ++++++++++++-----
 src/e-util/e-table-header-item.h   |  2 ++
 src/e-util/e-table.c               |  9 +++++++
 src/e-util/e-table.h               |  1 +
 src/e-util/e-tree.c                | 13 +++++++++++
 src/e-util/e-tree.h                |  1 +
 src/e-util/gal-view-etable.c       | 16 +++++++++++++
 src/e-util/gal-view-etable.h       |  2 ++
 src/shell/e-shell-window-actions.c | 48 ++++++++++++++++++++++++++++++++++++++
 src/shell/e-shell-window-actions.h |  2 ++
 11 files changed, 112 insertions(+), 6 deletions(-)
---
diff --git a/data/ui/evolution-shell.ui b/data/ui/evolution-shell.ui
index ac634aa0cf..75b467bcc4 100644
--- a/data/ui/evolution-shell.ui
+++ b/data/ui/evolution-shell.ui
@@ -37,6 +37,8 @@
       <menu action='gal-view-menu'>
         <placeholder name='gal-view-list'/>
         <separator/>
+        <menuitem action='gal-customize-view'/>
+        <separator/>
         <menuitem action='gal-custom-view'/>
         <menuitem action='gal-save-custom-view'/>
         <separator/>
diff --git a/src/e-util/e-table-header-item.c b/src/e-util/e-table-header-item.c
index b8556bd3dc..0d3c66afbd 100644
--- a/src/e-util/e-table-header-item.c
+++ b/src/e-util/e-table-header-item.c
@@ -1580,22 +1580,23 @@ apply_changes (ETableConfig *config,
                GTK_RESPONSE_APPLY, FALSE);
 }
 
-static void
-ethi_popup_customize_view (GtkWidget *widget,
-                           EthiHeaderInfo *info)
+void
+e_table_header_item_customize_view (ETableHeaderItem *ethi)
 {
-       ETableHeaderItem *ethi = info->ethi;
        ETableState *state;
        ETableSpecification *spec;
+       GtkWidget *widget = NULL;
+
+       g_return_if_fail (E_IS_TABLE_HEADER_ITEM (ethi));
 
        if (ethi->table)
                widget = GTK_WIDGET (ethi->table);
        else if (ethi->tree)
                widget = GTK_WIDGET (ethi->tree);
 
-       if (ethi->config)
+       if (ethi->config) {
                e_table_config_raise (E_TABLE_CONFIG (ethi->config));
-       else {
+       } else {
                if (ethi->table) {
                        state = e_table_get_state_object (ethi->table);
                        spec = ethi->table->spec;
@@ -1617,6 +1618,15 @@ ethi_popup_customize_view (GtkWidget *widget,
        }
 }
 
+static void
+ethi_popup_customize_view (GtkWidget *widget,
+                           EthiHeaderInfo *info)
+{
+       ETableHeaderItem *ethi = info->ethi;
+
+       e_table_header_item_customize_view (ethi);
+}
+
 static void
 free_popup_info (GtkWidget *w,
                  EthiHeaderInfo *info)
diff --git a/src/e-util/e-table-header-item.h b/src/e-util/e-table-header-item.h
index effc580d93..d22c39e624 100644
--- a/src/e-util/e-table-header-item.h
+++ b/src/e-util/e-table-header-item.h
@@ -148,6 +148,8 @@ GType               e_table_header_item_get_type    (void) G_GNUC_CONST;
 void           ethi_change_sort_state          (ETableHeaderItem *ethi,
                                                 ETableCol *col,
                                                 ETableHeaderItemSortFlag flag);
+void           e_table_header_item_customize_view
+                                               (ETableHeaderItem *ethi);
 
 G_END_DECLS
 
diff --git a/src/e-util/e-table.c b/src/e-util/e-table.c
index f26567bff4..9fe67fae66 100644
--- a/src/e-util/e-table.c
+++ b/src/e-util/e-table.c
@@ -3605,3 +3605,12 @@ e_table_is_editing (ETable *table)
        return (table->click_to_add && e_table_click_to_add_is_editing (E_TABLE_CLICK_TO_ADD 
(table->click_to_add))) ||
               (table->group && e_table_group_is_editing (table->group));
 }
+
+void
+e_table_customize_view (ETable *table)
+{
+       g_return_if_fail (E_IS_TABLE (table));
+
+       if (table->header_item)
+               e_table_header_item_customize_view (E_TABLE_HEADER_ITEM (table->header_item));
+}
diff --git a/src/e-util/e-table.h b/src/e-util/e-table.h
index aefc3b3525..5cdc229075 100644
--- a/src/e-util/e-table.h
+++ b/src/e-util/e-table.h
@@ -378,6 +378,7 @@ void                e_table_commit_click_to_add     (ETable *table);
 void           e_table_freeze_state_change     (ETable *table);
 void           e_table_thaw_state_change       (ETable *table);
 gboolean       e_table_is_editing              (ETable *table);
+void           e_table_customize_view          (ETable *table);
 
 G_END_DECLS
 
diff --git a/src/e-util/e-tree.c b/src/e-util/e-tree.c
index e98ba08be5..a701813e28 100644
--- a/src/e-util/e-tree.c
+++ b/src/e-util/e-tree.c
@@ -3432,3 +3432,16 @@ e_tree_set_sort_children_ascending (ETree *tree,
 
        g_object_notify (G_OBJECT (tree), "sort-children-ascending");
 }
+
+void
+e_tree_customize_view (ETree *tree)
+{
+       GnomeCanvasItem *header_item;
+
+       g_return_if_fail (E_IS_TREE (tree));
+
+       header_item = e_tree_get_header_item (tree);
+
+       if (header_item)
+               e_table_header_item_customize_view (E_TABLE_HEADER_ITEM (header_item));
+}
diff --git a/src/e-util/e-tree.h b/src/e-util/e-tree.h
index 35e20c8833..a38853f246 100644
--- a/src/e-util/e-tree.h
+++ b/src/e-util/e-tree.h
@@ -261,6 +261,7 @@ gboolean    e_tree_get_sort_children_ascending
 void           e_tree_set_sort_children_ascending
                                                (ETree *tree,
                                                 gboolean sort_children_ascending);
+void           e_tree_customize_view           (ETree *tree);
 
 G_END_DECLS
 
diff --git a/src/e-util/gal-view-etable.c b/src/e-util/gal-view-etable.c
index 06e80093d8..22b1495e60 100644
--- a/src/e-util/gal-view-etable.c
+++ b/src/e-util/gal-view-etable.c
@@ -274,3 +274,19 @@ gal_view_etable_detach (GalViewEtable *view)
        if (view->priv->tree != NULL)
                detach_tree (view);
 }
+
+ETable *
+gal_view_etable_get_table (GalViewEtable *view)
+{
+       g_return_val_if_fail (GAL_IS_VIEW_ETABLE (view), NULL);
+
+       return view->priv->table;
+}
+
+ETree *
+gal_view_etable_get_tree (GalViewEtable *view)
+{
+       g_return_val_if_fail (GAL_IS_VIEW_ETABLE (view), NULL);
+
+       return view->priv->tree;
+}
diff --git a/src/e-util/gal-view-etable.h b/src/e-util/gal-view-etable.h
index 84f1717ba2..82fa28c818 100644
--- a/src/e-util/gal-view-etable.h
+++ b/src/e-util/gal-view-etable.h
@@ -69,6 +69,8 @@ void          gal_view_etable_attach_table    (GalViewEtable *view,
 void           gal_view_etable_attach_tree     (GalViewEtable *view,
                                                 ETree *tree);
 void           gal_view_etable_detach          (GalViewEtable *view);
+ETable *       gal_view_etable_get_table       (GalViewEtable *view);
+ETree *                gal_view_etable_get_tree        (GalViewEtable *view);
 
 G_END_DECLS
 
diff --git a/src/shell/e-shell-window-actions.c b/src/shell/e-shell-window-actions.c
index c3ea66648e..f8c565f1cb 100644
--- a/src/shell/e-shell-window-actions.c
+++ b/src/shell/e-shell-window-actions.c
@@ -220,6 +220,40 @@ action_gal_save_custom_view_cb (GtkAction *action,
        gal_view_instance_save_as (view_instance);
 }
 
+static void
+action_gal_customize_view_cb (GtkAction *action,
+                             EShellWindow *shell_window)
+{
+       EShellView *shell_view;
+       GalViewInstance *view_instance;
+       GalView *gal_view;
+       const gchar *view_name;
+
+       view_name = e_shell_window_get_active_view (shell_window);
+       shell_view = e_shell_window_get_shell_view (shell_window, view_name);
+       view_instance = e_shell_view_get_view_instance (shell_view);
+
+       gal_view = gal_view_instance_get_current_view (view_instance);
+
+       if (GAL_IS_VIEW_ETABLE (gal_view)) {
+               GalViewEtable *etable_view = GAL_VIEW_ETABLE (gal_view);
+               ETable *etable;
+
+               etable = gal_view_etable_get_table (etable_view);
+
+               if (etable) {
+                       e_table_customize_view (etable);
+               } else {
+                       ETree *etree;
+
+                       etree = gal_view_etable_get_tree (etable_view);
+
+                       if (etree)
+                               e_tree_customize_view (etree);
+               }
+       }
+}
+
 /**
  * E_SHELL_WINDOW_ACTION_IMPORT:
  * @window: an #EShellWindow
@@ -1187,6 +1221,13 @@ static GtkActionEntry shell_gal_view_entries[] = {
          N_("Save current custom view"),
          G_CALLBACK (action_gal_save_custom_view_cb) },
 
+       { "gal-customize-view",
+         NULL,
+         N_("Custo_mize Current View…"),
+         NULL,
+         NULL,
+         G_CALLBACK (action_gal_customize_view_cb) },
+
        /*** Menus ***/
 
        { "gal-view-menu",
@@ -1649,6 +1690,7 @@ e_shell_window_update_view_menu (EShellWindow *shell_window)
        GtkUIManager *ui_manager;
        GtkActionGroup *action_group;
        GalViewCollection *view_collection;
+       GalViewInstance *view_instance;
        GtkRadioAction *radio_action;
        GtkAction *action;
        GSList *radio_group;
@@ -1741,6 +1783,12 @@ e_shell_window_update_view_menu (EShellWindow *shell_window)
                g_free (title);
        }
 
+       view_instance = e_shell_view_get_view_instance (shell_view);
+       visible = view_instance && gal_view_instance_get_current_view (view_instance) &&
+               GAL_IS_VIEW_ETABLE (gal_view_instance_get_current_view (view_instance));
+       action = ACTION (GAL_CUSTOMIZE_VIEW);
+       gtk_action_set_visible (action, visible);
+
        /* Doesn't matter which radio action we check. */
        visible = (gtk_radio_action_get_current_value (radio_action) < 0);
 
diff --git a/src/shell/e-shell-window-actions.h b/src/shell/e-shell-window-actions.h
index 1f6fa89fb9..06a106af94 100644
--- a/src/shell/e-shell-window-actions.h
+++ b/src/shell/e-shell-window-actions.h
@@ -44,6 +44,8 @@
        E_SHELL_WINDOW_ACTION ((window), "delete-selection")
 #define E_SHELL_WINDOW_ACTION_GAL_CUSTOM_VIEW(window) \
        E_SHELL_WINDOW_ACTION ((window), "gal-custom-view")
+#define E_SHELL_WINDOW_ACTION_GAL_CUSTOMIZE_VIEW(window) \
+       E_SHELL_WINDOW_ACTION ((window), "gal-customize-view")
 #define E_SHELL_WINDOW_ACTION_GAL_DELETE_VIEW(window) \
        E_SHELL_WINDOW_ACTION ((window), "gal-delete-view")
 #define E_SHELL_WINDOW_ACTION_GAL_SAVE_CUSTOM_VIEW(window) \


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]