static void
new_chatroom_dialog_new_room_cb (EmpathyTpRoomlist        *room_list,
				 EmpathyChatroom          *chatroom,
				 EmpathyNewChatroomDialog *dialog)
{
	GtkTreeView      *view;
	GtkTreeSelection *selection;
	GtkListStore     *store;
	GtkTreeIter       iter;

	DEBUG ("New chatroom listed: %s (%s)",
		empathy_chatroom_get_name (chatroom),
		empathy_chatroom_get_room (chatroom));

	/* Add to model */
	view = GTK_TREE_VIEW (dialog->treeview);
	selection = gtk_tree_view_get_selection (view);
	store = GTK_LIST_STORE (dialog->model);

	gtk_list_store_append (store, &iter);
	gtk_list_store_set (store, &iter,
			    COL_NAME, empathy_chatroom_get_name (chatroom),
			    COL_ROOM, empathy_chatroom_get_room (chatroom),
			    -1);
}
Beispiel #2
0
static gboolean
chatroom_manager_file_save (EmpathyChatroomManager *manager)
{
	EmpathyChatroomManagerPriv *priv;
	xmlDocPtr                  doc;
	xmlNodePtr                 root;
	GList                     *l;

	priv = GET_PRIV (manager);

	doc = xmlNewDoc ((const xmlChar *) "1.0");
	root = xmlNewNode (NULL, (const xmlChar *) "chatrooms");
	xmlDocSetRootElement (doc, root);

	for (l = priv->chatrooms; l; l = l->next) {
		EmpathyChatroom *chatroom;
		xmlNodePtr       node;
		const gchar     *account_id;

		chatroom = l->data;

		if (!empathy_chatroom_is_favorite (chatroom)) {
			continue;
		}

		account_id = empathy_account_get_unique_name (
		  empathy_chatroom_get_account (chatroom));

		node = xmlNewChild (root, NULL, (const xmlChar *) "chatroom", NULL);
		xmlNewTextChild (node, NULL, (const xmlChar *) "name",
			(const xmlChar *) empathy_chatroom_get_name (chatroom));
		xmlNewTextChild (node, NULL, (const xmlChar *) "room",
			(const xmlChar *) empathy_chatroom_get_name (chatroom));
		xmlNewTextChild (node, NULL, (const xmlChar *) "account",
			(const xmlChar *) account_id);
		xmlNewTextChild (node, NULL, (const xmlChar *) "auto_connect",
			empathy_chatroom_get_auto_connect (chatroom) ?
			(const xmlChar *) "yes" : (const xmlChar *) "no");
	}

	/* Make sure the XML is indented properly */
	xmlIndentTreeOutput = 1;

	DEBUG ("Saving file:'%s'", priv->file);
	xmlSaveFormatFileEnc (priv->file, doc, "utf-8", 1);
	xmlFreeDoc (doc);

	xmlCleanupParser ();
	xmlMemoryDump ();

	return TRUE;
}
static void
new_chatroom_dialog_new_room_cb (EmpathyTpRoomlist        *room_list,
				 EmpathyChatroom          *chatroom,
				 EmpathyNewChatroomDialog *dialog)
{
	GtkTreeView      *view;
	GtkTreeSelection *selection;
	GtkListStore     *store;
	GtkTreeIter       iter;
	gchar            *members;
	gchar            *tooltip;
	const gchar      *need_password;
	const gchar      *invite_only;

	DEBUG ("New chatroom listed: %s (%s)",
		empathy_chatroom_get_name (chatroom),
		empathy_chatroom_get_room (chatroom));

	/* Add to model */
	view = GTK_TREE_VIEW (dialog->treeview);
	selection = gtk_tree_view_get_selection (view);
	store = GTK_LIST_STORE (dialog->model);
	members = g_strdup_printf ("%d", empathy_chatroom_get_members_count (chatroom));
	/* Translators: Room/Join's roomlist tooltip. Parameters are a channel name,
	yes/no, yes/no and a number. */
	tooltip = g_strdup_printf (_("<b>%s</b>\nInvite required: %s\nPassword required: %s\nMembers: %s"),
		empathy_chatroom_get_name (chatroom),
		empathy_chatroom_get_invite_only (chatroom) ? _("Yes") : _("No"),
		empathy_chatroom_get_need_password (chatroom) ? _("Yes") : _("No"),
		members);
	invite_only = (empathy_chatroom_get_invite_only (chatroom) ?
		GTK_STOCK_INDEX : NULL);
	need_password = (empathy_chatroom_get_need_password (chatroom) ?
		GTK_STOCK_DIALOG_AUTHENTICATION : NULL);

	gtk_list_store_append (store, &iter);
	gtk_list_store_set (store, &iter,
			    COL_NEED_PASSWORD, need_password,
			    COL_INVITE_ONLY, invite_only,
			    COL_NAME, empathy_chatroom_get_name (chatroom),
			    COL_ROOM, empathy_chatroom_get_room (chatroom),
			    COL_MEMBERS, members,
			    COL_MEMBERS_INT, empathy_chatroom_get_members_count (chatroom),
			    COL_TOOLTIP, tooltip,
			    -1);

	g_free (members);
	g_free (tooltip);
}
Beispiel #4
0
static void
chatrooms_window_model_add (EmpathyChatroomsWindow *window,
                            EmpathyChatroom        *chatroom,
                            gboolean               set_active)
{
    GtkTreeView      *view;
    GtkTreeModel     *model;
    GtkTreeSelection *selection;
    GtkListStore     *store;
    GtkTreeIter       iter;

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

    gtk_list_store_append (store, &iter);
    gtk_list_store_set (store, &iter,
                        COL_NAME, empathy_chatroom_get_name (chatroom),
                        COL_ROOM, empathy_chatroom_get_room (chatroom),
                        COL_AUTO_CONNECT, empathy_chatroom_get_auto_connect (chatroom),
                        COL_POINTER, chatroom,
                        -1);

    if (set_active) {
        gtk_tree_selection_select_iter (selection, &iter);
    }
}
static void
check_chatroom (EmpathyChatroom *chatroom,
                const gchar *name,
                const gchar *room,
                gboolean auto_connect,
                gboolean favorite)
{
  gboolean _favorite;

  fail_if (tp_strdiff (empathy_chatroom_get_name (chatroom), name));
  fail_if (tp_strdiff (empathy_chatroom_get_room (chatroom), room));
  fail_if (empathy_chatroom_get_auto_connect (chatroom) != auto_connect);
  g_object_get (chatroom, "favorite", &_favorite, NULL);
  fail_if (favorite != _favorite);
}
static GtkWidget *
create_room_sub_menu (EmpathyContact *contact,
                      EmpathyChatroom *chatroom)
{
	GtkWidget *item;
	RoomSubMenuData *data;

	item = gtk_menu_item_new_with_label (empathy_chatroom_get_name (chatroom));
	data = room_sub_menu_data_new (contact, chatroom);
	g_signal_connect_data (item, "activate",
			       G_CALLBACK (room_sub_menu_activate_cb), data,
			       (GClosureNotify) room_sub_menu_data_free, 0);

	return item;
}
static void
main_window_favorite_chatroom_menu_add (EmpathyMainWindow *window,
					EmpathyChatroom    *chatroom)
{
	GtkWidget   *menu_item;
	const gchar *name;

	if (g_object_get_data (G_OBJECT (chatroom), "menu_item")) {
		return;
	}

	name = empathy_chatroom_get_name (chatroom);
	menu_item = gtk_menu_item_new_with_label (name);

	g_object_set_data (G_OBJECT (chatroom), "menu_item", menu_item);
	g_signal_connect (menu_item, "activate",
			  G_CALLBACK (main_window_favorite_chatroom_menu_activate_cb),
			  chatroom);

	gtk_menu_shell_insert (GTK_MENU_SHELL (window->room_menu),
			       menu_item, 4);

	gtk_widget_show (menu_item);
}