void empathy_chat_window_present_chat (EmpathyChat *chat) { EmpathyChatWindow *window; EmpathyChatWindowPriv *priv; g_return_if_fail (EMPATHY_IS_CHAT (chat)); window = chat_window_find_chat (chat); /* If the chat has no window, create one */ if (window == NULL) { window = empathy_chat_window_get_default (); if (!window) { window = empathy_chat_window_new (); } empathy_chat_window_add_chat (window, chat); } priv = GET_PRIV (window); empathy_chat_window_switch_to_chat (window, chat); empathy_window_present (GTK_WINDOW (priv->dialog), TRUE); gtk_widget_grab_focus (chat->input_text_view); }
static void status_icon_set_visibility (EmpathyStatusIcon *icon, gboolean visible, gboolean store) { EmpathyStatusIconPriv *priv = GET_PRIV (icon); if (store) { empathy_conf_set_bool (empathy_conf_get (), EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN, !visible); } if (!visible) { empathy_window_iconify (priv->window, priv->icon); } else { GList *accounts; empathy_window_present (GTK_WINDOW (priv->window), TRUE); /* Show the accounts dialog if there is no enabled accounts */ accounts = mc_accounts_list_by_enabled (TRUE); if (accounts) { mc_accounts_list_free (accounts); } else { DEBUG ("No enabled account, Showing account dialog"); empathy_accounts_dialog_show (GTK_WINDOW (priv->window), NULL); } } }
static void status_icon_set_visibility (EmpathyStatusIcon *icon, gboolean visible, gboolean store) { EmpathyStatusIconPriv *priv = GET_PRIV (icon); if (store) { empathy_conf_set_bool (empathy_conf_get (), EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN, !visible); } if (!visible) { empathy_window_iconify (priv->window, priv->icon); } else { GList *accounts; GList *l; gboolean one_enabled = FALSE; empathy_window_present (GTK_WINDOW (priv->window), TRUE); /* Show the accounts dialog if there is no enabled accounts */ accounts = empathy_account_manager_dup_accounts (priv->account_manager); for (l = accounts ; l != NULL ; l = g_list_next (l)) { one_enabled = empathy_account_is_enabled (EMPATHY_ACCOUNT (l->data)) || one_enabled; g_object_unref (l->data); } g_list_free (accounts); if (!one_enabled) { DEBUG ("No enabled account, Showing account dialog"); empathy_accounts_dialog_show (GTK_WINDOW (priv->window), NULL); } } }
static void status_icon_set_visibility (EmpathyStatusIcon *icon, gboolean visible, gboolean store) { EmpathyStatusIconPriv *priv = GET_PRIV (icon); if (store) { empathy_conf_set_bool (empathy_conf_get (), EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN, !visible); } if (!visible) { empathy_window_iconify (priv->window, priv->icon); } else { empathy_window_present (GTK_WINDOW (priv->window)); } }
static void clicked_cb (GtkButton *button, gpointer user_data) { EmpathyIrcNetworkChooserPriv *priv = GET_PRIV (button); GtkWindow *window; if (priv->dialog != NULL) goto out; window = empathy_get_toplevel_window (GTK_WIDGET (button)); priv->dialog = empathy_irc_network_chooser_dialog_new (priv->settings, priv->network, window); gtk_widget_show_all (priv->dialog); tp_g_signal_connect_object (priv->dialog, "response", G_CALLBACK (dialog_response_cb), button, 0); out: empathy_window_present (GTK_WINDOW (priv->dialog)); }
GtkWidget * empathy_main_window_show (void) { EmpathyMainWindow *window; EmpathyContactList *list_iface; EmpathyContactMonitor *monitor; GtkBuilder *gui; EmpathyConf *conf; GtkWidget *sw; GtkToggleAction *show_offline_widget; GtkWidget *ebox; GtkAction *show_map_widget; GtkToolItem *item; gboolean show_offline; gchar *filename; GSList *l; if (main_window) { empathy_window_present (GTK_WINDOW (main_window->window)); return main_window->window; } main_window = g_new0 (EmpathyMainWindow, 1); window = main_window; /* Set up interface */ filename = empathy_file_lookup ("empathy-main-window.ui", "src"); gui = empathy_builder_get_file (filename, "main_window", &window->window, "main_vbox", &window->main_vbox, "errors_vbox", &window->errors_vbox, "ui_manager", &window->ui_manager, "view_show_offline", &show_offline_widget, "view_show_protocols", &window->show_protocols, "view_sort_by_name", &window->sort_by_name, "view_sort_by_status", &window->sort_by_status, "view_normal_size_with_avatars", &window->normal_with_avatars, "view_normal_size", &window->normal_size, "view_compact_size", &window->compact_size, "view_history", &window->view_history, "view_show_map", &show_map_widget, "room_join_favorites", &window->room_join_favorites, "presence_toolbar", &window->presence_toolbar, "roster_scrolledwindow", &sw, NULL); g_free (filename); empathy_builder_connect (gui, window, "main_window", "destroy", main_window_destroy_cb, "main_window", "key-press-event", main_window_key_press_event_cb, "chat_quit", "activate", main_window_chat_quit_cb, "chat_new_message", "activate", main_window_chat_new_message_cb, "chat_new_call", "activate", main_window_chat_new_call_cb, "view_history", "activate", main_window_view_history_cb, "room_join_new", "activate", main_window_room_join_new_cb, "room_join_favorites", "activate", main_window_room_join_favorites_cb, "room_manage_favorites", "activate", main_window_room_manage_favorites_cb, "chat_add_contact", "activate", main_window_chat_add_contact_cb, "view_show_ft_manager", "activate", main_window_view_show_ft_manager, "view_show_offline", "toggled", main_window_view_show_offline_cb, "view_show_protocols", "toggled", main_window_view_show_protocols_cb, "view_sort_by_name", "changed", main_window_view_sort_contacts_cb, "view_normal_size_with_avatars", "changed", main_window_view_contacts_list_size_cb, "view_show_map", "activate", main_window_view_show_map_cb, "edit", "activate", main_window_edit_cb, "edit_accounts", "activate", main_window_edit_accounts_cb, "edit_personal_information", "activate", main_window_edit_personal_information_cb, "edit_preferences", "activate", main_window_edit_preferences_cb, "help_about", "activate", main_window_help_about_cb, "help_debug", "activate", main_window_help_debug_cb, "help_contents", "activate", main_window_help_contents_cb, NULL); /* Set up connection related widgets. */ main_window_connection_items_setup (window, gui); g_object_ref (window->ui_manager); g_object_unref (gui); #if !HAVE_LIBCHAMPLAIN gtk_action_set_visible (show_map_widget, FALSE); #endif window->account_manager = tp_account_manager_dup (); tp_account_manager_prepare_async (window->account_manager, NULL, account_manager_prepared_cb, window); window->errors = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, NULL); window->status_changed_handlers = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, NULL); /* Set up menu */ main_window_favorite_chatroom_menu_setup (window); window->edit_context = gtk_ui_manager_get_widget (window->ui_manager, "/menubar/edit/edit_context"); window->edit_context_separator = gtk_ui_manager_get_widget (window->ui_manager, "/menubar/edit/edit_context_separator"); gtk_widget_hide (window->edit_context); gtk_widget_hide (window->edit_context_separator); /* Set up contact list. */ empathy_status_presets_get_all (); /* Set up presence chooser */ window->presence_chooser = empathy_presence_chooser_new (); gtk_widget_show (window->presence_chooser); item = gtk_tool_item_new (); gtk_widget_show (GTK_WIDGET (item)); gtk_container_add (GTK_CONTAINER (item), window->presence_chooser); gtk_tool_item_set_is_important (item, TRUE); gtk_tool_item_set_expand (item, TRUE); gtk_toolbar_insert (GTK_TOOLBAR (window->presence_toolbar), item, -1); /* Set up the throbber */ ebox = gtk_event_box_new (); gtk_event_box_set_visible_window (GTK_EVENT_BOX (ebox), FALSE); gtk_widget_set_tooltip_text (ebox, _("Show and edit accounts")); g_signal_connect (ebox, "button-press-event", G_CALLBACK (main_window_throbber_button_press_event_cb), window); gtk_widget_show (ebox); window->throbber = ephy_spinner_new (); ephy_spinner_set_size (EPHY_SPINNER (window->throbber), GTK_ICON_SIZE_LARGE_TOOLBAR); gtk_container_add (GTK_CONTAINER (ebox), window->throbber); gtk_widget_show (window->throbber); item = gtk_tool_item_new (); gtk_container_add (GTK_CONTAINER (item), ebox); gtk_toolbar_insert (GTK_TOOLBAR (window->presence_toolbar), item, -1); gtk_widget_show (GTK_WIDGET (item)); list_iface = EMPATHY_CONTACT_LIST (empathy_contact_manager_dup_singleton ()); monitor = empathy_contact_list_get_monitor (list_iface); window->list_store = empathy_contact_list_store_new (list_iface); window->list_view = empathy_contact_list_view_new (window->list_store, EMPATHY_CONTACT_LIST_FEATURE_ALL, EMPATHY_CONTACT_FEATURE_ALL); g_signal_connect (monitor, "contact-presence-changed", G_CALLBACK (main_window_contact_presence_changed_cb), window); window->butterfly_log_migration_contact_added_id = g_signal_connect (monitor, "contact-added", G_CALLBACK (main_window_contact_added_cb), window); g_object_unref (list_iface); gtk_widget_show (GTK_WIDGET (window->list_view)); gtk_container_add (GTK_CONTAINER (sw), GTK_WIDGET (window->list_view)); g_signal_connect (window->list_view, "row-activated", G_CALLBACK (main_window_row_activated_cb), window); /* Load user-defined accelerators. */ main_window_accels_load (); /* Set window size. */ empathy_geometry_bind (GTK_WINDOW (window->window), GEOMETRY_NAME); /* Enable event handling */ window->event_manager = empathy_event_manager_dup_singleton (); g_signal_connect (window->event_manager, "event-added", G_CALLBACK (main_window_event_added_cb), window); g_signal_connect (window->event_manager, "event-removed", G_CALLBACK (main_window_event_removed_cb), window); g_signal_connect (window->account_manager, "account-validity-changed", G_CALLBACK (main_window_account_validity_changed_cb), window); g_signal_connect (window->account_manager, "account-removed", G_CALLBACK (main_window_account_removed_cb), window); g_signal_connect (window->account_manager, "account-disabled", G_CALLBACK (main_window_account_disabled_cb), window); l = empathy_event_manager_get_events (window->event_manager); while (l) { main_window_event_added_cb (window->event_manager, l->data, window); l = l->next; } conf = empathy_conf_get (); /* Show offline ? */ empathy_conf_get_bool (conf, EMPATHY_PREFS_CONTACTS_SHOW_OFFLINE, &show_offline); empathy_conf_notify_add (conf, EMPATHY_PREFS_CONTACTS_SHOW_OFFLINE, main_window_notify_show_offline_cb, show_offline_widget); gtk_toggle_action_set_active (show_offline_widget, show_offline); /* Show protocol ? */ empathy_conf_notify_add (conf, EMPATHY_PREFS_UI_SHOW_PROTOCOLS, (EmpathyConfNotifyFunc) main_window_notify_show_protocols_cb, window); main_window_notify_show_protocols_cb (conf, EMPATHY_PREFS_UI_SHOW_PROTOCOLS, window); /* Sort by name / by status ? */ empathy_conf_notify_add (conf, EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM, (EmpathyConfNotifyFunc) main_window_notify_sort_contact_cb, window); main_window_notify_sort_contact_cb (conf, EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM, window); /* Contacts list size */ empathy_conf_notify_add (conf, EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST, (EmpathyConfNotifyFunc) main_window_notify_contact_list_size_cb, window); empathy_conf_notify_add (conf, EMPATHY_PREFS_UI_SHOW_AVATARS, (EmpathyConfNotifyFunc) main_window_notify_contact_list_size_cb, window); main_window_notify_contact_list_size_cb (conf, EMPATHY_PREFS_UI_SHOW_AVATARS, window); return window->window; }