Пример #1
0
static void
chat_conversations_list_init (ChatConversationsList *self)
{
  ChatConversationsListPrivate *priv;

  self->priv = chat_conversations_list_get_instance_private (self);
  priv = self->priv;

  priv->accounts = g_hash_table_new_full (g_direct_hash,
                                          chat_conversations_list_accounts_key_equal_func,
                                          g_object_unref,
                                          chat_conversations_list_accounts_value_destroy_func);

  priv->am = tp_account_manager_dup ();
  tp_proxy_prepare_async (priv->am, NULL, chat_conversations_list_account_manager_prepare, g_object_ref (self));

  priv->lm = tpl_log_manager_dup_singleton ();
}
GtkWidget *
empathy_contact_log_menu_item_new (EmpathyContact *contact)
{
	TplLogManager     *manager;
	TplEntity         *entity;
	gboolean           have_log;
	GtkWidget         *item;
	GtkWidget         *image;

	g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);

	manager = tpl_log_manager_dup_singleton ();
	entity = tpl_entity_new_from_tp_contact (empathy_contact_get_tp_contact (contact),
						 TPL_ENTITY_CONTACT);

	have_log = tpl_log_manager_exists (manager,
					   empathy_contact_get_account (contact),
					   entity,
					   TPL_EVENT_MASK_TEXT);

	g_object_unref (entity);
	g_object_unref (manager);

	item = gtk_image_menu_item_new_with_mnemonic (_("_Previous Conversations"));
	image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_LOG,
					      GTK_ICON_SIZE_MENU);
	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
	gtk_widget_set_sensitive (item, have_log);
	gtk_widget_show (image);

	g_signal_connect_swapped (item, "activate",
				  G_CALLBACK (contact_log_menu_item_activate_cb),
				  contact);

	return item;
}
Пример #3
0
GtkWidget *
empathy_log_window_show (TpAccount  *account,
			const gchar *chat_id,
			gboolean     is_chatroom,
			GtkWindow   *parent)
{
	EmpathyAccountChooser   *account_chooser;
	TpAccountManager        *account_manager;
	GtkBuilder             *gui;
	gchar                  *filename;
	EmpathyLogWindow       *window;

	if (log_window != NULL) {
		gtk_window_present (GTK_WINDOW (log_window->window));

		if (account != NULL && chat_id != NULL) {
			gtk_notebook_set_current_page (GTK_NOTEBOOK (log_window->notebook), 1);
			select_account_once_ready (log_window, account, chat_id, is_chatroom);
		}

		return log_window->window;
	}

	log_window = g_new0 (EmpathyLogWindow, 1);
	log_window->log_manager = tpl_log_manager_dup_singleton ();

	window = log_window;

	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,
			      "entry_find", "activate", log_window_entry_find_activate_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) &log_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 = tp_account_manager_dup ();
	tp_account_manager_prepare_async (account_manager, NULL,
					  account_manager_prepared_cb, window);
	g_object_unref (account_manager);

	/* Search List */
	log_window_find_setup (window);

	/* Contacts */
	log_window_chats_setup (window);
	log_window_chats_populate (window);

	if (account != NULL && chat_id != NULL)
		select_account_once_ready (window, account, chat_id, is_chatroom);

	if (parent != NULL) {
		gtk_window_set_transient_for (GTK_WINDOW (window->window),
					      GTK_WINDOW (parent));
	}

	gtk_widget_show (window->window);

	return window->window;
}