diff options
author | Danielle Madeley <danielle.madeley@collabora.co.uk> | 2012-05-15 10:16:45 +0800 |
---|---|---|
committer | Danielle Madeley <danielle.madeley@collabora.co.uk> | 2012-05-15 18:40:27 +0800 |
commit | a51af40f723c6929a461b9af26eaa10b4b714c84 (patch) | |
tree | c8f09cde3e6c28b42043988f9a896488e7c9a1a1 /src | |
parent | 06d7e54c62318a502d9e726bdbda16caeaf898e6 (diff) | |
download | gsoc2013-empathy-a51af40f723c6929a461b9af26eaa10b4b714c84.tar gsoc2013-empathy-a51af40f723c6929a461b9af26eaa10b4b714c84.tar.gz gsoc2013-empathy-a51af40f723c6929a461b9af26eaa10b4b714c84.tar.bz2 gsoc2013-empathy-a51af40f723c6929a461b9af26eaa10b4b714c84.tar.lz gsoc2013-empathy-a51af40f723c6929a461b9af26eaa10b4b714c84.tar.xz gsoc2013-empathy-a51af40f723c6929a461b9af26eaa10b4b714c84.tar.zst gsoc2013-empathy-a51af40f723c6929a461b9af26eaa10b4b714c84.zip |
Remove menu button, have only app menu
Diffstat (limited to 'src')
-rw-r--r-- | src/empathy-roster-window.c | 101 | ||||
-rw-r--r-- | src/empathy-roster-window.h | 2 | ||||
-rw-r--r-- | src/empathy.c | 18 |
3 files changed, 17 insertions, 104 deletions
diff --git a/src/empathy-roster-window.c b/src/empathy-roster-window.c index 84916cd5f..4c1992979 100644 --- a/src/empathy-roster-window.c +++ b/src/empathy-roster-window.c @@ -131,7 +131,7 @@ struct _EmpathyRosterWindowPriv { GtkWidget *button_account_settings; GtkWidget *spinner_loading; - GMenu *menubuttonmodel; + GMenu *menumodel; GMenu *rooms_section; GtkWidget *balance_vbox; @@ -1257,7 +1257,7 @@ empathy_roster_window_finalize (GObject *window) g_object_unref (self->priv->gsettings_contacts); g_object_unref (self->priv->individual_manager); - g_object_unref (self->priv->menubuttonmodel); + g_object_unref (self->priv->menumodel); g_object_unref (self->priv->rooms_section); G_OBJECT_CLASS (empathy_roster_window_parent_class)->finalize (window); @@ -2071,9 +2071,6 @@ static void empathy_roster_window_constructed (GObject *self) { G_OBJECT_CLASS (empathy_roster_window_parent_class)->constructed (self); - - gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (self), - FALSE); } static void @@ -2123,59 +2120,6 @@ contacts_loaded_cb (EmpathyIndividualManager *manager, } static void -roster_window_menu_closed_cb (GtkWidget *button, - GtkMenu *menu) -{ - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE); -} - -static void -roster_window_menu_position_func (GtkMenu *menu, - int *x, - int *y, - gboolean *push_in, - gpointer user_data) -{ - GtkWidget *button = user_data; - GtkAllocation allocation; - int w = gtk_widget_get_allocated_width (GTK_WIDGET (menu)); - - gtk_widget_get_allocation (button, &allocation); - gdk_window_get_root_coords (gtk_widget_get_window (button), - allocation.x + allocation.width - w, - allocation.y + allocation.height, - x, y); - - *push_in = TRUE; -} - -static gboolean -roster_window_menu_button_press_cb (GtkWidget *button, - GdkEventButton *event, - EmpathyRosterWindow *self) -{ - if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) - { - GtkWidget *menu = gtk_menu_new_from_model ( - G_MENU_MODEL (self->priv->menubuttonmodel)); - - g_signal_connect (menu, "selection-done", - G_CALLBACK (gtk_widget_destroy), NULL); - gtk_menu_attach_to_widget (GTK_MENU (menu), button, - roster_window_menu_closed_cb); - gtk_menu_popup (GTK_MENU (menu), NULL, NULL, - roster_window_menu_position_func, button, - event->button, event->time); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); - - return TRUE; - } - - return FALSE; -} - -static void empathy_roster_window_init (EmpathyRosterWindow *self) { GtkBuilder *gui; @@ -2183,7 +2127,6 @@ empathy_roster_window_init (EmpathyRosterWindow *self) gchar *filename; GtkTreeModel *model; GtkWidget *search_vbox; - GtkWidget *button; self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, EMPATHY_TYPE_ROSTER_WINDOW, EmpathyRosterWindowPriv); @@ -2245,32 +2188,18 @@ empathy_roster_window_init (EmpathyRosterWindow *self) filename = empathy_file_lookup ("empathy-roster-window-menubar.ui", "src"); gui = empathy_builder_get_file (filename, - "menubutton", &self->priv->menubuttonmodel, + "menubutton", &self->priv->menumodel, "rooms", &self->priv->rooms_section, NULL); g_free (filename); - g_object_ref (self->priv->menubuttonmodel); + g_object_ref (self->priv->menumodel); g_object_ref (self->priv->rooms_section); - /* Disable map if built without champlain */ -#ifndef HAVE_LIBCHAMPLAIN - { - GAction *view_show_map; - - view_show_map = g_action_map_lookup_action (G_ACTION_MAP (self), - "view_show_map"); - g_simple_action_set_enabled (G_SIMPLE_ACTION (view_show_map), FALSE); - } -#endif - /* Set up connection related actions. */ roster_window_connection_items_setup (self); roster_window_favorite_chatroom_menu_setup (self); - /* FIXME: display accelerators in menu */ - /* FIXME: make menu appear on <Alt> */ - g_object_unref (gui); /* Set up contact list. */ @@ -2294,20 +2223,6 @@ empathy_roster_window_init (EmpathyRosterWindow *self) self->priv->throbber, FALSE, TRUE, 0); - /* Set up the menu */ - - button = gtk_toggle_button_new (); - gtk_button_set_image (GTK_BUTTON (button), - gtk_image_new_from_icon_name ("user-available-symbolic", - GTK_ICON_SIZE_SMALL_TOOLBAR)); - gtk_widget_show (button); - gtk_box_pack_start (GTK_BOX (self->priv->presence_toolbar), - button, - FALSE, TRUE, 0); - - g_signal_connect (button, "button-press-event", - G_CALLBACK (roster_window_menu_button_press_cb), self); - /* XXX: this class is designed to live for the duration of the program, * so it's got a race condition between its signal handlers and its * finalization. The class is planned to be removed, so we won't fix @@ -2429,3 +2344,11 @@ empathy_roster_window_new (GtkApplication *app) "application", app, NULL); } + +GMenuModel * +empathy_roster_window_get_menu_model (EmpathyRosterWindow *self) +{ + g_return_val_if_fail (EMPATHY_IS_ROSTER_WINDOW (self), NULL); + + return G_MENU_MODEL (self->priv->menumodel); +} diff --git a/src/empathy-roster-window.h b/src/empathy-roster-window.h index 82fedb79d..4620a9980 100644 --- a/src/empathy-roster-window.h +++ b/src/empathy-roster-window.h @@ -60,6 +60,8 @@ void empathy_roster_window_show_preferences (EmpathyRosterWindow *self, void empathy_roster_window_set_shell_running (EmpathyRosterWindow *self, gboolean shell_running); +GMenuModel *empathy_roster_window_get_menu_model (EmpathyRosterWindow *self); + G_END_DECLS #endif /* __EMPATHY_ROSTER_WINDOW_H__ */ diff --git a/src/empathy.c b/src/empathy.c index 774365bf7..9ba923602 100644 --- a/src/empathy.c +++ b/src/empathy.c @@ -332,9 +332,6 @@ empathy_app_command_line (GApplication *app, { GError *error = NULL; TpDBusDaemon *dbus; - GtkBuilder *gui; - GMenuModel *menu; - char *filename; /* Create the FT factory */ self->ft_factory = empathy_ft_factory_dup_singleton (); @@ -352,20 +349,11 @@ empathy_app_command_line (GApplication *app, self->activated = TRUE; - /* set up the app menu */ - filename = empathy_file_lookup ( - "empathy-roster-window-menubar.ui", "src"); - gui = empathy_builder_get_file (filename, - "menubutton", &menu, - NULL); - - gtk_application_set_app_menu (GTK_APPLICATION (self), menu); - - g_free (filename); - g_object_unref (gui); - /* Setting up UI */ self->window = empathy_roster_window_new (GTK_APPLICATION (app)); + gtk_application_set_app_menu (GTK_APPLICATION (self), + empathy_roster_window_get_menu_model ( + EMPATHY_ROSTER_WINDOW (self->window))); gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (self->window)); |