This is an automated email from the git hooks/post-receive script.

gottcode pushed a 
commit to branch 
master
in repository panel-plugins/xfce4-whiskermenu-plugin.

commit 69ef471b25fbeb32aa543adae02de6874f64b665
Author: Graeme Gott <[email protected]>
Date:   Wed Dec 18 17:52:08 2019 -0500

    Add icon view.
---
 panel-plugin/CMakeLists.txt         |   1 +
 panel-plugin/launcher-icon-view.cpp | 277 ++++++++++++++++++++++++++++++++++++
 panel-plugin/launcher-icon-view.h   |  72 ++++++++++
 panel-plugin/page.cpp               |   1 +
 panel-plugin/page.h                 |   5 +
 5 files changed, 356 insertions(+)

diff --git a/panel-plugin/CMakeLists.txt b/panel-plugin/CMakeLists.txt
index cce0447..bd9e181 100644
--- a/panel-plugin/CMakeLists.txt
+++ b/panel-plugin/CMakeLists.txt
@@ -78,6 +78,7 @@ add_library(whiskermenu MODULE
        favorites-page.cpp
        icon-size.cpp
        launcher.cpp
+       launcher-icon-view.cpp
        launcher-tree-view.cpp
        page.cpp
        plugin.cpp
diff --git a/panel-plugin/launcher-icon-view.cpp 
b/panel-plugin/launcher-icon-view.cpp
new file mode 100644
index 0000000..4e451cc
--- /dev/null
+++ b/panel-plugin/launcher-icon-view.cpp
@@ -0,0 +1,277 @@
+/*
+ * Copyright (C) 2019 Graeme Gott <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this library.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "launcher-icon-view.h"
+
+#include "settings.h"
+#include "slot.h"
+
+#include <exo/exo.h>
+
+using namespace WhiskerMenu;
+
+//-----------------------------------------------------------------------------
+
+LauncherIconView::LauncherIconView() :
+       m_icon_renderer(NULL),
+       m_icon_size(-1)
+{
+       // Create the view
+       m_view = GTK_ICON_VIEW(gtk_icon_view_new());
+
+       m_icon_renderer = exo_cell_renderer_icon_new();
+       g_object_set(m_icon_renderer,
+                       "follow-state", false,
+                       "xalign", 0.5,
+                       "yalign", 1.0,
+                       NULL);
+       GtkCellLayout* cell_layout = GTK_CELL_LAYOUT(m_view);
+       gtk_cell_layout_pack_start(cell_layout, m_icon_renderer, false);
+       gtk_cell_layout_set_attributes(cell_layout, m_icon_renderer, "icon", 
COLUMN_ICON, NULL);
+
+       gtk_icon_view_set_markup_column(m_view, COLUMN_TEXT);
+
+       reload_icon_size();
+
+       // Use single clicks to activate items
+       gtk_icon_view_set_activate_on_single_click(m_view, true);
+
+       // Only allow up to one selected item
+       gtk_icon_view_set_selection_mode(m_view, GTK_SELECTION_SINGLE);
+
+       g_object_ref_sink(m_view);
+}
+
+//-----------------------------------------------------------------------------
+
+LauncherIconView::~LauncherIconView()
+{
+       gtk_widget_destroy(GTK_WIDGET(m_view));
+       g_object_unref(m_view);
+}
+
+//-----------------------------------------------------------------------------
+
+GtkTreePath* LauncherIconView::get_cursor() const
+{
+       GtkTreePath* path = NULL;
+       gtk_icon_view_get_cursor(m_view, &path, NULL);
+       return path;
+}
+
+//-----------------------------------------------------------------------------
+
+GtkTreePath* LauncherIconView::get_path_at_pos(int x, int y) const
+{
+       return gtk_icon_view_get_path_at_pos(m_view, x, y);
+}
+
+//-----------------------------------------------------------------------------
+
+GtkTreePath* LauncherIconView::get_selected_path() const
+{
+       GtkTreePath* path = NULL;
+       GList* selection = gtk_icon_view_get_selected_items(m_view);
+       if (selection != NULL)
+       {
+               path = 
gtk_tree_path_copy(reinterpret_cast<GtkTreePath*>(selection->data));
+       }
+       g_list_free_full(selection, (GDestroyNotify)gtk_tree_path_free);
+       return path;
+}
+
+//-----------------------------------------------------------------------------
+
+void LauncherIconView::activate_path(GtkTreePath* path)
+{
+       gtk_icon_view_item_activated(m_view, path);
+}
+
+//-----------------------------------------------------------------------------
+
+void LauncherIconView::scroll_to_path(GtkTreePath* path)
+{
+       gtk_icon_view_scroll_to_path(m_view, path, true, 0.5f, 0.5f);
+}
+
+//-----------------------------------------------------------------------------
+
+void LauncherIconView::select_path(GtkTreePath* path)
+{
+       gtk_icon_view_select_path(m_view, path);
+}
+
+//-----------------------------------------------------------------------------
+
+void LauncherIconView::set_cursor(GtkTreePath* path)
+{
+       gtk_icon_view_set_cursor(m_view,path, NULL, false);
+}
+
+//-----------------------------------------------------------------------------
+
+void LauncherIconView::set_fixed_height_mode(bool)
+{
+}
+
+//-----------------------------------------------------------------------------
+
+void LauncherIconView::set_selection_mode(GtkSelectionMode mode)
+{
+       gtk_icon_view_set_selection_mode(m_view, mode);
+}
+
+//-----------------------------------------------------------------------------
+
+void LauncherIconView::hide_tooltips()
+{
+       gtk_icon_view_set_tooltip_column(m_view, -1);
+}
+
+//-----------------------------------------------------------------------------
+
+void LauncherIconView::show_tooltips()
+{
+       gtk_icon_view_set_tooltip_column(m_view, COLUMN_TOOLTIP);
+}
+
+//-----------------------------------------------------------------------------
+
+void LauncherIconView::clear_selection()
+{
+       gtk_icon_view_unselect_all(m_view);
+}
+
+//-----------------------------------------------------------------------------
+
+void LauncherIconView::collapse_all()
+{
+}
+
+//-----------------------------------------------------------------------------
+
+void LauncherIconView::set_model(GtkTreeModel* model)
+{
+       m_model = model;
+       gtk_icon_view_set_model(m_view, model);
+}
+
+//-----------------------------------------------------------------------------
+
+void LauncherIconView::unset_model()
+{
+       m_model = NULL;
+       gtk_icon_view_set_model(m_view, NULL);
+}
+
+//-----------------------------------------------------------------------------
+
+void LauncherIconView::set_drag_source(GdkModifierType start_button_mask, 
const GtkTargetEntry* targets, gint n_targets, GdkDragAction actions)
+{
+       gtk_icon_view_enable_model_drag_source(m_view, start_button_mask, 
targets, n_targets, actions);
+}
+
+//-----------------------------------------------------------------------------
+
+void LauncherIconView::set_drag_dest(const GtkTargetEntry* targets, gint 
n_targets, GdkDragAction actions)
+{
+       gtk_icon_view_enable_model_drag_dest(m_view, targets, n_targets, 
actions);
+}
+
+//-----------------------------------------------------------------------------
+
+void LauncherIconView::unset_drag_source()
+{
+       gtk_icon_view_unset_model_drag_source(m_view);
+}
+
+//-----------------------------------------------------------------------------
+
+void LauncherIconView::unset_drag_dest()
+{
+       gtk_icon_view_unset_model_drag_dest(m_view);
+}
+
+//-----------------------------------------------------------------------------
+
+void LauncherIconView::reload_icon_size()
+{
+       // Fetch icon size
+       if (m_icon_size == wm_settings->launcher_icon_size.get_size())
+       {
+               return;
+       }
+       m_icon_size = wm_settings->launcher_icon_size.get_size();
+
+       // Configure icon renderer
+       if (m_icon_size > 1)
+       {
+               g_object_set(m_icon_renderer, "size", m_icon_size, "visible", 
true, NULL);
+       }
+       else
+       {
+               g_object_set(m_icon_renderer, "visible", false, NULL);
+       }
+
+       // Adjust item size
+       int padding = 2;
+       int width = 88;
+       switch (wm_settings->launcher_icon_size)
+       {
+       case IconSize::Smallest:
+               padding = 2;
+               width = 88;
+               break;
+
+       case IconSize::Smaller:
+               padding = 2;
+               width =  92;
+               break;
+
+       case IconSize::Small:
+               padding = 4;
+               width = 100;
+               break;
+
+       case IconSize::Normal:
+               padding = 4;
+               width = 108;
+               break;
+
+       case IconSize::Large:
+               padding = 4;
+               width = 116;
+               break;
+
+       case IconSize::Larger:
+               padding = 6;
+               width = 136;
+               break;
+
+       case IconSize::Largest:
+               padding = 6;
+               width = 152;
+               break;
+
+       default:
+               break;
+       }
+       gtk_icon_view_set_item_padding(m_view, padding);
+       gtk_icon_view_set_item_width(m_view, width);
+}
+
+//-----------------------------------------------------------------------------
diff --git a/panel-plugin/launcher-icon-view.h 
b/panel-plugin/launcher-icon-view.h
new file mode 100644
index 0000000..b810000
--- /dev/null
+++ b/panel-plugin/launcher-icon-view.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2019 Graeme Gott <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this library.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef WHISKERMENU_LAUNCHER_ICON_VIEW_H
+#define WHISKERMENU_LAUNCHER_ICON_VIEW_H
+
+#include "launcher-view.h"
+
+namespace WhiskerMenu
+{
+
+class LauncherIconView : public LauncherView
+{
+public:
+       LauncherIconView();
+       ~LauncherIconView();
+
+       GtkWidget* get_widget() const
+       {
+               return GTK_WIDGET(m_view);
+       }
+
+       GtkTreePath* get_cursor() const;
+       GtkTreePath* get_path_at_pos(int x, int y) const;
+       GtkTreePath* get_selected_path() const;
+       void activate_path(GtkTreePath* path);
+       void scroll_to_path(GtkTreePath* path);
+       void select_path(GtkTreePath* path);
+       void set_cursor(GtkTreePath* path);
+
+       void set_fixed_height_mode(bool fixed_height);
+       void set_selection_mode(GtkSelectionMode mode);
+
+       void hide_tooltips();
+       void show_tooltips();
+
+       void clear_selection();
+       void collapse_all();
+
+       void set_model(GtkTreeModel* model);
+       void unset_model();
+
+       void set_drag_source(GdkModifierType start_button_mask, const 
GtkTargetEntry* targets, gint n_targets, GdkDragAction actions);
+       void set_drag_dest(const GtkTargetEntry* targets, gint n_targets, 
GdkDragAction actions);
+       void unset_drag_source();
+       void unset_drag_dest();
+
+       void reload_icon_size();
+
+private:
+       GtkIconView* m_view;
+       GtkCellRenderer* m_icon_renderer;
+       int m_icon_size;
+};
+
+}
+
+#endif // WHISKERMENU_LAUNCHER_ICON_VIEW_H
diff --git a/panel-plugin/page.cpp b/panel-plugin/page.cpp
index a48b107..732d901 100644
--- a/panel-plugin/page.cpp
+++ b/panel-plugin/page.cpp
@@ -19,6 +19,7 @@
 
 #include "favorites-page.h"
 #include "launcher.h"
+#include "launcher-icon-view.h"
 #include "launcher-tree-view.h"
 #include "recent-page.h"
 #include "slot.h"
diff --git a/panel-plugin/page.h b/panel-plugin/page.h
index a38b17d..27c90da 100644
--- a/panel-plugin/page.h
+++ b/panel-plugin/page.h
@@ -78,6 +78,11 @@ private:
        void create_context_menu(GtkTreePath* path, GdkEvent* event);
        virtual void extend_context_menu(GtkWidget* menu);
 
+       static void item_activated_slot(GtkIconView*, GtkTreePath* path, 
gpointer user_data)
+       {
+               reinterpret_cast<Page*>(user_data)->launcher_activated(path);
+       }
+
        static void row_activated_slot(GtkTreeView*, GtkTreePath* path, 
GtkTreeViewColumn*, gpointer user_data)
        {
                reinterpret_cast<Page*>(user_data)->launcher_activated(path);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
Xfce4-commits mailing list
[email protected]
https://mail.xfce.org/mailman/listinfo/xfce4-commits

Reply via email to