static void new_chatroom_dialog_join (EmpathyNewChatroomDialog *dialog) { EmpathyAccountChooser *account_chooser; McAccount *account; const gchar *room; const gchar *server = NULL; gchar *room_name = NULL; room = gtk_entry_get_text (GTK_ENTRY (dialog->entry_room)); server = gtk_entry_get_text (GTK_ENTRY (dialog->entry_server)); account_chooser = EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser); account = empathy_account_chooser_get_account (account_chooser); if (!EMP_STR_EMPTY (server)) { room_name = g_strconcat (room, "@", server, NULL); } else { room_name = g_strdup (room); } DEBUG ("Requesting channel for '%s'", room_name); empathy_dispatcher_join_muc (account, room_name, NULL, NULL); g_free (room_name); }
static void log_window_chats_populate (EmpathyLogWindow *window) { EmpathyAccountChooser *account_chooser; TpAccount *account; GtkTreeView *view; GtkTreeModel *model; GtkTreeSelection *selection; GtkListStore *store; account_chooser = EMPATHY_ACCOUNT_CHOOSER (window->account_chooser_chats); account = empathy_account_chooser_dup_account (account_chooser); view = GTK_TREE_VIEW (window->treeview_chats); model = gtk_tree_view_get_model (view); selection = gtk_tree_view_get_selection (view); store = GTK_LIST_STORE (model); if (account == NULL) { gtk_list_store_clear (store); return; } /* Block signals to stop the logs being retrieved prematurely */ g_signal_handlers_block_by_func (selection, log_window_chats_changed_cb, window); gtk_list_store_clear (store); tpl_log_manager_get_chats_async (window->log_manager, account, log_manager_got_chats_cb, (gpointer) window); }
GtkWidget * empathy_account_chooser_new (void) { EmpathyAccountChooserPriv *priv; McAccountMonitor *monitor; GtkWidget *chooser; monitor = mc_account_monitor_new (); chooser = g_object_new (EMPATHY_TYPE_ACCOUNT_CHOOSER, NULL); priv = GET_PRIV (chooser); priv->mc = empathy_mission_control_new (); priv->monitor = mc_account_monitor_new (); g_signal_connect (priv->monitor, "account-created", G_CALLBACK (account_chooser_account_created_cb), chooser); g_signal_connect (priv->monitor, "account-deleted", G_CALLBACK (account_chooser_account_deleted_cb), chooser); priv->token = empathy_connect_to_account_status_changed (priv->mc, G_CALLBACK (account_chooser_status_changed_cb), chooser, NULL); account_chooser_setup (EMPATHY_ACCOUNT_CHOOSER (chooser)); return chooser; }
static void contact_widget_set_contact (EmpathyContactWidget *information, EmpathyContact *contact) { if (contact == information->contact) return; contact_widget_remove_contact (information); if (contact) { TpConnection *connection; connection = empathy_contact_get_connection (contact); information->contact = g_object_ref (contact); information->factory = empathy_tp_contact_factory_dup_singleton (connection); } /* set the selected account to be the account this contact came from */ if (contact && EMPATHY_IS_ACCOUNT_CHOOSER (information->widget_account)) { empathy_account_chooser_set_account ( EMPATHY_ACCOUNT_CHOOSER (information->widget_account), empathy_contact_get_account (contact)); } /* Update information for widgets */ contact_widget_contact_update (information); contact_widget_groups_update (information); contact_widget_details_update (information); contact_widget_client_update (information); contact_widget_location_update (information); }
static void empathy_account_chooser_init (EmpathyAccountChooser *chooser) { EmpathyAccountChooserPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (chooser, EMPATHY_TYPE_ACCOUNT_CHOOSER, EmpathyAccountChooserPriv); chooser->priv = priv; priv->set_active_item = FALSE; priv->filter = NULL; priv->filter_data = NULL; priv->manager = empathy_account_manager_dup_singleton (); g_signal_connect (priv->manager, "account-created", G_CALLBACK (account_chooser_account_created_cb), chooser); g_signal_connect (priv->manager, "account-deleted", G_CALLBACK (account_chooser_account_deleted_cb), chooser); g_signal_connect (priv->manager, "account-connection-changed", G_CALLBACK (account_chooser_connection_changed_cb), chooser); account_chooser_setup (EMPATHY_ACCOUNT_CHOOSER (chooser)); }
static void new_chatroom_dialog_update_widgets (EmpathyNewChatroomDialog *dialog) { EmpathyAccountChooser *account_chooser; const gchar *protocol; account_chooser = EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser); if (dialog->account == NULL) return; protocol = tp_account_get_protocol (dialog->account); gtk_entry_set_text (GTK_ENTRY (dialog->entry_server), ""); /* hardcode here known protocols */ if (strcmp (protocol, "jabber") == 0) { gtk_widget_set_sensitive (dialog->entry_server, TRUE); } else if (strcmp (protocol, "local-xmpp") == 0) { gtk_widget_set_sensitive (dialog->entry_server, FALSE); } else if (strcmp (protocol, "irc") == 0) { gtk_widget_set_sensitive (dialog->entry_server, FALSE); } else { gtk_widget_set_sensitive (dialog->entry_server, TRUE); } update_join_button_sensitivity (dialog); /* Final set up of the dialog */ gtk_widget_grab_focus (dialog->entry_room); }
static void contact_blocking_dialog_refilter_account_chooser ( EmpathyContactBlockingDialog *self) { EmpathyAccountChooser *chooser = EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser); TpConnection *conn; gboolean enabled; DEBUG ("Refiltering account chooser"); /* set the filter to refilter the account chooser */ self->priv->block_account_changed++; empathy_account_chooser_set_filter (chooser, contact_blocking_dialog_filter_account_chooser, self); self->priv->block_account_changed--; conn = empathy_account_chooser_get_connection (chooser); enabled = (empathy_account_chooser_get_account (chooser) != NULL && conn != NULL && tp_proxy_has_interface_by_id (conn, TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_BLOCKING)); if (!enabled) DEBUG ("No account selected"); gtk_widget_set_sensitive (self->priv->add_button, enabled); gtk_widget_set_sensitive (self->priv->add_contact_entry, enabled); contact_blocking_dialog_account_changed (self->priv->account_chooser, self); }
static void contact_widget_change_contact (EmpathyContactWidget *information) { EmpathyTpContactFactory *factory; TpConnection *connection; connection = empathy_account_chooser_get_connection ( EMPATHY_ACCOUNT_CHOOSER (information->widget_account)); if (!connection) return; factory = empathy_tp_contact_factory_dup_singleton (connection); if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID) { const gchar *id; id = gtk_entry_get_text (GTK_ENTRY (information->widget_id)); if (!EMP_STR_EMPTY (id)) { empathy_tp_contact_factory_get_from_id (factory, id, contact_widget_got_contact_cb, information, NULL, G_OBJECT (information->vbox_contact_widget)); } } else { empathy_tp_contact_factory_get_from_handle (factory, tp_connection_get_self_handle (connection), contact_widget_got_contact_cb, information, NULL, G_OBJECT (information->vbox_contact_widget)); } g_object_unref (factory); }
static void account_chooser_dispose (GObject *object) { EmpathyAccountChooser *self = EMPATHY_ACCOUNT_CHOOSER (object); g_clear_object (&self->priv->manager); g_clear_object (&self->priv->select_when_ready); G_OBJECT_CLASS (empathy_account_chooser_parent_class)->dispose (object); }
static void chatrooms_window_model_refresh_data (EmpathyChatroomsWindow *window, gboolean first_time) { GtkTreeView *view; GtkTreeSelection *selection; GtkTreeModel *model; GtkListStore *store; GtkTreeIter iter; GtkTreeViewColumn *column; EmpathyAccountChooser *account_chooser; EmpathyAccount *account; GList *chatrooms, *l; view = GTK_TREE_VIEW (window->treeview); selection = gtk_tree_view_get_selection (view); model = gtk_tree_view_get_model (view); store = GTK_LIST_STORE (model); /* Look up chatrooms */ account_chooser = EMPATHY_ACCOUNT_CHOOSER (window->account_chooser); account = empathy_account_chooser_dup_account (account_chooser); chatrooms = empathy_chatroom_manager_get_chatrooms (window->manager, account); /* Sort out columns, we only show the server column for * selected protocol types, such as Jabber. */ if (account) { column = gtk_tree_view_get_column (view, window->room_column); gtk_tree_view_column_set_visible (column, TRUE); } else { column = gtk_tree_view_get_column (view, window->room_column); gtk_tree_view_column_set_visible (column, FALSE); } /* Clean out the store */ gtk_list_store_clear (store); /* Populate with chatroom list. */ for (l = chatrooms; l; l = l->next) { chatrooms_window_model_add (window, l->data, FALSE); } if (gtk_tree_model_get_iter_first (model, &iter)) { gtk_tree_selection_select_iter (selection, &iter); } if (account) { g_object_unref (account); } g_list_free (chatrooms); }
static void account_chooser_ready_cb (EmpathyAccountChooser *chooser, EmpathyLogWindow *window) { gtk_notebook_set_current_page (GTK_NOTEBOOK (window->notebook), 1); /* We'll display the account once the model has been populate with the chats * of this account. */ empathy_account_chooser_set_account (EMPATHY_ACCOUNT_CHOOSER ( window->account_chooser_chats), window->selected_account); }
static void log_window_chats_set_selected (EmpathyLogWindow *window, EmpathyAccount *account, const gchar *chat_id, gboolean is_chatroom) { EmpathyAccountChooser *account_chooser; GtkTreeView *view; GtkTreeModel *model; GtkTreeSelection *selection; GtkTreeIter iter; GtkTreePath *path; gboolean ok; account_chooser = EMPATHY_ACCOUNT_CHOOSER (window->account_chooser_chats); empathy_account_chooser_set_account (account_chooser, account); view = GTK_TREE_VIEW (window->treeview_chats); model = gtk_tree_view_get_model (view); selection = gtk_tree_view_get_selection (view); if (!gtk_tree_model_get_iter_first (model, &iter)) { return; } for (ok = TRUE; ok; ok = gtk_tree_model_iter_next (model, &iter)) { EmpathyAccount *this_account; gchar *this_chat_id; gboolean this_is_chatroom; gtk_tree_model_get (model, &iter, COL_CHAT_ACCOUNT, &this_account, COL_CHAT_ID, &this_chat_id, COL_CHAT_IS_CHATROOM, &this_is_chatroom, -1); if (empathy_account_equal (this_account, account) && strcmp (this_chat_id, chat_id) == 0 && this_is_chatroom == is_chatroom) { gtk_tree_selection_select_iter (selection, &iter); path = gtk_tree_model_get_path (model, &iter); gtk_tree_view_scroll_to_cell (view, path, NULL, TRUE, 0.5, 0.0); gtk_tree_path_free (path); g_object_unref (this_account); g_free (this_chat_id); break; } g_object_unref (this_account); g_free (this_chat_id); } }
static void new_chatroom_dialog_response_cb (GtkWidget *widget, gint response, EmpathyNewChatroomDialog *dialog) { if (response == GTK_RESPONSE_OK) { new_chatroom_dialog_join (dialog); new_chatroom_dialog_store_last_account (dialog->gsettings, EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser)); } gtk_widget_destroy (widget); }
static void account_chooser_set_property (GObject *object, guint param_id, const GValue *value, GParamSpec *pspec) { switch (param_id) { case PROP_HAS_ALL_OPTION: empathy_account_chooser_set_has_all_option (EMPATHY_ACCOUNT_CHOOSER (object), g_value_get_boolean (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; }; }
static void contact_blocking_dialog_remove_contacts (GtkWidget *button, EmpathyContactBlockingDialog *self) { TpConnection *conn = empathy_account_chooser_get_connection ( EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser)); GtkTreeModel *model; GList *rows, *ptr; GPtrArray *contacts; rows = gtk_tree_selection_get_selected_rows (self->priv->selection, &model); contacts = g_ptr_array_new_with_free_func (g_object_unref); for (ptr = rows; ptr != NULL; ptr = ptr->next) { GtkTreePath *path = ptr->data; GtkTreeIter iter; TpContact *contact; if (!gtk_tree_model_get_iter (model, &iter, path)) continue; gtk_tree_model_get (model, &iter, COL_BLOCKED_CONTACT, &contact, -1); g_ptr_array_add (contacts, contact); gtk_tree_path_free (path); } g_list_free (rows); if (contacts->len > 0) { DEBUG ("Unblocking %u contacts", contacts->len); tp_connection_unblock_contacts_async (conn, contacts->len, (TpContact * const *) contacts->pdata, unblock_cb, self); } g_ptr_array_unref (contacts); }
static void new_chatroom_dialog_update_widgets (EmpathyNewChatroomDialog *dialog) { EmpathyAccountChooser *account_chooser; McAccount *account; McProfile *profile; const gchar *protocol; const gchar *room; account_chooser = EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser); account = empathy_account_chooser_get_account (account_chooser); profile = mc_account_get_profile (account); protocol = mc_profile_get_protocol_name (profile); gtk_entry_set_text (GTK_ENTRY (dialog->entry_server), ""); /* hardcode here known protocols */ if (strcmp (protocol, "jabber") == 0) { gtk_widget_set_sensitive (dialog->entry_server, TRUE); gtk_widget_show (dialog->vbox_browse); } else if (strcmp (protocol, "local-xmpp") == 0) { gtk_widget_set_sensitive (dialog->entry_server, FALSE); gtk_widget_show (dialog->vbox_browse); } else if (strcmp (protocol, "irc") == 0) { gtk_widget_set_sensitive (dialog->entry_server, FALSE); gtk_widget_show (dialog->vbox_browse); } else { gtk_widget_set_sensitive (dialog->entry_server, TRUE); gtk_widget_show (dialog->vbox_browse); } room = gtk_entry_get_text (GTK_ENTRY (dialog->entry_room)); gtk_widget_set_sensitive (dialog->button_join, !EMP_STR_EMPTY (room)); /* Final set up of the dialog */ gtk_widget_grab_focus (dialog->entry_room); g_object_unref (account); g_object_unref (profile); }
/** * empathy_contact_widget_set_account_filter: * @widget: an #EmpathyContactWidget * @filter: a #EmpathyAccountChooserFilterFunc * @user_data: user data to pass to @filter, or %NULL * * Set a filter on the #EmpathyAccountChooser included in the * #EmpathyContactWidget. */ void empathy_contact_widget_set_account_filter ( GtkWidget *widget, EmpathyAccountChooserFilterFunc filter, gpointer user_data) { EmpathyContactWidget *information; EmpathyAccountChooser *chooser; g_return_if_fail (GTK_IS_WIDGET (widget)); information = g_object_get_data (G_OBJECT (widget), "EmpathyContactWidget"); if (!information) return; chooser = EMPATHY_ACCOUNT_CHOOSER (information->widget_account); if (chooser) empathy_account_chooser_set_filter (chooser, filter, user_data); }
static void account_chooser_finalize (GObject *object) { EmpathyAccountChooser *chooser; EmpathyAccountChooserPriv *priv; chooser = EMPATHY_ACCOUNT_CHOOSER (object); priv = GET_PRIV (object); g_signal_handlers_disconnect_by_func (priv->monitor, account_chooser_account_created_cb, chooser); g_signal_handlers_disconnect_by_func (priv->monitor, account_chooser_account_deleted_cb, chooser); empathy_disconnect_account_status_changed (priv->token); g_object_unref (priv->mc); g_object_unref (priv->monitor); G_OBJECT_CLASS (empathy_account_chooser_parent_class)->finalize (object); }
static void chatrooms_window_chatroom_added_cb (EmpathyChatroomManager *manager, EmpathyChatroom *chatroom, EmpathyChatroomsWindow *window) { EmpathyAccountChooser *account_chooser; TpAccount *account; account_chooser = EMPATHY_ACCOUNT_CHOOSER (window->account_chooser); account = empathy_account_chooser_dup_account (account_chooser); if (!account) { chatrooms_window_model_add (window, chatroom, FALSE); } else { if (account == empathy_chatroom_get_account (chatroom)) { chatrooms_window_model_add (window, chatroom, FALSE); } g_object_unref (account); } }
static void contact_blocking_dialog_add_contact (GtkWidget *widget, EmpathyContactBlockingDialog *self) { TpConnection *conn = empathy_account_chooser_get_connection ( EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser)); const char *identifiers[2] = { NULL, }; identifiers[0] = gtk_entry_get_text ( GTK_ENTRY (self->priv->add_contact_entry)); DEBUG ("Looking up handle for '%s' on %s", identifiers[0], get_pretty_conn_name (conn)); tp_connection_get_contacts_by_id (conn, 1, identifiers, 0, NULL, block_contact_got_contact, g_strdup (identifiers[0]), NULL, G_OBJECT (self)); gtk_entry_set_text (GTK_ENTRY (self->priv->add_contact_entry), ""); gtk_widget_hide (self->priv->info_bar); }
static void new_chatroom_dialog_account_changed_cb (GtkComboBox *combobox, EmpathyNewChatroomDialog *dialog) { EmpathyAccountChooser *account_chooser; McAccount *account; gboolean listing = FALSE; if (dialog->room_list) { g_object_unref (dialog->room_list); } ephy_spinner_stop (EPHY_SPINNER (dialog->throbber)); new_chatroom_dialog_model_clear (dialog); account_chooser = EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser); account = empathy_account_chooser_get_account (account_chooser); dialog->room_list = empathy_tp_roomlist_new (account); if (dialog->room_list) { g_signal_connect (dialog->room_list, "destroy", G_CALLBACK (new_chatroom_dialog_roomlist_destroy_cb), dialog); g_signal_connect (dialog->room_list, "new-room", G_CALLBACK (new_chatroom_dialog_new_room_cb), dialog); g_signal_connect (dialog->room_list, "notify::is-listing", G_CALLBACK (new_chatroom_dialog_listing_cb), dialog); listing = empathy_tp_roomlist_is_listing (dialog->room_list); if (listing) { ephy_spinner_start (EPHY_SPINNER (dialog->throbber)); } } new_chatroom_dialog_update_widgets (dialog); }
static void select_account_once_ready (EmpathyLogWindow *self, TpAccount *account, const gchar *chat_id, gboolean is_chatroom) { EmpathyAccountChooser *account_chooser = EMPATHY_ACCOUNT_CHOOSER (self->account_chooser_chats); tp_clear_object (&self->selected_account); self->selected_account = g_object_ref (account); g_free (self->selected_chat_id); self->selected_chat_id = g_strdup (chat_id); self->selected_is_chatroom = is_chatroom; if (empathy_account_chooser_is_ready (account_chooser)) account_chooser_ready_cb (account_chooser, self); else /* Chat will be selected once the account chooser is ready */ g_signal_connect (account_chooser, "ready", G_CALLBACK (account_chooser_ready_cb), self); }
static void contact_widget_contact_update (EmpathyContactWidget *information) { EmpathyAccount *account = NULL; const gchar *id = NULL; /* Connect and get info from new contact */ if (information->contact) { g_signal_connect_swapped (information->contact, "notify::name", G_CALLBACK (contact_widget_name_notify_cb), information); g_signal_connect_swapped (information->contact, "notify::presence", G_CALLBACK (contact_widget_presence_notify_cb), information); g_signal_connect_swapped (information->contact, "notify::presence-message", G_CALLBACK (contact_widget_presence_notify_cb), information); g_signal_connect_swapped (information->contact, "notify::avatar", G_CALLBACK (contact_widget_avatar_notify_cb), information); account = empathy_contact_get_account (information->contact); id = empathy_contact_get_id (information->contact); } /* Update account widget */ if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT) { if (account) { g_signal_handlers_block_by_func (information->widget_account, contact_widget_change_contact, information); empathy_account_chooser_set_account ( EMPATHY_ACCOUNT_CHOOSER (information->widget_account), account); g_signal_handlers_unblock_by_func (information->widget_account, contact_widget_change_contact, information); } } else { if (account) { const gchar *name; name = empathy_account_get_display_name (account); gtk_label_set_label (GTK_LABEL (information->widget_account), name); } } /* Update id widget */ if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID) gtk_entry_set_text (GTK_ENTRY (information->widget_id), id ? id : ""); else gtk_label_set_label (GTK_LABEL (information->widget_id), id ? id : ""); /* Update other widgets */ if (information->contact) { contact_widget_name_notify_cb (information); contact_widget_presence_notify_cb (information); contact_widget_avatar_notify_cb (information); gtk_widget_show (information->label_alias); gtk_widget_show (information->widget_alias); gtk_widget_show (information->hbox_presence); gtk_widget_show (information->widget_avatar); } else { gtk_widget_hide (information->label_alias); gtk_widget_hide (information->widget_alias); gtk_widget_hide (information->hbox_presence); gtk_widget_hide (information->widget_avatar); } }
static void contact_widget_contact_setup (EmpathyContactWidget *information) { /* Setup account label/chooser */ if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT) { information->widget_account = empathy_account_chooser_new (); g_signal_connect_swapped (information->widget_account, "changed", G_CALLBACK (contact_widget_change_contact), information); } else { information->widget_account = gtk_label_new (NULL); if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) { gtk_label_set_selectable (GTK_LABEL (information->widget_account), TRUE); } gtk_misc_set_alignment (GTK_MISC (information->widget_account), 0, 0.5); } gtk_table_attach_defaults (GTK_TABLE (information->table_contact), information->widget_account, 1, 2, 0, 1); gtk_widget_show (information->widget_account); /* Set up avatar chooser/display */ if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_AVATAR) { information->widget_avatar = empathy_avatar_chooser_new (); g_signal_connect (information->widget_avatar, "changed", G_CALLBACK (contact_widget_avatar_changed_cb), information); if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT) { g_signal_connect (information->widget_account, "changed", G_CALLBACK (update_avatar_chooser_account_cb), information->widget_avatar); update_avatar_chooser_account_cb ( EMPATHY_ACCOUNT_CHOOSER (information->widget_account), EMPATHY_AVATAR_CHOOSER (information->widget_avatar)); } } else { information->widget_avatar = empathy_avatar_image_new (); g_signal_connect (information->widget_avatar, "popup-menu", G_CALLBACK (widget_avatar_popup_menu_cb), information); g_signal_connect (information->widget_avatar, "button-press-event", G_CALLBACK (widget_avatar_button_press_event_cb), information); } gtk_box_pack_start (GTK_BOX (information->vbox_avatar), information->widget_avatar, FALSE, FALSE, 6); gtk_widget_show (information->widget_avatar); /* Setup id label/entry */ if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID) { information->widget_id = gtk_entry_new (); g_signal_connect (information->widget_id, "focus-out-event", G_CALLBACK (contact_widget_id_focus_out_cb), information); g_signal_connect (information->widget_id, "changed", G_CALLBACK (contact_widget_id_changed_cb), information); } else { information->widget_id = gtk_label_new (NULL); if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) { gtk_label_set_selectable (GTK_LABEL (information->widget_id), TRUE); } gtk_misc_set_alignment (GTK_MISC (information->widget_id), 0, 0.5); } gtk_table_attach_defaults (GTK_TABLE (information->table_contact), information->widget_id, 1, 2, 1, 2); gtk_widget_show (information->widget_id); /* Setup alias label/entry */ if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ALIAS) { information->widget_alias = gtk_entry_new (); g_signal_connect (information->widget_alias, "focus-out-event", G_CALLBACK (contact_widget_entry_alias_focus_event_cb), information); /* Make return activate the window default (the Close button) */ gtk_entry_set_activates_default (GTK_ENTRY (information->widget_alias), TRUE); } else { information->widget_alias = gtk_label_new (NULL); if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) { gtk_label_set_selectable (GTK_LABEL (information->widget_alias), TRUE); } gtk_misc_set_alignment (GTK_MISC (information->widget_alias), 0, 0.5); } gtk_table_attach_defaults (GTK_TABLE (information->table_contact), information->widget_alias, 1, 2, 2, 3); if (information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP) { gtk_label_set_selectable (GTK_LABEL (information->label_status), FALSE); } gtk_widget_show (information->widget_alias); }
static void log_window_chats_populate (EmpathyLogWindow *window) { EmpathyAccountChooser *account_chooser; EmpathyAccount *account; GList *chats, *l; GtkTreeView *view; GtkTreeModel *model; GtkTreeSelection *selection; GtkListStore *store; GtkTreeIter iter; account_chooser = EMPATHY_ACCOUNT_CHOOSER (window->account_chooser_chats); account = empathy_account_chooser_dup_account (account_chooser); view = GTK_TREE_VIEW (window->treeview_chats); model = gtk_tree_view_get_model (view); selection = gtk_tree_view_get_selection (view); store = GTK_LIST_STORE (model); if (account == NULL) { gtk_list_store_clear (store); return; } /* Block signals to stop the logs being retrieved prematurely */ g_signal_handlers_block_by_func (selection, log_window_chats_changed_cb, window); gtk_list_store_clear (store); chats = empathy_log_manager_get_chats (window->log_manager, account); for (l = chats; l; l = l->next) { EmpathyLogSearchHit *hit; hit = l->data; gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, COL_CHAT_ICON, "empathy-available", /* FIXME */ COL_CHAT_NAME, hit->chat_id, COL_CHAT_ACCOUNT, account, COL_CHAT_ID, hit->chat_id, COL_CHAT_IS_CHATROOM, hit->is_chatroom, -1); /* FIXME: Update COL_CHAT_ICON/NAME */ if (hit->is_chatroom) { } else { } } empathy_log_manager_search_free (chats); /* Unblock signals */ g_signal_handlers_unblock_by_func (selection, log_window_chats_changed_cb, window); g_object_unref (account); }
GtkWidget * empathy_log_window_show (EmpathyAccount *account, const gchar *chat_id, gboolean is_chatroom, GtkWindow *parent) { static EmpathyLogWindow *window = NULL; EmpathyAccountChooser *account_chooser; EmpathyAccountManager *account_manager; gint account_num; GtkBuilder *gui; gchar *filename; if (window) { gtk_window_present (GTK_WINDOW (window->window)); if (account && chat_id) { gtk_notebook_set_current_page (GTK_NOTEBOOK (window->notebook), 1); log_window_chats_set_selected (window, account, chat_id, is_chatroom); } return window->window; } window = g_new0 (EmpathyLogWindow, 1); window->log_manager = empathy_log_manager_dup_singleton (); filename = empathy_file_lookup ("empathy-log-window.ui", "libempathy-gtk"); gui = empathy_builder_get_file (filename, "log_window", &window->window, "notebook", &window->notebook, "entry_find", &window->entry_find, "button_find", &window->button_find, "treeview_find", &window->treeview_find, "scrolledwindow_find", &window->scrolledwindow_find, "button_previous", &window->button_previous, "button_next", &window->button_next, "entry_chats", &window->entry_chats, "calendar_chats", &window->calendar_chats, "vbox_chats", &window->vbox_chats, "treeview_chats", &window->treeview_chats, "scrolledwindow_chats", &window->scrolledwindow_chats, NULL); g_free (filename); empathy_builder_connect (gui, window, "log_window", "destroy", log_window_destroy_cb, "entry_find", "changed", log_window_entry_find_changed_cb, "button_previous", "clicked", log_window_button_previous_clicked_cb, "button_next", "clicked", log_window_button_next_clicked_cb, "button_find", "clicked", log_window_button_find_clicked_cb, "entry_chats", "changed", log_window_entry_chats_changed_cb, "entry_chats", "activate", log_window_entry_chats_activate_cb, NULL); g_object_unref (gui); g_object_add_weak_pointer (G_OBJECT (window->window), (gpointer) &window); /* We set this up here so we can block it when needed. */ g_signal_connect (window->calendar_chats, "day-selected", G_CALLBACK (log_window_calendar_chats_day_selected_cb), window); g_signal_connect (window->calendar_chats, "month-changed", G_CALLBACK (log_window_calendar_chats_month_changed_cb), window); /* Configure Search EmpathyChatView */ window->chatview_find = empathy_theme_manager_create_view (empathy_theme_manager_get ()); gtk_container_add (GTK_CONTAINER (window->scrolledwindow_find), GTK_WIDGET (window->chatview_find)); gtk_widget_show (GTK_WIDGET (window->chatview_find)); /* Configure Contacts EmpathyChatView */ window->chatview_chats = empathy_theme_manager_create_view (empathy_theme_manager_get ()); gtk_container_add (GTK_CONTAINER (window->scrolledwindow_chats), GTK_WIDGET (window->chatview_chats)); gtk_widget_show (GTK_WIDGET (window->chatview_chats)); /* Account chooser for chats */ window->account_chooser_chats = empathy_account_chooser_new (); account_chooser = EMPATHY_ACCOUNT_CHOOSER (window->account_chooser_chats); gtk_box_pack_start (GTK_BOX (window->vbox_chats), window->account_chooser_chats, FALSE, TRUE, 0); g_signal_connect (window->account_chooser_chats, "changed", G_CALLBACK (log_window_chats_accounts_changed_cb), window); /* Populate */ account_manager = empathy_account_manager_dup_singleton (); account_num = empathy_account_manager_get_count (account_manager); g_object_unref (account_manager); if (account_num > 1) { gtk_widget_show (window->vbox_chats); gtk_widget_show (window->account_chooser_chats); } else { gtk_widget_hide (window->vbox_chats); gtk_widget_hide (window->account_chooser_chats); } /* Search List */ log_window_find_setup (window); /* Contacts */ log_window_chats_setup (window); log_window_chats_populate (window); /* Select chat */ if (account && chat_id) { gtk_notebook_set_current_page (GTK_NOTEBOOK (window->notebook), 1); log_window_chats_set_selected (window, account, chat_id, is_chatroom); } if (parent) { gtk_window_set_transient_for (GTK_WINDOW (window->window), GTK_WINDOW (parent)); } gtk_widget_show (window->window); return window->window; }
static void contact_widget_contact_setup (EmpathyContactWidget *information) { /* Setup label_status as a KludgeLabel */ information->label_status = empathy_kludge_label_new (""); gtk_label_set_line_wrap_mode (GTK_LABEL (information->label_status), PANGO_WRAP_WORD_CHAR); gtk_label_set_line_wrap (GTK_LABEL (information->label_status), TRUE); if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) gtk_label_set_selectable (GTK_LABEL (information->label_status), TRUE); gtk_box_pack_start (GTK_BOX (information->hbox_presence), information->label_status, TRUE, TRUE, 0); gtk_widget_show (information->label_status); /* Setup account label/chooser */ if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT) { information->widget_account = empathy_account_chooser_new (); g_signal_connect_swapped (information->widget_account, "changed", G_CALLBACK (contact_widget_change_contact), information); } else { /* Pack the protocol icon with the account name in an hbox */ information->widget_account = gtk_hbox_new (FALSE, 6); information->label_account = gtk_label_new (NULL); if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) { gtk_label_set_selectable (GTK_LABEL (information->label_account), TRUE); } gtk_misc_set_alignment (GTK_MISC (information->label_account), 0, 0.5); gtk_widget_show (information->label_account); information->image_account = gtk_image_new (); gtk_widget_show (information->image_account); gtk_box_pack_start (GTK_BOX (information->widget_account), information->image_account, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (information->widget_account), information->label_account, FALSE, TRUE, 0); } gtk_table_attach_defaults (GTK_TABLE (information->table_contact), information->widget_account, 1, 2, 0, 1); gtk_widget_show (information->widget_account); /* Set up avatar chooser/display */ if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_AVATAR) { information->widget_avatar = empathy_avatar_chooser_new (); g_signal_connect (information->widget_avatar, "changed", G_CALLBACK (contact_widget_avatar_changed_cb), information); if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT) { g_signal_connect (information->widget_account, "changed", G_CALLBACK (update_avatar_chooser_account_cb), information->widget_avatar); update_avatar_chooser_account_cb ( EMPATHY_ACCOUNT_CHOOSER (information->widget_account), EMPATHY_AVATAR_CHOOSER (information->widget_avatar)); } } else { information->widget_avatar = empathy_avatar_image_new (); g_signal_connect (information->widget_avatar, "popup-menu", G_CALLBACK (widget_avatar_popup_menu_cb), information); g_signal_connect (information->widget_avatar, "button-press-event", G_CALLBACK (widget_avatar_button_press_event_cb), information); } gtk_box_pack_start (GTK_BOX (information->vbox_avatar), information->widget_avatar, FALSE, FALSE, 6); gtk_widget_show (information->widget_avatar); /* Setup id label/entry */ if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID) { information->widget_id = gtk_entry_new (); g_signal_connect (information->widget_id, "focus-out-event", G_CALLBACK (contact_widget_id_focus_out_cb), information); g_signal_connect (information->widget_id, "changed", G_CALLBACK (contact_widget_id_changed_cb), information); } else { information->widget_id = gtk_label_new (NULL); if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) { gtk_label_set_selectable (GTK_LABEL (information->widget_id), TRUE); } gtk_misc_set_alignment (GTK_MISC (information->widget_id), 0, 0.5); } gtk_table_attach_defaults (GTK_TABLE (information->table_contact), information->widget_id, 1, 2, 1, 2); gtk_widget_show (information->widget_id); /* Setup alias label/entry */ if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ALIAS) { information->widget_alias = gtk_entry_new (); if (!(information->flags & EMPATHY_CONTACT_WIDGET_NO_SET_ALIAS)) g_signal_connect (information->widget_alias, "focus-out-event", G_CALLBACK (contact_widget_entry_alias_focus_event_cb), information); /* Make return activate the window default (the Close button) */ gtk_entry_set_activates_default (GTK_ENTRY (information->widget_alias), TRUE); } else { information->widget_alias = gtk_label_new (NULL); if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) { gtk_label_set_selectable (GTK_LABEL (information->widget_alias), TRUE); } gtk_misc_set_alignment (GTK_MISC (information->widget_alias), 0, 0.5); } gtk_table_attach_defaults (GTK_TABLE (information->table_contact), information->widget_alias, 1, 2, 2, 3); if (information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP) { gtk_label_set_selectable (GTK_LABEL (information->label_status), FALSE); } gtk_widget_show (information->widget_alias); #if HAVE_FAVOURITE_CONTACTS /* Favorite */ if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_FAVOURITE) { information->favourite_checkbox = gtk_check_button_new_with_label ( _("Favorite")); g_signal_connect (information->favourite_checkbox, "toggled", G_CALLBACK (favourite_toggled_cb), information); gtk_table_attach_defaults (GTK_TABLE (information->table_contact), information->favourite_checkbox, 0, 2, 3, 4); information->fav_sig_id = g_signal_connect (information->manager, "favourites-changed", G_CALLBACK (contact_widget_favourites_changed_cb), information); gtk_widget_show (information->favourite_checkbox); } #endif }
void empathy_new_chatroom_dialog_show (GtkWindow *parent) { EmpathyNewChatroomDialog *dialog; GladeXML *glade; GtkSizeGroup *size_group; gchar *filename; if (dialog_p) { gtk_window_present (GTK_WINDOW (dialog_p->window)); return; } dialog_p = dialog = g_new0 (EmpathyNewChatroomDialog, 1); filename = empathy_file_lookup ("empathy-new-chatroom-dialog.glade", "src"); glade = empathy_glade_get_file (filename, "new_chatroom_dialog", NULL, "new_chatroom_dialog", &dialog->window, "table_info", &dialog->table_info, "label_account", &dialog->label_account, "label_server", &dialog->label_server, "label_room", &dialog->label_room, "entry_server", &dialog->entry_server, "entry_room", &dialog->entry_room, "togglebutton_refresh", &dialog->togglebutton_refresh, "vbox_browse", &dialog->vbox_browse, "image_status", &dialog->image_status, "label_status", &dialog->label_status, "hbox_status", &dialog->hbox_status, "treeview", &dialog->treeview, "button_join", &dialog->button_join, NULL); g_free (filename); empathy_glade_connect (glade, dialog, "new_chatroom_dialog", "response", new_chatroom_dialog_response_cb, "new_chatroom_dialog", "destroy", new_chatroom_dialog_destroy_cb, "entry_server", "changed", new_chatroom_dialog_entry_changed_cb, "entry_server", "activate", new_chatroom_dialog_entry_server_activate_cb, "entry_room", "changed", new_chatroom_dialog_entry_changed_cb, "togglebutton_refresh", "toggled", new_chatroom_dialog_togglebutton_refresh_toggled_cb, NULL); g_object_unref (glade); g_object_add_weak_pointer (G_OBJECT (dialog->window), (gpointer) &dialog_p); /* Label alignment */ size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); gtk_size_group_add_widget (size_group, dialog->label_account); gtk_size_group_add_widget (size_group, dialog->label_server); gtk_size_group_add_widget (size_group, dialog->label_room); g_object_unref (size_group); /* Set up chatrooms treeview */ new_chatroom_dialog_model_setup (dialog); /* Add throbber */ dialog->throbber = ephy_spinner_new (); ephy_spinner_set_size (EPHY_SPINNER (dialog->throbber), GTK_ICON_SIZE_LARGE_TOOLBAR); gtk_widget_show (dialog->throbber); gtk_box_pack_start (GTK_BOX (dialog->hbox_status), dialog->throbber, FALSE, FALSE, 0); /* Account chooser for custom */ dialog->account_chooser = empathy_account_chooser_new (); empathy_account_chooser_set_filter (EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser), empathy_account_chooser_filter_is_connected, NULL); gtk_table_attach_defaults (GTK_TABLE (dialog->table_info), dialog->account_chooser, 1, 3, 0, 1); gtk_widget_show (dialog->account_chooser); g_signal_connect (GTK_COMBO_BOX (dialog->account_chooser), "changed", G_CALLBACK (new_chatroom_dialog_account_changed_cb), dialog); new_chatroom_dialog_account_changed_cb (GTK_COMBO_BOX (dialog->account_chooser), dialog); if (parent) { gtk_window_set_transient_for (GTK_WINDOW (dialog->window), GTK_WINDOW (parent)); } gtk_widget_show (dialog->window); }
void empathy_chatrooms_window_show (GtkWindow *parent) { static EmpathyChatroomsWindow *window = NULL; GtkBuilder *gui; gchar *filename; if (window) { gtk_window_present (GTK_WINDOW (window->window)); return; } window = g_new0 (EmpathyChatroomsWindow, 1); filename = empathy_file_lookup ("empathy-chatrooms-window.ui", "src"); gui = empathy_builder_get_file (filename, "chatrooms_window", &window->window, "hbox_account", &window->hbox_account, "label_account", &window->label_account, "treeview", &window->treeview, "button_remove", &window->button_remove, "button_close", &window->button_close, NULL); g_free (filename); empathy_builder_connect (gui, window, "chatrooms_window", "destroy", chatrooms_window_destroy_cb, "button_remove", "clicked", chatrooms_window_button_remove_clicked_cb, "button_close", "clicked", chatrooms_window_button_close_clicked_cb, NULL); g_object_unref (gui); g_object_add_weak_pointer (G_OBJECT (window->window), (gpointer) &window); /* Get the session and chat room manager */ window->manager = empathy_chatroom_manager_dup_singleton (NULL); g_signal_connect (window->manager, "chatroom-added", G_CALLBACK (chatrooms_window_chatroom_added_cb), window); g_signal_connect (window->manager, "chatroom-removed", G_CALLBACK (chatrooms_window_chatroom_removed_cb), window); /* Account chooser for chat rooms */ window->account_chooser = empathy_account_chooser_new (); empathy_account_chooser_set_filter (EMPATHY_ACCOUNT_CHOOSER (window->account_chooser), empathy_account_chooser_filter_is_connected, NULL); g_object_set (window->account_chooser, "has-all-option", TRUE, NULL); empathy_account_chooser_set_account (EMPATHY_ACCOUNT_CHOOSER (window->account_chooser), NULL); gtk_box_pack_start (GTK_BOX (window->hbox_account), window->account_chooser, TRUE, TRUE, 0); g_signal_connect (window->account_chooser, "changed", G_CALLBACK (chatrooms_window_account_changed_cb), window); gtk_widget_show (window->account_chooser); /* Set up chatrooms */ chatrooms_window_model_setup (window); /* Set focus */ gtk_widget_grab_focus (window->treeview); /* Last touches */ if (parent) { gtk_window_set_transient_for (GTK_WINDOW (window->window), GTK_WINDOW (parent)); } gtk_widget_show (window->window); }
static void contact_blocking_dialog_account_changed (GtkWidget *account_chooser, EmpathyContactBlockingDialog *self) { TpConnection *conn = empathy_account_chooser_get_connection ( EMPATHY_ACCOUNT_CHOOSER (account_chooser)); GPtrArray *blocked; GPtrArray *members; guint i; if (self->priv->block_account_changed > 0) return; if (conn == self->priv->current_conn) return; /* clear the lists of contacts */ gtk_list_store_clear (self->priv->blocked_contacts); gtk_list_store_clear (self->priv->completion_contacts); if (self->priv->current_conn != NULL) { g_signal_handlers_disconnect_by_func (self->priv->current_conn, blocked_contacts_changed_cb, self); g_clear_object (&self->priv->current_conn); } if (conn == NULL) return; DEBUG ("Account changed: %s", get_pretty_conn_name (conn)); self->priv->current_conn = g_object_ref (conn); tp_g_signal_connect_object (conn, "blocked-contacts-changed", G_CALLBACK (blocked_contacts_changed_cb), self, 0); blocked = tp_connection_get_blocked_contacts (conn); DEBUG ("%u contacts blocked on %s", blocked != NULL ? blocked->len : 0, get_pretty_conn_name (conn)); contact_blocking_dialog_add_blocked (self, blocked); DEBUG ("Loading contacts"); members = tp_connection_dup_contact_list (conn); for (i = 0; i < members->len; i++) { TpContact *contact = g_ptr_array_index (members, i); gchar *tmpstr; tmpstr = g_strdup_printf ("%s (%s)", tp_contact_get_alias (contact), tp_contact_get_identifier (contact)); gtk_list_store_insert_with_values (self->priv->completion_contacts, NULL, -1, COL_COMPLETION_IDENTIFIER, tp_contact_get_identifier (contact), COL_COMPLETION_TEXT, tmpstr, -1); g_free (tmpstr); } g_ptr_array_unref (members); }