[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 08/09: Use plugin get_button function in window.

noreply at xfce.org noreply at xfce.org
Sun Apr 15 01:13:27 CEST 2018


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

g   o   t   t   c   o   d   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository panel-plugins/xfce4-whiskermenu-plugin.

commit ba2f9f56b6d7d4a1fb48ab3c7c74e4a63b079b6a
Author: Graeme Gott <graeme at gottcode.org>
Date:   Sun Apr 8 15:47:30 2018 -0400

    Use plugin get_button function in window.
---
 panel-plugin/plugin.cpp | 8 ++++----
 panel-plugin/plugin.h   | 2 +-
 panel-plugin/window.cpp | 7 ++++---
 panel-plugin/window.h   | 9 ++++++++-
 4 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/panel-plugin/plugin.cpp b/panel-plugin/plugin.cpp
index 1ccf479..0a84cf4 100644
--- a/panel-plugin/plugin.cpp
+++ b/panel-plugin/plugin.cpp
@@ -358,7 +358,7 @@ void Plugin::button_toggled(GtkToggleButton* button)
 	else
 	{
 		xfce_panel_plugin_block_autohide(m_plugin, true);
-		show_menu(m_button, xfce_panel_plugin_get_orientation(m_plugin) == GTK_ORIENTATION_HORIZONTAL);
+		show_menu(false);
 	}
 }
 
@@ -419,7 +419,7 @@ gboolean Plugin::remote_event(XfcePanelPlugin*, gchar* name, GValue* value)
 	}
 	else if (value && G_VALUE_HOLDS_BOOLEAN(value) && g_value_get_boolean(value))
 	{
-		show_menu(NULL, true);
+		show_menu(true);
 	}
 	else
 	{
@@ -542,7 +542,7 @@ void Plugin::update_size()
 
 //-----------------------------------------------------------------------------
 
-void Plugin::show_menu(GtkWidget* parent, bool horizontal)
+void Plugin::show_menu(bool at_cursor)
 {
 	if (wm_settings->menu_opacity != m_opacity)
 	{
@@ -554,7 +554,7 @@ void Plugin::show_menu(GtkWidget* parent, bool horizontal)
 		}
 		m_opacity = wm_settings->menu_opacity;
 	}
-	m_window->show(parent, horizontal);
+	m_window->show(at_cursor ? Window::PositionAtCursor : Window::Position(xfce_panel_plugin_get_orientation(m_plugin)));
 }
 
 //-----------------------------------------------------------------------------
diff --git a/panel-plugin/plugin.h b/panel-plugin/plugin.h
index b6bbe00..9104c69 100644
--- a/panel-plugin/plugin.h
+++ b/panel-plugin/plugin.h
@@ -71,7 +71,7 @@ private:
 	void show_about();
 	gboolean size_changed(XfcePanelPlugin*, gint size);
 	void update_size();
-	void show_menu(GtkWidget* parent, bool horizontal);
+	void show_menu(bool at_cursor);
 
 private:
 	XfcePanelPlugin* m_plugin;
diff --git a/panel-plugin/window.cpp b/panel-plugin/window.cpp
index fd72908..c51bae1 100644
--- a/panel-plugin/window.cpp
+++ b/panel-plugin/window.cpp
@@ -323,7 +323,7 @@ void WhiskerMenu::Window::hide()
 
 //-----------------------------------------------------------------------------
 
-void WhiskerMenu::Window::show(GtkWidget* parent, bool horizontal)
+void WhiskerMenu::Window::show(const Position position)
 {
 	// Handle showing tooltips
 	if (wm_settings->launcher_show_tooltip)
@@ -387,10 +387,11 @@ void WhiskerMenu::Window::show(GtkWidget* parent, bool horizontal)
 
 	GdkScreen* screen = NULL;
 	int parent_x = 0, parent_y = 0, parent_w = 0, parent_h = 0;
-	if (parent != NULL)
+	if (position != PositionAtCursor)
 	{
 		// Wait up to half a second for auto-hidden panels to be shown
 		clock_t end = clock() + (CLOCKS_PER_SEC / 2);
+		GtkWidget* parent = m_plugin->get_button();
 		GtkWindow* parent_window = GTK_WINDOW(gtk_widget_get_toplevel(parent));
 		gtk_window_get_position(parent_window, &parent_x, &parent_y);
 		while ((parent_x == -9999) && (parent_y == -9999) && (clock() < end))
@@ -451,7 +452,7 @@ void WhiskerMenu::Window::show(GtkWidget* parent, bool horizontal)
 	// Find window position
 	bool layout_left = ((2 * (parent_x - monitor.x)) + parent_w) < monitor.width;
 	bool layout_bottom = ((2 * (parent_y - monitor.y)) + (parent_h / 2)) > monitor.height;
-	if (horizontal)
+	if (position != PositionVertical)
 	{
 		m_geometry.x = layout_left ? parent_x : (parent_x + parent_w - m_geometry.width);
 		m_geometry.y = layout_bottom ? (parent_y - m_geometry.height) : (parent_y + parent_h);
diff --git a/panel-plugin/window.h b/panel-plugin/window.h
index bb7a4f2..4855831 100644
--- a/panel-plugin/window.h
+++ b/panel-plugin/window.h
@@ -41,6 +41,13 @@ public:
 	explicit Window(Plugin* plugin);
 	~Window();
 
+	enum Position
+	{
+		PositionHorizontal = GTK_ORIENTATION_HORIZONTAL,
+		PositionVertical = GTK_ORIENTATION_VERTICAL,
+		PositionAtCursor
+	};
+
 	GtkWidget* get_widget() const
 	{
 		return GTK_WIDGET(m_window);
@@ -67,7 +74,7 @@ public:
 	}
 
 	void hide();
-	void show(GtkWidget* parent, bool horizontal);
+	void show(const Position position);
 	void save();
 	void on_context_menu_destroyed();
 	void set_categories(const std::vector<SectionButton*>& categories);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list