Commit 73a749ca authored by Xavier Claessens's avatar Xavier Claessens Committed by Xavier Claessens

Initial room list support. It does not works yet.

2007-07-20 Xavier Claessens  <xclaesse@gmail.com>

	* libempathy/Makefile.am:
	* libempathy/empathy-tp-roomlist.h:
	* libempathy/empathy-tp-roomlist.c:
	* libempathy-gtk/empathy-chatrooms-window.c:
	* libempathy-gtk/empathy-new-chatroom-dialog.c: Initial room list
	support. It does not works yet.

	* libempathy-gtk/empathy-account-widget-generic.c: Add support for all
	types of integer and float. Fixes bug #457740 (Jamey Hicks).

	* libempathy/empathy-tp-chat.c:
	* libempathy-gtk/empathy-chat.c: If there is an error sending a message,
	show an error message to the user.

	* libempathy-gtk/empathy-accounts-dialog.c: Fix a leak, profile should
	be unrefed after mc_account_get_profile.

	* libempathy/empathy-utils.c:
	* libempathy/empathy-utils.h:
	* libempathy/empathy-tp-chatroom.c:
	* libempathy/empathy-tp-group.h:
	* libempathy/empathy-tp-group.c:
	* src/empathy.c: Rename empathy_get_channel_id() to
	empathy_inspect_channel(). We now have empathy_inspect_handle().

	* po/POTFILES.in:
	* libempathy/empathy-tp-contact-list.c: Set all contacts from salut
	protocol to the "Local Network" group.

	* libempathy/empathy-idle.c: Fix NetworkManager support.

	* libempathy/empathy-chatroom.h: Fix indentation.

	* libempathy-gtk/empathy-status-icon.c:
	* libempathy-gtk/empathy-ui-utils.c:
	* libempathy-gtk/empathy-ui-utils.h:
	 - Iconify main window to the status icon like in rhythmbox.
	   Fixes bug #458106 (Jaap A. Haitsma).
	 - Rounded avatars. Fixes bug #457992 (Raphael Slinckx)

	* Makefile.am: Fix distcheck for gtkdoc (Vincent Untz)

	* data/empathy.desktop.in.in: Change application description
	(Jaap A. Haitsma).


svn path=/trunk/; revision=190
parent f2e322a3
2007-07-20 Xavier Claessens <xclaesse@gmail.com>
* libempathy/Makefile.am:
* libempathy/empathy-tp-roomlist.h:
* libempathy/empathy-tp-roomlist.c:
* libempathy-gtk/empathy-chatrooms-window.c:
* libempathy-gtk/empathy-new-chatroom-dialog.c: Initial room list
support. It does not works yet.
* libempathy-gtk/empathy-account-widget-generic.c: Add support for all
types of integer and float. Fixes bug #457740 (Jamey Hicks).
* libempathy/empathy-tp-chat.c:
* libempathy-gtk/empathy-chat.c: If there is an error sending a message,
show an error message to the user.
* libempathy-gtk/empathy-accounts-dialog.c: Fix a leak, profile should
be unrefed after mc_account_get_profile.
* libempathy/empathy-utils.c:
* libempathy/empathy-utils.h:
* libempathy/empathy-tp-chatroom.c:
* libempathy/empathy-tp-group.h:
* libempathy/empathy-tp-group.c:
* src/empathy.c: Rename empathy_get_channel_id() to
empathy_inspect_channel(). We now have empathy_inspect_handle().
* po/POTFILES.in:
* libempathy/empathy-tp-contact-list.c: Set all contacts from salut
protocol to the "Local Network" group.
* libempathy/empathy-idle.c: Fix NetworkManager support.
* libempathy/empathy-chatroom.h: Fix indentation.
* libempathy-gtk/empathy-status-icon.c:
* libempathy-gtk/empathy-ui-utils.c:
* libempathy-gtk/empathy-ui-utils.h:
- Iconify main window to the status icon like in rhythmbox.
Fixes bug #458106 (Jaap A. Haitsma).
- Rounded avatars. Fixes bug #457992 (Raphael Slinckx)
* Makefile.am: Fix distcheck for gtkdoc (Vincent Untz)
* data/empathy.desktop.in.in: Change application description
(Jaap A. Haitsma).
2007-07-14 Xavier Claessens <xclaesse@gmail.com>
* libempathy-gtk/empathy-contact-list-store.c: Show avatars by default.
......
SUBDIRS = po data libempathy libempathy-gtk src doc
DISTCHECK_CONFIGURE_FLAGS = \
--disable-scrollkeeper
--disable-scrollkeeper \
--enable-gtk-doc
INTLTOOL = \
intltool-extract.in \
......
......@@ -2,7 +2,7 @@
Version=1.0
Encoding=UTF-8
_Name=Empathy Instant Messenger
_Comment=Instant Messenger
_Comment=Send and receive instant messages
Exec=empathy --no-connect
Icon=empathy
StartupNotify=false
......
......@@ -32,9 +32,12 @@
#include <libmissioncontrol/mc-account.h>
#include <libmissioncontrol/mc-protocol.h>
#include <libempathy-gtk/empathy-ui-utils.h>
#include <libempathy/empathy-debug.h>
#include "empathy-account-widget-generic.h"
#include "empathy-ui-utils.h"
#define DEBUG_DOMAIN "AccountWidgetGeneric"
typedef struct {
McAccount *account;
......@@ -178,10 +181,30 @@ account_widget_generic_setup_foreach (McProtocolParam *param,
GTK_FILL | GTK_EXPAND, 0,
0, 0);
}
else if (param->signature[0] == 'q' ||
param->signature[0] == 'n') {
gchar *str = NULL;
gint value = 0;
/* int types: ynqiuxt. double type is 'd' */
else if (param->signature[0] == 'y' ||
param->signature[0] == 'n' ||
param->signature[0] == 'q' ||
param->signature[0] == 'i' ||
param->signature[0] == 'u' ||
param->signature[0] == 'x' ||
param->signature[0] == 't' ||
param->signature[0] == 'd') {
gchar *str = NULL;
gint value = 0;
gdouble minint = 0;
gdouble maxint = 0;
gdouble step = 1;
switch (param->signature[0]) {
case 'y': minint = G_MININT8; maxint = G_MAXINT8; break;
case 'n': minint = G_MININT16; maxint = G_MAXINT16; break;
case 'q': minint = 0; maxint = G_MAXUINT16; break;
case 'i': minint = G_MININT32; maxint = G_MAXINT32; break;
case 'u': minint = 0; maxint = G_MAXUINT32; break;
case 'x': minint = G_MININT64; maxint = G_MAXINT64; break;
case 't': minint = 0; maxint = G_MAXUINT64; break;
case 'd': minint = G_MININT32; maxint = G_MAXINT32; step = 0.1; break;
}
str = g_strdup_printf (_("%s:"), param_name_formatted);
widget = gtk_label_new (str);
......@@ -195,7 +218,7 @@ account_widget_generic_setup_foreach (McProtocolParam *param,
GTK_FILL, 0,
0, 0);
widget = gtk_spin_button_new_with_range (0, G_MAXINT, 1);
widget = gtk_spin_button_new_with_range (minint, maxint, step);
mc_account_get_param_int (settings->account,
param->name,
&value);
......@@ -233,6 +256,9 @@ account_widget_generic_setup_foreach (McProtocolParam *param,
GTK_FILL | GTK_EXPAND, 0,
0, 0);
} else {
empathy_debug (DEBUG_DOMAIN,
"Unknown signature for param %s: %s\n",
param_name_formatted, param->signature);
g_assert_not_reached ();
}
......
......@@ -284,6 +284,7 @@ accounts_dialog_update_account (EmpathyAccountsDialog *dialog,
profile = mc_account_get_profile (account);
config_ui = mc_profile_get_configuration_ui (profile);
g_object_unref (profile);
if (strcmp (config_ui, "jabber") == 0) {
dialog->settings_widget =
......
......@@ -94,56 +94,60 @@ typedef struct {
GtkTextIter end;
} EmpathyChatSpell;
static void empathy_chat_class_init (EmpathyChatClass *klass);
static void empathy_chat_init (EmpathyChat *chat);
static void chat_finalize (GObject *object);
static void chat_destroy_cb (EmpathyTpChat *tp_chat,
EmpathyChat *chat);
static void chat_send (EmpathyChat *chat,
const gchar *msg);
static void chat_input_text_view_send (EmpathyChat *chat);
static void chat_message_received_cb (EmpathyTpChat *tp_chat,
EmpathyMessage *message,
EmpathyChat *chat);
void chat_sent_message_add (EmpathyChat *chat,
const gchar *str);
const gchar * chat_sent_message_get_next (EmpathyChat *chat);
const gchar * chat_sent_message_get_last (EmpathyChat *chat);
static gboolean chat_input_key_press_event_cb (GtkWidget *widget,
GdkEventKey *event,
EmpathyChat *chat);
static void chat_input_text_buffer_changed_cb (GtkTextBuffer *buffer,
EmpathyChat *chat);
static gboolean chat_text_view_focus_in_event_cb (GtkWidget *widget,
GdkEvent *event,
EmpathyChat *chat);
static void chat_text_view_scroll_hide_cb (GtkWidget *widget,
EmpathyChat *chat);
static void chat_text_view_size_allocate_cb (GtkWidget *widget,
GtkAllocation *allocation,
EmpathyChat *chat);
static void chat_text_view_realize_cb (GtkWidget *widget,
EmpathyChat *chat);
static void chat_text_populate_popup_cb (GtkTextView *view,
GtkMenu *menu,
EmpathyChat *chat);
static void chat_text_check_word_spelling_cb (GtkMenuItem *menuitem,
EmpathyChatSpell *chat_spell);
static EmpathyChatSpell *chat_spell_new (EmpathyChat *chat,
const gchar *word,
GtkTextIter start,
GtkTextIter end);
static void chat_spell_free (EmpathyChatSpell *chat_spell);
static void chat_composing_start (EmpathyChat *chat);
static void chat_composing_stop (EmpathyChat *chat);
static void chat_composing_remove_timeout (EmpathyChat *chat);
static gboolean chat_composing_stop_timeout_cb (EmpathyChat *chat);
static void chat_state_changed_cb (EmpathyTpChat *tp_chat,
EmpathyContact *contact,
TelepathyChannelChatState state,
EmpathyChat *chat);
static void chat_add_logs (EmpathyChat *chat);
static gboolean chat_scroll_down_idle_func (EmpathyChat *chat);
static void empathy_chat_class_init (EmpathyChatClass *klass);
static void empathy_chat_init (EmpathyChat *chat);
static void chat_finalize (GObject *object);
static void chat_destroy_cb (EmpathyTpChat *tp_chat,
EmpathyChat *chat);
static void chat_send (EmpathyChat *chat,
const gchar *msg);
static void chat_input_text_view_send (EmpathyChat *chat);
static void chat_message_received_cb (EmpathyTpChat *tp_chat,
EmpathyMessage *message,
EmpathyChat *chat);
static void chat_send_error_cb (EmpathyTpChat *tp_chat,
EmpathyMessage *message,
TelepathyChannelTextSendError error_code,
EmpathyChat *chat);
void chat_sent_message_add (EmpathyChat *chat,
const gchar *str);
const gchar * chat_sent_message_get_next (EmpathyChat *chat);
const gchar * chat_sent_message_get_last (EmpathyChat *chat);
static gboolean chat_input_key_press_event_cb (GtkWidget *widget,
GdkEventKey *event,
EmpathyChat *chat);
static void chat_input_text_buffer_changed_cb (GtkTextBuffer *buffer,
EmpathyChat *chat);
static gboolean chat_text_view_focus_in_event_cb (GtkWidget *widget,
GdkEvent *event,
EmpathyChat *chat);
static void chat_text_view_scroll_hide_cb (GtkWidget *widget,
EmpathyChat *chat);
static void chat_text_view_size_allocate_cb (GtkWidget *widget,
GtkAllocation *allocation,
EmpathyChat *chat);
static void chat_text_view_realize_cb (GtkWidget *widget,
EmpathyChat *chat);
static void chat_text_populate_popup_cb (GtkTextView *view,
GtkMenu *menu,
EmpathyChat *chat);
static void chat_text_check_word_spelling_cb (GtkMenuItem *menuitem,
EmpathyChatSpell *chat_spell);
static EmpathyChatSpell *chat_spell_new (EmpathyChat *chat,
const gchar *word,
GtkTextIter start,
GtkTextIter end);
static void chat_spell_free (EmpathyChatSpell *chat_spell);
static void chat_composing_start (EmpathyChat *chat);
static void chat_composing_stop (EmpathyChat *chat);
static void chat_composing_remove_timeout (EmpathyChat *chat);
static gboolean chat_composing_stop_timeout_cb (EmpathyChat *chat);
static void chat_state_changed_cb (EmpathyTpChat *tp_chat,
EmpathyContact *contact,
TelepathyChannelChatState state,
EmpathyChat *chat);
static void chat_add_logs (EmpathyChat *chat);
static gboolean chat_scroll_down_idle_func (EmpathyChat *chat);
enum {
COMPOSING,
......@@ -424,6 +428,43 @@ chat_message_received_cb (EmpathyTpChat *tp_chat,
g_signal_emit (chat, signals[NEW_MESSAGE], 0, message, FALSE);
}
static void
chat_send_error_cb (EmpathyTpChat *tp_chat,
EmpathyMessage *message,
TelepathyChannelTextSendError error_code,
EmpathyChat *chat)
{
const gchar *error;
gchar *str;
switch (error_code) {
case TP_CHANNEL_TEXT_SEND_ERROR_OFFLINE:
error = _("offline");
break;
case TP_CHANNEL_TEXT_SEND_ERROR_INVALID_CONTACT:
error = _("invalid contact");
break;
case TP_CHANNEL_TEXT_SEND_ERROR_PERMISSION_DENIED:
error = _("permission denied");
break;
case TP_CHANNEL_TEXT_SEND_ERROR_TOO_LONG:
error = _("too long message");
break;
case TP_CHANNEL_TEXT_SEND_ERROR_NOT_IMPLEMENTED:
error = _("not implemented");
break;
default:
error = _("unknown");
break;
}
str = g_strdup_printf (_("Error sending message '%s': %s"),
empathy_message_get_body (message),
error);
empathy_chat_view_append_event (chat->view, str);
g_free (str);
}
void
chat_sent_message_add (EmpathyChat *chat,
const gchar *str)
......@@ -1307,6 +1348,9 @@ empathy_chat_set_tp_chat (EmpathyChat *chat,
g_signal_handlers_disconnect_by_func (priv->tp_chat,
chat_message_received_cb,
chat);
g_signal_handlers_disconnect_by_func (priv->tp_chat,
chat_send_error_cb,
chat);
g_signal_handlers_disconnect_by_func (priv->tp_chat,
chat_destroy_cb,
chat);
......@@ -1326,6 +1370,9 @@ empathy_chat_set_tp_chat (EmpathyChat *chat,
g_signal_connect (tp_chat, "message-received",
G_CALLBACK (chat_message_received_cb),
chat);
g_signal_connect (tp_chat, "send-error",
G_CALLBACK (chat_send_error_cb),
chat);
g_signal_connect (tp_chat, "chat-state-changed",
G_CALLBACK (chat_state_changed_cb),
chat);
......
......@@ -38,7 +38,6 @@
#include "empathy-account-chooser.h"
#include "empathy-chatrooms-window.h"
//#include "empathy-edit-chatroom-dialog.h"
#include "empathy-new-chatroom-dialog.h"
#include "empathy-ui-utils.h"
......
......@@ -36,6 +36,8 @@
#include <libmissioncontrol/mc-account.h>
#include <libmissioncontrol/mc-profile.h>
#include <libempathy/empathy-tp-roomlist.h>
#include <libempathy/empathy-chatroom.h>
#include <libempathy/empathy-utils.h>
#include <libempathy/empathy-debug.h>
......@@ -47,45 +49,33 @@
#define DEBUG_DOMAIN "NewChatroomDialog"
typedef struct {
GtkWidget *window;
GtkWidget *vbox_widgets;
GtkWidget *table_info;
GtkWidget *label_account;
GtkWidget *account_chooser;
GtkWidget *label_server;
GtkWidget *entry_server;
GtkWidget *togglebutton_refresh;
GtkWidget *label_room;
GtkWidget *entry_room;
GtkWidget *vbox_browse;
GtkWidget *image_status;
GtkWidget *label_status;
GtkWidget *hbox_status;
GtkWidget *throbber;
GtkWidget *treeview;
GtkTreeModel *model;
GtkTreeModel *filter;
GtkWidget *button_join;
GtkWidget *button_close;
EmpathyTpRoomlist *room_list;
GtkWidget *window;
GtkWidget *vbox_widgets;
GtkWidget *table_info;
GtkWidget *label_account;
GtkWidget *account_chooser;
GtkWidget *label_server;
GtkWidget *entry_server;
GtkWidget *togglebutton_refresh;
GtkWidget *label_room;
GtkWidget *entry_room;
GtkWidget *vbox_browse;
GtkWidget *image_status;
GtkWidget *label_status;
GtkWidget *hbox_status;
GtkWidget *throbber;
GtkWidget *treeview;
GtkTreeModel *model;
GtkWidget *button_join;
GtkWidget *button_close;
} EmpathyNewChatroomDialog;
typedef struct {
guint handle;
gchar *channel_type;
gchar *name;
gchar *id;
} EmpathyRoomListItem;
enum {
COL_IMAGE,
COL_NAME,
COL_POINTER,
COL_ROOM,
COL_COUNT
};
......@@ -97,25 +87,20 @@ static void new_chatroom_dialog_destroy_cb (GtkWidget
static void new_chatroom_dialog_model_setup (EmpathyNewChatroomDialog *dialog);
static void new_chatroom_dialog_model_add_columns (EmpathyNewChatroomDialog *dialog);
static void new_chatroom_dialog_update_widgets (EmpathyNewChatroomDialog *dialog);
static void new_chatroom_dialog_account_changed_cb (GtkComboBox *combobox,
static void new_chatroom_dialog_account_changed_cb (GtkComboBox *combobox,
EmpathyNewChatroomDialog *dialog);
static void new_chatroom_dialog_model_add (EmpathyNewChatroomDialog *dialog,
EmpathyRoomListItem *item);
static void new_chatroom_dialog_model_clear (EmpathyNewChatroomDialog *dialog);
static GList * new_chatroom_dialog_model_get_selected (EmpathyNewChatroomDialog *dialog);
static gboolean new_chatroom_dialog_model_filter_func (GtkTreeModel *model,
GtkTreeIter *iter,
static void new_chatroom_dialog_roomlist_destroy_cb (EmpathyTpRoomlist *room_list,
EmpathyNewChatroomDialog *dialog);
static void new_chatroom_dialog_model_row_activated_cb (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *column,
static void new_chatroom_dialog_new_room_cb (EmpathyTpRoomlist *room_list,
EmpathyChatroom *chatroom,
EmpathyNewChatroomDialog *dialog);
static void new_chatroom_dialog_model_row_inserted_cb (GtkTreeModel *model,
GtkTreePath *path,
GtkTreeIter *iter,
static void new_chatroom_dialog_listing_cb (EmpathyTpRoomlist *room_list,
gboolean listing,
EmpathyNewChatroomDialog *dialog);
static void new_chatroom_dialog_model_row_deleted_cb (GtkTreeModel *model,
static void new_chatroom_dialog_model_clear (EmpathyNewChatroomDialog *dialog);
static void new_chatroom_dialog_model_row_activated_cb (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *column,
EmpathyNewChatroomDialog *dialog);
static void new_chatroom_dialog_model_selection_changed (GtkTreeSelection *selection,
EmpathyNewChatroomDialog *dialog);
......@@ -187,16 +172,8 @@ empathy_new_chatroom_dialog_show (GtkWindow *parent)
g_object_unref (size_group);
/* Account chooser for custom */
dialog->account_chooser = empathy_account_chooser_new ();
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);
/* Set up chatrooms treeview */
new_chatroom_dialog_model_setup (dialog);
/* Add throbber */
dialog->throbber = ephy_spinner_new ();
......@@ -206,11 +183,18 @@ empathy_new_chatroom_dialog_show (GtkWindow *parent)
gtk_box_pack_start (GTK_BOX (dialog->hbox_status), dialog->throbber,
FALSE, FALSE, 0);
/* Set up chatrooms treeview */
new_chatroom_dialog_model_setup (dialog);
/* Account chooser for custom */
dialog->account_chooser = empathy_account_chooser_new ();
gtk_table_attach_defaults (GTK_TABLE (dialog->table_info),
dialog->account_chooser,
1, 3, 0, 1);
gtk_widget_show (dialog->account_chooser);
/* Set things up according to the account type */
new_chatroom_dialog_update_widgets (dialog);
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),
......@@ -236,8 +220,10 @@ static void
new_chatroom_dialog_destroy_cb (GtkWidget *widget,
EmpathyNewChatroomDialog *dialog)
{
if (dialog->room_list) {
g_object_unref (dialog->room_list);
}
g_object_unref (dialog->model);
g_object_unref (dialog->filter);
g_free (dialog);
}
......@@ -260,36 +246,19 @@ new_chatroom_dialog_model_setup (EmpathyNewChatroomDialog *dialog)
store = gtk_list_store_new (COL_COUNT,
G_TYPE_STRING, /* Image */
G_TYPE_STRING, /* Text */
G_TYPE_POINTER); /* infos */
G_TYPE_STRING); /* Room */
dialog->model = GTK_TREE_MODEL (store);
/* Filter */
dialog->filter = gtk_tree_model_filter_new (dialog->model, NULL);
gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (dialog->filter),
(GtkTreeModelFilterVisibleFunc)
new_chatroom_dialog_model_filter_func,
dialog,
NULL);
gtk_tree_view_set_model (view, dialog->filter);
g_signal_connect (dialog->filter, "row-inserted",
G_CALLBACK (new_chatroom_dialog_model_row_inserted_cb),
dialog);
g_signal_connect (dialog->filter, "row-deleted",
G_CALLBACK (new_chatroom_dialog_model_row_deleted_cb),
dialog);
gtk_tree_view_set_model (view, dialog->model);
/* Selection */
selection = gtk_tree_view_get_selection (view);
gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
COL_NAME, GTK_SORT_ASCENDING);
g_signal_connect (selection, "changed",
G_CALLBACK (new_chatroom_dialog_model_selection_changed), dialog);
G_CALLBACK (new_chatroom_dialog_model_selection_changed),
dialog);
/* Columns */
new_chatroom_dialog_model_add_columns (dialog);
......@@ -373,105 +342,105 @@ 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, "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
new_chatroom_dialog_model_add (EmpathyNewChatroomDialog *dialog,
EmpathyRoomListItem *item)
new_chatroom_dialog_roomlist_destroy_cb (EmpathyTpRoomlist *room_list,
EmpathyNewChatroomDialog *dialog)
{
g_object_unref (dialog->room_list);
dialog->room_list = NULL;
}
static void
new_chatroom_dialog_new_room_cb (EmpathyTpRoomlist *room_list,
EmpathyChatroom *chatroom,
EmpathyNewChatroomDialog *dialog)
{
GtkTreeView *view;
GtkTreeSelection *selection;
GtkListStore *store;
GtkTreeIter iter;
empathy_debug (DEBUG_DOMAIN, "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, item->name,
COL_POINTER, item,
COL_NAME, empathy_chatroom_get_name (chatroom),
COL_ROOM, empathy_chatroom_get_room (chatroom),
-1);
}
static void
new_chatroom_dialog_model_clear (EmpathyNewChatroomDialog *dialog)
{
GtkListStore *store;
store = GTK_LIST_STORE (dialog->model);
gtk_list_store_clear (store);
}
static GList *
new_chatroom_dialog_model_get_selected (EmpathyNewChatroomDialog *dialog)
new_chatroom_dialog_listing_cb (EmpathyTpRoomlist *room_list,
gboolean listing,
EmpathyNewChatroomDialog *dialog)
{
GtkTreeView *view;
GtkTreeModel *model;
GtkTreeSelection *selection;
GList *rows, *l;
GList *chatrooms = NULL;
view = GTK_TREE_VIEW (dialog->treeview);
selection = gtk_tree_view_get_selection (view);
model = gtk_tree_view_get_model (view);
rows = gtk_tree_selection_get_selected_rows (selection, NULL);
for (l = rows; l; l = l->next) {
GtkTreeIter iter;
EmpathyRoomListItem *chatroom;
if (!gtk_tree_model_get_iter (model, &iter, l->data)) {
continue;
}
gtk_tree_model_get (model, &iter, COL_POINTER, &chatroom, -1);
chatrooms = g_list_append (chatrooms, chatroom);
/* Update the throbber */
if (listing) {
ephy_spinner_start (EPHY_SPINNER (dialog->throbber));
} else {
ephy_spinner_stop (EPHY_SPINNER (dialog->throbber));
}
g_list_foreach (rows, (GFunc) gtk_tree_path_free, NULL);
g_list_free (rows);
return chatrooms;
/* Update the refresh toggle button */
g_signal_handlers_block_by_func (dialog->togglebutton_refresh,
new_chatroom_dialog_togglebutton_refresh_toggled_cb,
dialog);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->togglebutton_refresh),
listing);
g_signal_handlers_unblock_by_func (dialog->togglebutton_refresh,
new_chatroom_dialog_togglebutton_refresh_toggled_cb,
dialog);
}
static gboolean
new_chatroom_dialog_model_filter_func (GtkTreeModel *model,
GtkTreeIter *iter,
EmpathyNewChatroomDialog *dialog)
static void
new_chatroom_dialog_model_clear (EmpathyNewChatroomDialog *dialog)
{
EmpathyRoomListItem *chatroom;
const gchar *text;
gchar *room_nocase;
gchar *text_nocase;
gboolean found = FALSE;
gtk_tree_model_get (model, iter, COL_POINTER, &chatroom, -1);
if (!chatroom) {
return TRUE;
}
text = gtk_entry_get_text (GTK_ENTRY (dialog->entry_room));
/* Casefold */
room_nocase = g_utf8_casefold (chatroom->id, -1);
text_nocase = g_utf8_casefold (text, -1);
/* Compare */
if (g_utf8_strlen (text_nocase, -1) < 1 ||
strstr (room_nocase, text_nocase)) {
found = TRUE;
}
g_free (room_nocase);
g_free (text_nocase);
GtkListStore *store;
return found;
store = GTK_LIST_STORE (dialog->model);
gtk_list_store_clear (store);
}
static void
......@@ -484,24 +453,30 @@ new_chatroom_dialog_model_row_activated_cb (GtkTreeView *tree_view,
}
static void