[Telepathy] rework of the UI
Xavier Claessens <[email protected]>
| Newsgroups | gmane.comp.gnome.gossip.devel |
|---|---|
| Message-ID | <1157923995.4605.12.camel@zdra-desktop> |
Hi, I'm working on the telepathy branch. I think the UI for accounts displays too many information to the user. I don't understand why we can't keep the normal user interface. So I'm cooking a patch which removes src/gossip-accounts-dialog-telepathy.[ch] src/gossip-new-account-window-telepathy.[ch] ui/telepathy.glade and merge changes in the normal code. I think there is not too many changes to justify a fork of those modules. Patch attached is a work in progress. I still have to modify account_manager_parse_account() and account_manager_file_save() because they don't uses account's properties. With telepathy all informations in the account is saved in a GHashTable but I think common informations that already are in the GossipAccount object should still be used and not ignored like now. I attach the patch here to have feedback, maybe I'm completely wrong ? Thanks, Xavier Claessens. _______________________________________________ Gossip-dev mailing list [email protected] http://lists.imendio.com/mailman/listinfo/gossip-dev
gossip-tp.patch
(text/x-patch, 21.2 KB)
Index: libgossip/gossip-account-manager.c
===================================================================
RCS file: /cvs/gnome/gossip/libgossip/gossip-account-manager.c,v
retrieving revision 1.23.2.2
diff -u -p -r1.23.2.2 gossip-account-manager.c
--- libgossip/gossip-account-manager.c 28 Aug 2006 18:52:22 -0000 1.23.2.2
+++ libgossip/gossip-account-manager.c 10 Sep 2006 21:17:57 -0000
@@ -887,8 +887,6 @@ account_manager_file_save (GossipAccount
g_hash_table_unref (account_parameters);
- g_hash_table_unref (account_parameters);
-
g_free (account_param_data);
xmlNewChild (node, NULL, "auto_connect", gossip_account_get_auto_connect (account) ? "yes" : "no");
Index: libgossip/gossip-account.c
===================================================================
RCS file: /cvs/gnome/gossip/libgossip/gossip-account.c,v
retrieving revision 1.40.2.2
diff -u -p -r1.40.2.2 gossip-account.c
--- libgossip/gossip-account.c 28 Aug 2006 18:52:22 -0000 1.40.2.2
+++ libgossip/gossip-account.c 10 Sep 2006 21:17:57 -0000
@@ -460,9 +460,6 @@ account_set_property (GObject *obje
gossip_account_set_name (GOSSIP_ACCOUNT (object),
g_value_get_string (value));
break;
-#ifdef USE_TELEPATHY
-
-#endif
case PROP_ID:
gossip_account_set_id (GOSSIP_ACCOUNT (object),
g_value_get_string (value));
@@ -1039,8 +1036,8 @@ gossip_account_param_set_string (GossipA
void
gossip_account_param_set_g_value (GossipAccount *account,
- const gchar *param_name,
- GValue *g_value)
+ const gchar *param_name,
+ GValue *g_value)
{
GossipAccountParam *account_param;
GossipAccountPriv *priv;
Index: src/Makefile.am
===================================================================
RCS file: /cvs/gnome/gossip/src/Makefile.am,v
retrieving revision 1.74.2.2
diff -u -p -r1.74.2.2 Makefile.am
--- src/Makefile.am 28 Aug 2006 18:52:23 -0000 1.74.2.2
+++ src/Makefile.am 10 Sep 2006 21:17:57 -0000
@@ -32,12 +32,6 @@ if HAVE_GNOME
eggtray_sources = eggtrayicon.c eggtrayicon.h
endif
-if USE_TELEPATHY
-telepathy_sources = \
- gossip-new-account-window-telepathy.c gossip-new-account-window-telepathy.h \
- gossip-accounts-dialog-telepathy.c gossip-accounts-dialog-telepathy.h
-endif
-
bin_PROGRAMS = gossip
gossip_SOURCES = \
@@ -45,7 +39,6 @@ gossip_SOURCES =
$(galago_sources) \
$(libnotify_sources) \
$(eggtray_sources) \
- $(telepathy_sources) \
gossip-about-dialog.c gossip-about-dialog.h \
gossip-accounts-dialog.c gossip-accounts-dialog.h \
gossip-account-button.c gossip-account-button.h \
@@ -136,6 +129,5 @@ EXTRA_DIST = \
$(dbus_binding_sources) \
$(galago_sources) \
$(libnotify_sources) \
- $(eggtray_sources) \
- $(telepathy_sources)
+ $(eggtray_sources)
Index: src/gossip-accounts-dialog.c
===================================================================
RCS file: /cvs/gnome/gossip/src/gossip-accounts-dialog.c,v
retrieving revision 1.33.2.1
diff -u -p -r1.33.2.1 gossip-accounts-dialog.c
--- src/gossip-accounts-dialog.c 7 Aug 2006 16:21:42 -0000 1.33.2.1
+++ src/gossip-accounts-dialog.c 10 Sep 2006 21:17:59 -0000
@@ -61,7 +61,7 @@ typedef struct {
GtkWidget *checkbutton_connect;
gboolean account_changed;
-
+
gboolean connecting_show;
guint connecting_id;
} GossipAccountsDialog;
Index: src/gossip-app.c
===================================================================
RCS file: /cvs/gnome/gossip/src/gossip-app.c,v
retrieving revision 1.256.2.3
diff -u -p -r1.256.2.3 gossip-app.c
--- src/gossip-app.c 28 Aug 2006 18:52:24 -0000 1.256.2.3
+++ src/gossip-app.c 10 Sep 2006 21:18:01 -0000
@@ -35,14 +35,6 @@
#include "eggtrayicon.h"
#endif
-#ifdef USE_TELEPATHY
-#include "gossip-accounts-dialog-telepathy.h"
-#include "gossip-new-account-window-telepathy.h"
-#else
-#include "gossip-accounts-dialog.h"
-#include "gossip-new-account-window.h"
-#endif
-
#include <libgossip/gossip-contact.h>
#include <libgossip/gossip-debug.h>
#include <libgossip/gossip-ft.h>
@@ -51,6 +43,8 @@
#include <libgossip/gossip-utils.h>
#include <libgossip/gossip-conf.h>
+#include "gossip-accounts-dialog.h"
+#include "gossip-new-account-window.h"
#include "gossip-about-dialog.h"
#include "gossip-account-button.h"
#include "gossip-add-contact-window.h"
@@ -497,19 +491,11 @@ app_setup (GossipSession *session
gossip_subscription_dialog_init (priv->session);
gossip_ft_window_init (priv->session);
-#ifdef USE_TELEPATHY
- if (gossip_new_account_window_telepathy_is_needed ()) {
-#else
if (gossip_new_account_window_is_needed ()) {
-#endif
gossip_debug (DEBUG_DOMAIN_SETUP,
"Showing new account window "
"for first time run");
-#ifdef USE_TELEPATHY
- gossip_new_account_window_telepathy_show (NULL);
-#else
gossip_new_account_window_show (NULL);
-#endif
}
gossip_debug (DEBUG_DOMAIN_SETUP,
@@ -1185,11 +1171,7 @@ static void
app_edit_accounts_cb (GtkWidget *widget,
GossipApp *app)
{
-#ifdef USE_TELEPATHY
- gossip_accounts_dialog_telepathy_show (NULL);
-#else
gossip_accounts_dialog_show (NULL);
-#endif
}
static void
@@ -1238,11 +1220,7 @@ app_throbber_button_press_event_cb (GtkW
return FALSE;
}
-#ifdef USE_TELEPATHY
- gossip_accounts_dialog_telepathy_show (NULL);
-#else
gossip_accounts_dialog_show (NULL);
-#endif
return FALSE;
}
@@ -1860,11 +1838,7 @@ app_connect_no_accounts_response_cb (Gtk
gpointer user_data)
{
gtk_widget_destroy (widget);
-#ifdef USE_TELEPATHY
- gossip_accounts_dialog_telepathy_show (NULL);
-#else
gossip_accounts_dialog_show (NULL);
-#endif
}
void
@@ -2102,11 +2076,8 @@ app_accounts_error_edit_clicked_cb (GtkB
priv = GET_PRIV (app);
-#ifdef USE_TELEPATHY
- gossip_accounts_dialog_telepathy_show (account);
-#else
gossip_accounts_dialog_show (account);
-#endif
+
g_hash_table_remove (priv->errors, account);
}
Index: src/gossip-new-account-window.c
===================================================================
RCS file: /cvs/gnome/gossip/src/gossip-new-account-window.c,v
retrieving revision 1.10.4.1
diff -u -p -r1.10.4.1 gossip-new-account-window.c
--- src/gossip-new-account-window.c 7 Aug 2006 16:21:43 -0000 1.10.4.1
+++ src/gossip-new-account-window.c 10 Sep 2006 21:18:02 -0000
@@ -32,6 +32,15 @@
#include "gossip-app.h"
#include "gossip-new-account-window.h"
+#ifdef USE_TELEPATHY
+#include <telepathy/gossip-telepathy-cmgr.h>
+enum {
+ COL_PROTOCOL_LABEL,
+ COL_PROTOCOL_PROTOCOL,
+ COL_PROTOCOL_INFOS,
+ COL_PROTOCOL_COUNT
+};
+#endif
typedef struct {
GtkWidget *window;
@@ -44,7 +53,9 @@ typedef struct {
GtkWidget *two_page;
GtkWidget *two_yes_radiobutton;
GtkWidget *two_no_radiobutton;
-
+ GtkWidget *two_protocol_label;
+ GtkWidget *two_protocol_combobox;
+
/* Page three */
GtkWidget *three_page;
GtkWidget *three_username_label;
@@ -106,9 +117,6 @@ static void new_account_window_regis
static void new_account_window_cancel (GossipNewAccountWindow *window);
static gboolean new_account_window_get_account_info (GossipNewAccountWindow *window,
GossipAccount **account);
-static GossipAccountType
- new_account_window_get_account_type (GossipNewAccountWindow *window);
-
static void new_account_window_1_prepare (GnomeDruidPage *page,
GnomeDruid *druid,
GossipNewAccountWindow *window);
@@ -147,6 +155,7 @@ static void new_account_window_druid
GossipNewAccountWindow *window);
static void new_account_window_destroy (GtkWidget *widget,
GossipNewAccountWindow *window);
+static void new_account_window_protocol_setup (GossipNewAccountWindow *window);
static gboolean
@@ -283,7 +292,13 @@ new_account_window_get_account_info (Gos
gboolean use_ssl;
gboolean use_proxy;
const gchar *name;
-
+#ifdef USE_TELEPATHY
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GossipCmgrInfo *info = NULL;
+ gchar *protocol = NULL;
+#endif
+
toggle = GTK_TOGGLE_BUTTON (window->two_yes_radiobutton);
has_account = gtk_toggle_button_get_active (toggle);
@@ -304,40 +319,47 @@ new_account_window_get_account_info (Gos
toggle = GTK_TOGGLE_BUTTON (window->four_ssl_checkbutton);
use_ssl = gtk_toggle_button_get_active (toggle);
-
+
toggle = GTK_TOGGLE_BUTTON (window->four_proxy_checkbutton);
use_proxy = gtk_toggle_button_get_active (toggle);
if (!resource || resource[0] == '\0') {
name = _("Home");
}
+
+#ifdef USE_TELEPATHY
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (window->two_protocol_combobox));
+ if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (window->two_protocol_combobox), &iter)) {
+ gtk_tree_model_get (model, &iter,
+ COL_PROTOCOL_INFOS, &info,
+ COL_PROTOCOL_PROTOCOL, &protocol,
+ -1);
+ }
+
+ *account = gossip_telepathy_cmgr_new_account_from_protocol (info, protocol);
+
+ /* FIXME: We will need to deal with registration at some point. Later. */
+#else
+ *account = g_object_new (GOSSIP_TYPE_ACCOUNT, NULL);
+#endif
/* create account */
port_int = atoi (port);
- *account = g_object_new (GOSSIP_TYPE_ACCOUNT,
- "name", name,
- "id", username,
- "resource", resource,
- "server", server,
- "password", password,
- "port", port_int,
- "use_ssl", use_ssl,
- "use_proxy", use_proxy,
- NULL);
+ g_object_set (*account,
+ "name", name,
+ "id", username,
+ "resource", resource,
+ "server", server,
+ "password", password,
+ "port", port_int,
+ "use_ssl", use_ssl,
+ "use_proxy", use_proxy,
+ NULL);
return has_account;
}
-static GossipAccountType
-new_account_window_get_account_type (GossipNewAccountWindow *window)
-{
- /* FIXME: in future we would have an account selector which we
- * would get the account type from, but for now, we just
- * support Jabber */
- return GOSSIP_ACCOUNT_TYPE_JABBER;
-}
-
static void
new_account_window_1_prepare (GnomeDruidPage *page,
GnomeDruid *druid,
@@ -355,6 +377,7 @@ new_account_window_2_prepare (GnomeDruid
first_time = gossip_new_account_window_is_needed ();
gnome_druid_set_buttons_sensitive (druid, first_time, TRUE, TRUE, FALSE);
+
}
static void
@@ -420,11 +443,16 @@ new_account_window_4_prepare (GnomeDruid
{
GtkToggleButton *toggle;
gboolean use_ssl;
+ gboolean ssl_supported;
guint16 port;
gchar *port_str;
const gchar *username;
gchar *server;
+ /* can we use ssl */
+ ssl_supported = gossip_protocol_is_ssl_supported (window->selected_protocol);
+ gtk_widget_set_sensitive (window->four_ssl_checkbutton, ssl_supported);
+
username = gtk_entry_get_text (GTK_ENTRY (window->three_username_entry));
server = gossip_protocol_get_default_server (window->selected_protocol, username);
@@ -681,15 +709,81 @@ gossip_new_account_window_is_needed (voi
return FALSE;
}
+static void
+new_account_window_protocol_setup (GossipNewAccountWindow *window)
+{
+#ifdef USE_TELEPATHY
+ GSList *cmgr_list, *l;
+ GtkListStore *store;
+ GtkCellRenderer *renderer;
+ GtkComboBox *combo_box;
+ GtkTreeIter iter;
+
+ /* set up combo box with new store */
+ combo_box = GTK_COMBO_BOX (window->two_protocol_combobox);
+
+ gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo_box));
+ store = gtk_list_store_new (COL_PROTOCOL_COUNT,
+ G_TYPE_STRING, /* Label */
+ G_TYPE_STRING, /* Protocol */
+ G_TYPE_POINTER); /* Infos */
+ gtk_combo_box_set_model (combo_box,
+ GTK_TREE_MODEL (store));
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, TRUE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), renderer,
+ "text", COL_PROTOCOL_LABEL,
+ NULL);
+
+ cmgr_list = gossip_telepathy_cmgr_list ();
+ for (l = cmgr_list; l; l = l->next) {
+ GossipCmgrInfo *cmgr_info;
+ gchar **protocols;
+
+ /* FIXME: how to free cmgr_info ? it's copied in the store... */
+ cmgr_info = gossip_telepathy_cmgr_info_get ((gchar *) l->data);
+ protocols = gossip_telepathy_cmgr_list_protocols (cmgr_info);
+
+ while (*protocols) {
+ gchar *protocol_label;
+
+ protocol_label = g_strdup_printf ("%s (%s)",
+ *protocols,
+ cmgr_info->name);
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter,
+ COL_PROTOCOL_LABEL, protocol_label,
+ COL_PROTOCOL_PROTOCOL, *protocols,
+ COL_PROTOCOL_INFOS, cmgr_info,
+ -1);
+ gtk_combo_box_set_active_iter (combo_box, &iter);
+
+ g_free (protocol_label);
+
+ protocols++;
+ }
+
+ g_free (l->data);
+ }
+
+ g_object_unref (store);
+ window->selected_protocol = gossip_protocol_new_from_account_type (GOSSIP_ACCOUNT_TYPE_TELEPATHY);
+#else
+ gtk_widget_hide (window->two_protocol_label);
+ gtk_widget_hide (window->two_protocol_combobox);
+ window->selected_protocol = gossip_protocol_new_from_account_type (GOSSIP_ACCOUNT_TYPE_JABBER);
+#endif
+}
+
void
gossip_new_account_window_show (GtkWindow *parent)
{
#ifdef HAVE_GNOME
GossipNewAccountWindow *window;
- GossipAccountType type;
GladeXML *glade;
GnomeDruid *druid;
- gboolean ssl_supported;
window = g_new0 (GossipNewAccountWindow, 1);
@@ -702,6 +796,8 @@ gossip_new_account_window_show (GtkWindo
"2_page", &window->two_page,
"2_yes_radiobutton", &window->two_yes_radiobutton,
"2_no_radiobutton", &window->two_no_radiobutton,
+ "2_protocol_label", &window->two_protocol_label,
+ "2_protocol_combobox", &window->two_protocol_combobox,
"3_page", &window->three_page,
"3_username_label", &window->three_username_label,
"3_username_new_label", &window->three_username_new_label,
@@ -782,14 +878,8 @@ gossip_new_account_window_show (GtkWindo
"can-default", TRUE,
"has-default", TRUE,
NULL);
-
- /* set default account type */
- type = new_account_window_get_account_type (window);
- window->selected_protocol = gossip_protocol_new_from_account_type (type);
- /* can we use ssl */
- ssl_supported = gossip_protocol_is_ssl_supported (window->selected_protocol);
- gtk_widget_set_sensitive (window->four_ssl_checkbutton, ssl_supported);
+ new_account_window_protocol_setup (window);
/* set the position, either center on screen on startup, or on the parent window */
if (parent != NULL) {
Index: telepathy/gossip-telepathy-cmgr.c
===================================================================
RCS file: /cvs/gnome/gossip/telepathy/Attic/gossip-telepathy-cmgr.c,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 gossip-telepathy-cmgr.c
--- telepathy/gossip-telepathy-cmgr.c 28 Aug 2006 18:52:31 -0000 1.1.2.1
+++ telepathy/gossip-telepathy-cmgr.c 10 Sep 2006 21:18:03 -0000
@@ -275,16 +275,16 @@ gossip_telepathy_cmgr_list_protocols (Go
return protocols_list;
}
-GossipAccount *
+GossipAccount*
gossip_telepathy_cmgr_new_account_from_protocol (GossipCmgrInfo *cmgr_info,
gchar *protocol)
{
- DBusGConnection *dbus_conn;
- TpConnMgr *conn_manager;
- GError *error = NULL;
- gboolean success;
- GossipAccount *account;
- GPtrArray *parameters;
+ DBusGConnection *dbus_conn;
+ TpConnMgr *conn_manager;
+ GError *error = NULL;
+ gboolean success;
+ GossipAccount *account;
+ GPtrArray *parameters;
account = g_object_new (GOSSIP_TYPE_ACCOUNT,
"type", GOSSIP_ACCOUNT_TYPE_TELEPATHY,
@@ -412,46 +412,46 @@ telepathy_cmgr_params_foreach (GValueArr
void
telepathy_cmgr_account_param_insert (gchar *key,
- gchar *value,
- TelepathyCmgrNewAccountData *new_account_data,
- gboolean mandatory)
+ gchar *value,
+ TelepathyCmgrNewAccountData *new_account_data,
+ gboolean mandatory)
{
- GType type;
- gboolean has_default;
- GValue *default_value;
-
- default_value = g_hash_table_lookup (new_account_data->default_values, key);
-
- has_default = (default_value != NULL);
-
- type = gossip_telepathy_dbus_type_to_g_type (value);
-
- gossip_account_param_insert (new_account_data->account,
- key,
- mandatory,
- FALSE,
- has_default,
- type);
-
- if (has_default) {
- gossip_account_param_set_g_value (new_account_data->account,
- key,
- default_value);
- }
+ GType type;
+ gboolean has_default;
+ GValue *default_value;
+
+ default_value = g_hash_table_lookup (new_account_data->default_values, key);
+
+ has_default = (default_value != NULL);
+
+ type = gossip_telepathy_dbus_type_to_g_type (value);
+
+ gossip_account_param_insert (new_account_data->account,
+ key,
+ mandatory,
+ FALSE,
+ has_default,
+ type);
+
+ if (has_default) {
+ gossip_account_param_set_g_value (new_account_data->account,
+ key,
+ default_value);
+ }
}
void
telepathy_cmgr_mandatory_params_foreach (gchar *key,
- gchar *value,
- TelepathyCmgrNewAccountData *new_account_data)
+ gchar *value,
+ TelepathyCmgrNewAccountData *new_account_data)
{
- telepathy_cmgr_account_param_insert (key, value, new_account_data, TRUE);
+ telepathy_cmgr_account_param_insert (key, value, new_account_data, TRUE);
}
void
telepathy_cmgr_optional_params_foreach (gchar *key,
- gchar *value,
- TelepathyCmgrNewAccountData *new_account_data)
+ gchar *value,
+ TelepathyCmgrNewAccountData *new_account_data)
{
- telepathy_cmgr_account_param_insert (key, value, new_account_data, FALSE);
+ telepathy_cmgr_account_param_insert (key, value, new_account_data, FALSE);
}
Index: ui/Makefile.am
===================================================================
RCS file: /cvs/gnome/gossip/ui/Makefile.am,v
retrieving revision 1.3.4.1
diff -u -p -r1.3.4.1 Makefile.am
--- ui/Makefile.am 28 Aug 2006 18:52:38 -0000 1.3.4.1
+++ ui/Makefile.am 10 Sep 2006 21:18:03 -0000
@@ -1,12 +1,7 @@
SUBDIRS = pixmaps
-if USE_TELEPATHY
-telepathy_data = telepathy.glade
-endif
-
gladedir = $(datadir)/gossip
glade_DATA = \
- $(telepathy_data) \
chat.glade \
group-chat.glade \
file-transfer.glade \
Index: ui/main.glade
===================================================================
RCS file: /cvs/gnome/gossip/ui/main.glade,v
retrieving revision 1.161.2.2
diff -u -p -r1.161.2.2 main.glade
--- ui/main.glade 17 Aug 2006 19:37:13 -0000 1.161.2.2
+++ ui/main.glade 10 Sep 2006 21:18:14 -0000
@@ -2662,6 +2662,44 @@ To get started, just click "Forward
<property name="fill">False</property>
</packing>
</child>
+
+ <child>
+ <widget class="GtkLabel" id="2_protocol_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Select a protocol:</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="xpad">6</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkComboBox" id="2_protocol_combobox">
+ <property name="visible">True</property>
+ <property name="add_tearoffs">False</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
</widget>
</child>
</widget>
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) iD8DBQBFBISb6dEBUn2qPAMRAkhVAJ9/asn9G3pIB9LkMwIbJg1+S2hK0ACbBSYk OHoXUAWz2oG6mXekXoOnrqg= =76Vb -----END PGP SIGNATURE-----