Mon, 15 Aug 2022 21:28:59 -0500
Move the Sort Buddies menu into the new menu bar
Testing Done:
Ran and verified the sort menu items functioned as expected.
Reviewed at https://reviews.imfreedom.org/r/1591/
--- a/pidgin/gtkblist.c Mon Aug 15 20:47:21 2022 -0500 +++ b/pidgin/gtkblist.c Mon Aug 15 21:28:59 2022 -0500 @@ -4525,7 +4525,7 @@ void pidgin_blist_update_sort_methods(void) { - GtkWidget *sort_item = NULL; + GApplication *application = NULL; GMenu *menu = NULL; GList *l; @@ -4533,10 +4533,13 @@ return; } - /* create the gmenu */ - menu = g_menu_new(); - - /* walk through the sort methods and update all the things */ + /* get the menu and clear any existing entries. */ + application = g_application_get_default(); + menu = gtk_application_get_menu_by_id(GTK_APPLICATION(application), + "sort-buddies"); + g_menu_remove_all(menu); + + /* Walk through the sort methods and add them to the menu. */ for (l = pidgin_blist_sort_methods; l; l = l->next) { PidginBlistSortMethod *method = NULL; GMenuItem *item = NULL; @@ -4555,10 +4558,4 @@ g_menu_append_item(menu, item); g_object_unref(item); } - - /* replace the old submenu with a new one */ - sort_item = pidgin_contact_list_window_get_menu_sort_item(PIDGIN_CONTACT_LIST_WINDOW(gtkblist->window)); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(sort_item), - gtk_menu_new_from_model(G_MENU_MODEL(menu))); - g_object_unref(menu); }
--- a/pidgin/pidgincontactlistwindow.c Mon Aug 15 20:47:21 2022 -0500 +++ b/pidgin/pidgincontactlistwindow.c Mon Aug 15 21:28:59 2022 -0500 @@ -28,9 +28,6 @@ GtkApplicationWindow parent; GtkWidget *vbox; - - GtkWidget *menu_bar; - GtkWidget *sort_buddies; }; G_DEFINE_TYPE(PidginContactListWindow, pidgin_contact_list_window, @@ -64,10 +61,6 @@ gtk_widget_class_bind_template_child(widget_class, PidginContactListWindow, vbox); - gtk_widget_class_bind_template_child(widget_class, PidginContactListWindow, - menu_bar); - gtk_widget_class_bind_template_child(widget_class, PidginContactListWindow, - sort_buddies); } /****************************************************************************** @@ -84,10 +77,3 @@ return window->vbox; } - -GtkWidget * -pidgin_contact_list_window_get_menu_sort_item(PidginContactListWindow *window) { - g_return_val_if_fail(PIDGIN_IS_CONTACT_LIST_WINDOW(window), NULL); - - return window->sort_buddies; -}
--- a/pidgin/pidgincontactlistwindow.h Mon Aug 15 20:47:21 2022 -0500 +++ b/pidgin/pidgincontactlistwindow.h Mon Aug 15 21:28:59 2022 -0500 @@ -71,18 +71,6 @@ GtkWidget *pidgin_contact_list_window_get_vbox(PidginContactListWindow *window); /** - * pidgin_contact_list_window_get_menu_sort_item: - * @window: The #PidginContactListWindow instance. - * - * Returns the sort menu item from the menu of @window. - * - * Returns: (transfer none): The sort menu item from the menu of @window. - * - * Since: 3.0.0 - */ -GtkWidget *pidgin_contact_list_window_get_menu_sort_item(PidginContactListWindow *window); - -/** * pidgin_contact_list_window_get_menu_tray: * @window: The #PidginContactListWindow instance. *
--- a/pidgin/resources/BuddyList/window.ui Mon Aug 15 20:47:21 2022 -0500 +++ b/pidgin/resources/BuddyList/window.ui Mon Aug 15 21:28:59 2022 -0500 @@ -35,39 +35,6 @@ <property name="visible">True</property> <property name="can-focus">False</property> <property name="orientation">vertical</property> - <child> - <object class="GtkMenuBar" id="menu_bar"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <child> - <object class="GtkMenuItem"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="label" translatable="yes">_Buddies</property> - <property name="use-underline">True</property> - <child type="submenu"> - <object class="GtkMenu"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <child> - <object class="GtkMenuItem" id="sort_buddies"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="label" translatable="yes">_Sort Buddies</property> - <property name="use-underline">True</property> - </object> - </child> - </object> - </child> - </object> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> </object> </child> </template>
--- a/pidgin/resources/gtk/menus.ui Mon Aug 15 20:47:21 2022 -0500 +++ b/pidgin/resources/gtk/menus.ui Mon Aug 15 21:28:59 2022 -0500 @@ -45,6 +45,14 @@ </section> <section> + <submenu> + <attribute name="label" translatable="yes">_Sort Buddies</attribute> + + <section id="sort-buddies"/> + </submenu> + </section> + + <section> <item> <attribute name="label" translatable="yes">_Add Buddy...</attribute> <attribute name="action">app.add-buddy</attribute>