lists.geany.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
List overview
Plugins-Commits
August 2019
----- 2024 -----
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
plugins-commits@lists.geany.org
1 participants
1 discussions
Start a n
N
ew thread
[geany/geany-plugins] 9694c6: Fixed document list menu position bug (#895)
by PatrickGMM
13 Aug '19
13 Aug '19
Branch: refs/heads/master Author: PatrickGMM <pbrands(a)socal.rr.com> Committer: Enrico Tröger <enrico.troeger(a)uvena.de> Date: Tue, 13 Aug 2019 20:22:30 UTC Commit: 9694c624d6a3ff579dc03f84f24f4c99295f0027
https://github.com/geany/geany-plugins/commit/9694c624d6a3ff579dc03f84f24f4…
Log Message: ----------- Fixed document list menu position bug (#895) * Fixed document list menu position bug when the tool button has been moved to the toolbar overflow menu * Tested on builds of Geany 1.35 for Gtk versions 3.22.30 and 2.24.32 Modified Paths: -------------- addons/src/ao_doclist.c Modified: addons/src/ao_doclist.c 94 lines changed, 81 insertions(+), 13 deletions(-) =================================================================== @@ -53,6 +53,8 @@ struct _AoDocListPrivate gboolean enable_doclist; DocListSortMode sort_mode; GtkToolItem *toolbar_doclist_button; + gboolean in_overflow_menu; + GtkWidget *overflow_menu_item; }; enum @@ -112,6 +114,8 @@ static void ao_doc_list_finalize(GObject *object) if (priv->toolbar_doclist_button != NULL) gtk_widget_destroy(GTK_WIDGET(priv->toolbar_doclist_button)); + if (priv->overflow_menu_item != NULL) + gtk_widget_destroy(priv->overflow_menu_item); G_OBJECT_CLASS(ao_doc_list_parent_class)->finalize(object); } @@ -120,23 +124,55 @@ static void ao_doc_list_finalize(GObject *object) /* This function is taken from Midori's katze-utils.c, thanks to Christian. */ static void ao_popup_position_menu(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data) { + AoDocListPrivate *priv = AO_DOC_LIST_GET_PRIVATE(data); + gint wx, wy; GtkRequisition widget_req; - GtkWidget *widget = data; - GdkWindow *window = gtk_widget_get_window(widget); + GtkWidget *widget = GTK_WIDGET(priv->toolbar_doclist_button); + GdkWindow *window; gint widget_height; - /* Retrieve size and position of both widget and menu */ - if (! gtk_widget_get_has_window(widget)) - { - GtkAllocation allocation; - gdk_window_get_position(window, &wx, &wy); - gtk_widget_get_allocation(widget, &allocation); - wx += allocation.x; - wy += allocation.y; + if (priv->in_overflow_menu) { + /* The button was added to the toolbar overflow menu (since the toolbar + * isn't wide enough to contain the button), so use the toolbar window + * instead + */ + + /* Get the root coordinates of the toolbar's window */ + int wx_root, wy_root, width; + window = gtk_widget_get_window (gtk_widget_get_ancestor(widget, GTK_TYPE_TOOLBAR)); +#if GTK_CHECK_VERSION(3, 0, 0) + gdk_window_get_geometry(window, &wx, &wy, &width, NULL); + gtk_widget_get_preferred_size(widget, &widget_req, NULL); +#else + gdk_window_get_geometry(window, &wx, &wy, &width, NULL, NULL); + gtk_widget_size_request(widget, &widget_req); +#endif + gdk_window_get_root_coords(window, wx, wy, &wx_root, &wy_root); + + /* Approximate the horizontal location of the overflow menu button */ + /* TODO: See if there's a way to find the exact location */ + wx = wx_root + width - (int) (widget_req.width * 1.5); + wy = wy_root; + + /* This will be set TRUE if the overflow menu is open again and includes + * the doclist menu item + */ + priv->in_overflow_menu = FALSE; + } else { + /* Retrieve size and position of both widget and menu */ + window = gtk_widget_get_window(widget); + if (! gtk_widget_get_has_window(widget)) + { + GtkAllocation allocation; + gdk_window_get_position(window, &wx, &wy); + gtk_widget_get_allocation(widget, &allocation); + wx += allocation.x; + wy += allocation.y; + } + else + gdk_window_get_origin(window, &wx, &wy); } - else - gdk_window_get_origin(window, &wx, &wy); #if GTK_CHECK_VERSION(3, 0, 0) gtk_widget_get_preferred_size(widget, &widget_req, NULL); #else @@ -223,7 +259,33 @@ static void ao_toolbar_item_doclist_clicked_cb(GtkWidget *button, gpointer data) GINT_TO_POINTER(ACTION_CLOSE_ALL)); gtk_menu_popup(GTK_MENU(menu), NULL, NULL, - ao_popup_position_menu, button, 0, gtk_get_current_event_time()); + ao_popup_position_menu, data, 0, gtk_get_current_event_time()); +} + + +static gboolean ao_create_proxy_menu_cb(GtkToolItem *widget, gpointer data) +{ + AoDocListPrivate *priv = AO_DOC_LIST_GET_PRIVATE(data); + + /* Create the menu item if needed */ + if (priv->overflow_menu_item == NULL) + { +#if GTK_CHECK_VERSION(3, 0, 0) + priv->overflow_menu_item = gtk_menu_item_new_with_label("Document List"); +#else + GtkWidget *menu_image = gtk_image_new_from_icon_name(GTK_STOCK_INDEX, GTK_ICON_SIZE_MENU); + priv->overflow_menu_item = gtk_image_menu_item_new_with_label("Document List"); + gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(priv->overflow_menu_item), menu_image); +#endif + g_signal_connect(priv->overflow_menu_item, "activate", + G_CALLBACK(ao_toolbar_item_doclist_clicked_cb), data); + } + + gtk_tool_item_set_proxy_menu_item(priv->toolbar_doclist_button, "doc-list-menu-item", + priv->overflow_menu_item); + priv->in_overflow_menu = TRUE; + + return TRUE; } @@ -253,6 +315,10 @@ static void ao_toolbar_update(AoDocList *self) g_signal_connect(priv->toolbar_doclist_button, "clicked", G_CALLBACK(ao_toolbar_item_doclist_clicked_cb), self); + + g_signal_connect(priv->toolbar_doclist_button, "create-menu-proxy", + G_CALLBACK(ao_create_proxy_menu_cb), self); + } gtk_widget_show(GTK_WIDGET(priv->toolbar_doclist_button)); } @@ -285,6 +351,8 @@ static void ao_doc_list_init(AoDocList *self) AoDocListPrivate *priv = AO_DOC_LIST_GET_PRIVATE(self); priv->toolbar_doclist_button = NULL; + priv->in_overflow_menu = FALSE; + priv->overflow_menu_item = NULL; } -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
Results per page:
10
25
50
100
200