[ekiga] Made the main window use the new api for selected objects in the roster view and call history view w
- From: Julien Puydt <jpuydt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga] Made the main window use the new api for selected objects in the roster view and call history view w
- Date: Tue, 12 Oct 2010 20:45:06 +0000 (UTC)
commit 5d5fe03908a676db3852d3dd8943324a8aaf42e8
Author: Snark <jpuydt gnome org>
Date: Tue Oct 12 22:45:27 2010 +0200
Made the main window use the new api for selected objects in the roster view and call history view widgets
As was the goal, it didn't make the widgets' code that much more complex,
and it simplified the main window's code quite considerably.
This fixes bug #631735.
src/gui/main_window.cpp | 155 +++++++----------------------------------------
1 files changed, 23 insertions(+), 132 deletions(-)
---
diff --git a/src/gui/main_window.cpp b/src/gui/main_window.cpp
index d7220d5..1b4c5f2 100644
--- a/src/gui/main_window.cpp
+++ b/src/gui/main_window.cpp
@@ -204,8 +204,6 @@ struct _EkigaMainWindowPrivate
std::string received_video_codec;
std::string received_audio_codec;
- boost::signals::connection selected_item_updated_connection;
- boost::signals::connection selected_item_removed_connection;
std::vector<boost::signals::connection> connections;
};
@@ -274,17 +272,6 @@ static void ekiga_main_window_incoming_call_notify (EkigaMainWindow *mw,
boost::shared_ptr<Ekiga::Call> call);
#endif
-
-/* Callbacks */
-/* DESCRIPTION : This callback is called when the user selects a presentity
- * in the roster
- * BEHAVIOR : Populates the Chat->Contact submenu
- * PRE : /
- */
-static void on_presentity_selected (GtkWidget* view,
- Ekiga::Presentity* presentity,
- gpointer data);
-
/* DESCRIPTION : This callback is called when the chat window alerts about
* unread messages
* BEHAVIOR : Plays a sound (if enabled)
@@ -1845,54 +1832,21 @@ gnomemeeting_tray_hack_cb (G_GNUC_UNUSED gpointer data)
}
static void
-on_selected_item_removed (EkigaMainWindow* mw)
-{
- GtkWidget *menu = gtk_menu_get_widget (mw->priv->main_menu, "contact");
- mw->priv->selected_item_updated_connection.disconnect ();
- mw->priv->selected_item_removed_connection.disconnect ();
- gtk_widget_set_sensitive (menu, FALSE);
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu), NULL);
-}
-
-static void
-on_selected_item_updated (Ekiga::LiveObject* live,
- EkigaMainWindow* mw)
-{
- MenuBuilderGtk builder;
- GtkWidget *menu = gtk_menu_get_widget (mw->priv->main_menu, "contact");
-
- gtk_widget_set_sensitive (menu, TRUE);
-
- if (live->populate_menu (builder)) {
-
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu), builder.menu);
- gtk_widget_show_all (builder.menu);
- }
- else {
-
- gtk_widget_set_sensitive (menu, FALSE);
- g_object_ref_sink (builder.menu);
- g_object_unref (builder.menu);
- }
-}
-
-static void
-on_item_selected (EkigaMainWindow* mw,
- Ekiga::LiveObject* live)
+on_history_selection_changed (G_GNUC_UNUSED GtkWidget* view,
+ gpointer self)
{
- GtkWidget *menu = gtk_menu_get_widget (mw->priv->main_menu, "contact");
+ EkigaMainWindow *mw = EKIGA_MAIN_WINDOW (self);
+ gint section;
+ GtkWidget* menu = gtk_menu_get_widget (mw->priv->main_menu, "contact");
- mw->priv->selected_item_updated_connection.disconnect ();
- mw->priv->selected_item_removed_connection.disconnect ();
+ section = gtk_notebook_get_current_page (GTK_NOTEBOOK (mw->priv->main_notebook));
- if (live != NULL) {
+ if (section == mw->priv->call_history_page_number) {
MenuBuilderGtk builder;
gtk_widget_set_sensitive (menu, TRUE);
- mw->priv->selected_item_updated_connection = live->updated.connect (boost::bind (&on_selected_item_updated, live, mw));
- mw->priv->selected_item_removed_connection = live->removed.connect (boost::bind (&on_selected_item_removed, mw));
- if (live->populate_menu (builder)) {
+ if (call_history_view_gtk_populate_menu_for_selected (CALL_HISTORY_VIEW_GTK (mw->priv->call_history_view), builder)) {
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu), builder.menu);
gtk_widget_show_all (builder.menu);
@@ -1910,54 +1864,21 @@ on_item_selected (EkigaMainWindow* mw,
}
static void
-on_history_contact_selected (G_GNUC_UNUSED GtkWidget* view,
- History::Contact* contact,
+on_roster_selection_changed (G_GNUC_UNUSED GtkWidget* view,
gpointer self)
{
EkigaMainWindow *mw = EKIGA_MAIN_WINDOW (self);
- on_item_selected (mw, (Ekiga::LiveObject*)contact);
-}
-
-static void
-on_presentity_selected (G_GNUC_UNUSED GtkWidget* view,
- Ekiga::Presentity* presentity,
- gpointer self)
-{
- EkigaMainWindow *mw = EKIGA_MAIN_WINDOW (self);
- on_item_selected (mw, (Ekiga::LiveObject*)presentity);
-}
-
-static void
-on_heap_selected (G_GNUC_UNUSED GtkWidget* view,
- Ekiga::Heap* heap,
- gpointer self)
-{
- EkigaMainWindow *mw = EKIGA_MAIN_WINDOW (self);
- on_item_selected (mw, (Ekiga::LiveObject*)heap);
-}
-
-
-static void
-on_heap_group_selected (G_GNUC_UNUSED GtkWidget* view,
- Ekiga::Heap* heap,
- gchar* group,
- gpointer self)
-{
- EkigaMainWindow *mw = EKIGA_MAIN_WINDOW (self);
- GtkWidget *menu = gtk_menu_get_widget (mw->priv->main_menu, "contact");
+ gint section;
+ GtkWidget* menu = gtk_menu_get_widget (mw->priv->main_menu, "contact");
- mw->priv->selected_item_updated_connection.disconnect ();
- mw->priv->selected_item_removed_connection.disconnect ();
+ section = gtk_notebook_get_current_page (GTK_NOTEBOOK (mw->priv->main_notebook));
- if (heap && group != NULL) {
+ if (section == mw->priv->roster_view_page_number) {
MenuBuilderGtk builder;
gtk_widget_set_sensitive (menu, TRUE);
- // we can't get updates about the groups as the contact api currently stands
- mw->priv->selected_item_updated_connection = heap->updated.connect (boost::bind (&on_selected_item_removed, mw));
- mw->priv->selected_item_removed_connection = heap->removed.connect (boost::bind (&on_selected_item_removed, mw));
- if (heap->populate_menu_for_group (group, builder)) {
+ if (roster_view_gtk_populate_menu_for_selected (ROSTER_VIEW_GTK (mw->priv->roster_view), builder)) {
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu), builder.menu);
gtk_widget_show_all (builder.menu);
@@ -2010,39 +1931,13 @@ panel_section_changed_nt (G_GNUC_UNUSED gpointer id,
menu = gtk_menu_get_widget (mw->priv->main_menu, "dialpad");
gtk_radio_menu_select_with_widget (menu, section);
- if (section == mw->priv->roster_view_page_number) {
-
- Ekiga::Heap* heap = NULL;
- Ekiga::Presentity* presentity = NULL;
- gchar* group = NULL;
- roster_view_gtk_get_selected (ROSTER_VIEW_GTK (mw->priv->roster_view),
- &heap,
- &group,
- &presentity);
- if (presentity)
- on_presentity_selected (mw->priv->roster_view, presentity, data);
-
- if (heap && group == NULL)
- on_heap_selected (mw->priv->roster_view, heap, data);
-
- if (heap && group != NULL)
- on_heap_group_selected (mw->priv->roster_view, heap, group, data);
-
- if (group)
- g_free (group);
- } else if (section == mw->priv->call_history_page_number) {
-
- History::Contact* contact = NULL;
- call_history_view_gtk_get_selected (CALL_HISTORY_VIEW_GTK (mw->priv->call_history_view), &contact);
-
- if (contact)
- on_history_contact_selected (mw->priv->call_history_view, contact, data);
-
- } else { // we're not on a page where that menu makes sense
+ if (section == mw->priv->roster_view_page_number)
+ on_roster_selection_changed (mw->priv->roster_view, data);
+ else if (section == mw->priv->call_history_page_number)
+ on_roster_selection_changed (mw->priv->call_history_view, data);
+ else { // we're not on a page where that menu makes sense
menu = gtk_menu_get_widget (mw->priv->main_menu, "contact");
- mw->priv->selected_item_updated_connection.disconnect ();
- mw->priv->selected_item_removed_connection.disconnect ();
gtk_widget_set_sensitive (menu, FALSE);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu), NULL);
}
@@ -3547,12 +3442,8 @@ ekiga_main_window_init_contact_list (EkigaMainWindow *mw)
label = gtk_label_new (_("Contacts"));
mw->priv->roster_view = roster_view_gtk_new (*presence_core);
mw->priv->roster_view_page_number = gtk_notebook_append_page (GTK_NOTEBOOK (mw->priv->main_notebook), mw->priv->roster_view, label);
- g_signal_connect (G_OBJECT (mw->priv->roster_view), "heap-selected",
- G_CALLBACK (on_heap_selected), mw);
- g_signal_connect (G_OBJECT (mw->priv->roster_view), "heap-group-selected",
- G_CALLBACK (on_heap_group_selected), mw);
- g_signal_connect (G_OBJECT (mw->priv->roster_view), "presentity-selected",
- G_CALLBACK (on_presentity_selected), mw);
+ g_signal_connect (G_OBJECT (mw->priv->roster_view), "selection-changed",
+ G_CALLBACK (on_roster_selection_changed), mw);
}
@@ -3590,8 +3481,8 @@ ekiga_main_window_init_history (EkigaMainWindow *mw)
label = gtk_label_new (_("Call history"));
mw->priv->call_history_page_number = gtk_notebook_append_page (GTK_NOTEBOOK (mw->priv->main_notebook), mw->priv->call_history_view, label);
- g_signal_connect (G_OBJECT (mw->priv->call_history_view), "contact-selected",
- G_CALLBACK (on_history_contact_selected), mw);
+ g_signal_connect (G_OBJECT (mw->priv->call_history_view), "selection-changed",
+ G_CALLBACK (on_history_selection_changed), mw);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]