Ejemplo n.º 1
0
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
new_chatroom_dialog_select_last_account (GSettings             *gsettings,
                                         EmpathyAccountChooser *account_chooser)
{
	const gchar          *account_path;
	TpAccountManager      *manager;
	TpSimpleClientFactory *factory;
	TpAccount             *account;
	TpConnectionStatus    status;

	account_path = g_settings_get_string (gsettings, EMPATHY_PREFS_CHAT_ROOM_LAST_ACCOUNT);
	DEBUG ("Selecting account path '%s'", account_path);

	manager =  tp_account_manager_dup ();
	factory = tp_proxy_get_factory (manager);
	account = tp_simple_client_factory_ensure_account (factory,
	                                                   account_path,
	                                                   NULL,
	                                                   NULL);

	if (account != NULL) {
		status = tp_account_get_connection_status (account, NULL);
		if (status == TP_CONNECTION_STATUS_CONNECTED) {
			empathy_account_chooser_set_account (account_chooser,
			                                     account);
		}
		g_object_unref (account);
	}
	g_object_unref (manager);
}
Ejemplo n.º 3
0
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);
}
Ejemplo n.º 4
0
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);
	}
}
Ejemplo n.º 5
0
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);
    }
}
Ejemplo n.º 6
0
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);
}
Ejemplo n.º 7
0
static void
contact_widget_contact_update (EmpathyContactWidget *information)
{
  TpAccount *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 = tp_account_get_display_name (account);
          gtk_label_set_label (GTK_LABEL (information->label_account), name);

          name = tp_account_get_icon_name (account);
          gtk_image_set_from_icon_name (GTK_IMAGE (information->image_account),
              name, GTK_ICON_SIZE_MENU);
        }
    }

  /* 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);

#if HAVE_FAVOURITE_CONTACTS
      if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_FAVOURITE)
        {
          gboolean is_favourite;

          is_favourite = empathy_contact_list_is_favourite (
              EMPATHY_CONTACT_LIST (information->manager),
              information->contact);

          contact_widget_favourites_changed_cb (information->manager,
              information->contact, is_favourite, information);
        }
#endif

      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);
    }
}