From d5e907193f0b29abb5a10f16c6e141183bbb3c4f Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Tue, 21 Apr 2009 11:48:02 +0800 Subject: Skeleton of a new presets dialog --- libempathy-gtk/Makefile.am | 2 + libempathy-gtk/empathy-status-preset-dialog.c | 83 +++++++++++++++++++++++++++ libempathy-gtk/empathy-status-preset-dialog.h | 63 ++++++++++++++++++++ 3 files changed, 148 insertions(+) create mode 100644 libempathy-gtk/empathy-status-preset-dialog.c create mode 100644 libempathy-gtk/empathy-status-preset-dialog.h (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am index 6f3b99ba6..2d9b21b00 100644 --- a/libempathy-gtk/Makefile.am +++ b/libempathy-gtk/Makefile.am @@ -50,6 +50,7 @@ libempathy_gtk_la_SOURCES = \ empathy-smiley-manager.c \ empathy-spell.c \ empathy-spell-dialog.c \ + empathy-status-preset-dialog.c \ empathy-theme-boxes.c \ empathy-theme-irc.c \ empathy-theme-manager.c \ @@ -103,6 +104,7 @@ libempathy_gtk_headers = \ empathy-smiley-manager.h \ empathy-spell.h \ empathy-spell-dialog.h \ + empathy-status-preset-dialog.h \ empathy-theme-boxes.h \ empathy-theme-irc.h \ empathy-theme-manager.h \ diff --git a/libempathy-gtk/empathy-status-preset-dialog.c b/libempathy-gtk/empathy-status-preset-dialog.c new file mode 100644 index 000000000..4c3cf2490 --- /dev/null +++ b/libempathy-gtk/empathy-status-preset-dialog.c @@ -0,0 +1,83 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * empathy-status-preset-dialog.c + * + * EmpathyStatusPresetDialog - a dialog for adding and removing preset status + * messages. + * + * Copyright (C) 2009 Collabora Ltd. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Davyd Madeley + */ + +#include "config.h" + +#include +#include + +#include + +#define DEBUG_FLAG EMPATHY_DEBUG_OTHER +#include + +#include "empathy-status-preset-dialog.h" + +#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyStatusPresetDialog) + +G_DEFINE_TYPE (EmpathyStatusPresetDialog, empathy_status_preset_dialog, GTK_TYPE_DIALOG) + +typedef struct _EmpathyStatusPresetDialogPriv EmpathyStatusPresetDialogPriv; +struct _EmpathyStatusPresetDialogPriv +{ + int dum; /*dummy*/ +}; + +static void +empathy_status_preset_dialog_class_init (EmpathyStatusPresetDialogClass *class) +{ + GObjectClass *gobject_class; + + gobject_class = G_OBJECT_CLASS (class); + + g_type_class_add_private (gobject_class, + sizeof (EmpathyStatusPresetDialogPriv)); +} + +static void +empathy_status_preset_dialog_init (EmpathyStatusPresetDialog *self) +{ + EmpathyStatusPresetDialogPriv *priv = self->priv = + G_TYPE_INSTANCE_GET_PRIVATE (self, + EMPATHY_TYPE_STATUS_PRESET_DIALOG, + EmpathyStatusPresetDialogPriv); + + (void) priv; +} + +GtkWidget * +empathy_status_preset_dialog_new (GtkWindow *parent) +{ + GtkWidget *self = g_object_new (EMPATHY_TYPE_STATUS_PRESET_DIALOG, + NULL); + + if (parent) { + gtk_window_set_transient_for (GTK_WINDOW (self), parent); + } + + return self; +} diff --git a/libempathy-gtk/empathy-status-preset-dialog.h b/libempathy-gtk/empathy-status-preset-dialog.h new file mode 100644 index 000000000..e53c3d8ad --- /dev/null +++ b/libempathy-gtk/empathy-status-preset-dialog.h @@ -0,0 +1,63 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * empathy-status-preset-dialog.c + * + * EmpathyStatusPresetDialog - a dialog for adding and removing preset status + * messages. + * + * Copyright (C) 2009 Collabora Ltd. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Davyd Madeley + */ + +#ifndef __EMPATHY_STATUS_PRESET_DIALOG_H__ +#define __EMPATHY_STATUS_PRESET_DIALOG_H__ + +#include + +G_BEGIN_DECLS + +#define EMPATHY_TYPE_STATUS_PRESET_DIALOG (empathy_status_preset_dialog_get_type ()) +#define EMPATHY_STATUS_PRESET_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMPATHY_TYPE_STATUS_PRESET_DIALOG, EmpathyStatusPresetDialog)) +#define EMPATHY_STATUS_PRESET_DIALOG_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), EMPATHY_TYPE_STATUS_PRESET_DIALOG, EmpathyStatusPresetDialogClass)) +#define EMPATHY_IS_STATUS_PRESET_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMPATHY_TYPE_STATUS_PRESET_DIALOG)) +#define EMPATHY_IS_STATUS_PRESET_DIALOG_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), EMPATHY_TYPE_STATUS_PRESET_DIALOG)) +#define EMPATHY_STATUS_PRESET_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_STATUS_PRESET_DIALOG, EmpathyStatusPresetDialogClass)) + +typedef struct _EmpathyStatusPresetDialog EmpathyStatusPresetDialog; +typedef struct _EmpathyStatusPresetDialogClass EmpathyStatusPresetDialogClass; + +struct _EmpathyStatusPresetDialog +{ + GtkDialog parent; + + /*< private >*/ + gpointer priv; +}; + +struct _EmpathyStatusPresetDialogClass +{ + GtkDialogClass parent_class; +}; + +GType empathy_status_preset_dialog_get_type (void); +GtkWidget *empathy_status_preset_dialog_new (GtkWindow *parent); + +G_END_DECLS + +#endif -- cgit v1.2.3 From 3803226331340b213351cf3bf92c85485bfe66b3 Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Tue, 21 Apr 2009 14:51:14 +0800 Subject: List presets in the treeview --- libempathy-gtk/Makefile.am | 1 + libempathy-gtk/empathy-status-preset-dialog.c | 128 ++++++++++++++++++++++++- libempathy-gtk/empathy-status-preset-dialog.ui | 84 ++++++++++++++++ 3 files changed, 210 insertions(+), 3 deletions(-) create mode 100644 libempathy-gtk/empathy-status-preset-dialog.ui (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am index 2d9b21b00..7fb4579cf 100644 --- a/libempathy-gtk/Makefile.am +++ b/libempathy-gtk/Makefile.am @@ -131,6 +131,7 @@ ui_DATA = \ empathy-account-widget-groupwise.ui \ empathy-account-widget-aim.ui \ empathy-spell-dialog.ui \ + empathy-status-preset-dialog.ui \ empathy-log-window.ui \ empathy-chat.ui \ empathy-new-message-dialog.ui diff --git a/libempathy-gtk/empathy-status-preset-dialog.c b/libempathy-gtk/empathy-status-preset-dialog.c index 4c3cf2490..88b12db3e 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.c +++ b/libempathy-gtk/empathy-status-preset-dialog.c @@ -30,21 +30,39 @@ #include #include +#include + +#include #include #define DEBUG_FLAG EMPATHY_DEBUG_OTHER #include +#include "empathy-ui-utils.h" #include "empathy-status-preset-dialog.h" #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyStatusPresetDialog) -G_DEFINE_TYPE (EmpathyStatusPresetDialog, empathy_status_preset_dialog, GTK_TYPE_DIALOG) +G_DEFINE_TYPE (EmpathyStatusPresetDialog, empathy_status_preset_dialog, GTK_TYPE_DIALOG); + +static McPresence states[] = { + MC_PRESENCE_AVAILABLE, + MC_PRESENCE_DO_NOT_DISTURB, + MC_PRESENCE_AWAY +}; typedef struct _EmpathyStatusPresetDialogPriv EmpathyStatusPresetDialogPriv; struct _EmpathyStatusPresetDialogPriv { - int dum; /*dummy*/ + GtkWidget *presets_treeview; +}; + +enum +{ + PRESETS_STORE_STATE, + PRESETS_STORE_ICON_NAME, + PRESETS_STORE_STATUS, + PRESETS_STORE_N_COLS }; static void @@ -58,6 +76,82 @@ empathy_status_preset_dialog_class_init (EmpathyStatusPresetDialogClass *class) sizeof (EmpathyStatusPresetDialogPriv)); } +static void +status_preset_dialog_setup_presets_update (EmpathyStatusPresetDialog *self) +{ + EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self); + GtkListStore *store; + int i; + + store = GTK_LIST_STORE (gtk_tree_view_get_model ( + GTK_TREE_VIEW (priv->presets_treeview))); + + for (i = 0; i < G_N_ELEMENTS (states); i++) + { + GList *presets, *l; + const char *icon_name; + + presets = empathy_status_presets_get (states[i], -1); + icon_name = empathy_icon_name_for_presence (states[i]); + + for (l = presets; l; l = l->next) { + char *preset = (char *) l->data; + + gtk_list_store_insert_with_values (store, + NULL, -1, + PRESETS_STORE_STATE, states[i], + PRESETS_STORE_ICON_NAME, icon_name, + PRESETS_STORE_STATUS, preset, + -1); + } + + g_list_free (presets); + } +} + +static void +status_preset_dialog_setup_presets_treeview (EmpathyStatusPresetDialog *self) +{ + EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self); + GtkWidget *treeview = priv->presets_treeview; + GtkListStore *store; + GtkTreeViewColumn *column; + GtkCellRenderer *renderer; + + store = gtk_list_store_new (PRESETS_STORE_N_COLS, + MC_TYPE_PRESENCE, /* PRESETS_STORE_STATE */ + G_TYPE_STRING, /* PRESETS_STORE_ICON_NAME */ + G_TYPE_STRING); /* PRESETS_STORE_STATUS */ + + gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), + GTK_TREE_MODEL (store)); + g_object_unref (store); + + status_preset_dialog_setup_presets_update (self); + + column = gtk_tree_view_column_new (); + gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column); + + renderer = gtk_cell_renderer_pixbuf_new (); + gtk_tree_view_column_pack_start (column, renderer, FALSE); + gtk_tree_view_column_add_attribute (column, renderer, + "icon-name", PRESETS_STORE_ICON_NAME); + + renderer = gtk_cell_renderer_text_new (); + gtk_tree_view_column_pack_start (column, renderer, TRUE); + gtk_tree_view_column_add_attribute (column, renderer, + "text", PRESETS_STORE_STATUS); +} + +static void +status_preset_dialog_preset_selection_changed (GtkTreeSelection *selection, + GtkWidget *remove_button) +{ + /* update the sensitivity of the Remove button */ + gtk_widget_set_sensitive (remove_button, + gtk_tree_selection_get_selected (selection, NULL, NULL)); +} + static void empathy_status_preset_dialog_init (EmpathyStatusPresetDialog *self) { @@ -65,8 +159,36 @@ empathy_status_preset_dialog_init (EmpathyStatusPresetDialog *self) G_TYPE_INSTANCE_GET_PRIVATE (self, EMPATHY_TYPE_STATUS_PRESET_DIALOG, EmpathyStatusPresetDialogPriv); + GtkBuilder *gui; + GtkWidget *toplevel_vbox, *remove_button; + char *filename; + + (void) priv; /* hack */ + + gtk_dialog_set_has_separator (GTK_DIALOG (self), FALSE); + gtk_dialog_add_button (GTK_DIALOG (self), + GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); + + filename = empathy_file_lookup ("empathy-status-preset-dialog.ui", + "libempathy-gtk"); + gui = empathy_builder_get_file (filename, + "toplevel-vbox", &toplevel_vbox, + "presets-treeview", &priv->presets_treeview, + "remove-button", &remove_button, + NULL); + g_free (filename); + + status_preset_dialog_setup_presets_treeview (self); + g_signal_connect (gtk_tree_view_get_selection ( + GTK_TREE_VIEW (priv->presets_treeview)), + "changed", + G_CALLBACK (status_preset_dialog_preset_selection_changed), + remove_button); + + gtk_box_pack_start(GTK_BOX (GTK_DIALOG (self)->vbox), toplevel_vbox, + TRUE, TRUE, 0); - (void) priv; + g_object_unref (gui); } GtkWidget * diff --git a/libempathy-gtk/empathy-status-preset-dialog.ui b/libempathy-gtk/empathy-status-preset-dialog.ui new file mode 100644 index 000000000..9bfae2cd4 --- /dev/null +++ b/libempathy-gtk/empathy-status-preset-dialog.ui @@ -0,0 +1,84 @@ + + + + + + True + 6 + vertical + 6 + + + True + True + never + etched-in + + + True + True + False + + + + + 0 + + + + + True + end + + + gtk-remove + True + False + True + True + True + + + False + False + 0 + + + + + False + 1 + + + + + True + 3 + + + True + + + 0 + + + + + gtk-add + True + True + True + True + + + 1 + + + + + False + 2 + + + + -- cgit v1.2.3 From e3b6bd0deedd3353ecde9cc50ec3fb90d9656ec4 Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Tue, 21 Apr 2009 16:21:55 +0800 Subject: Make [Remove] work --- libempathy-gtk/empathy-status-preset-dialog.c | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-status-preset-dialog.c b/libempathy-gtk/empathy-status-preset-dialog.c index 88b12db3e..cf28352eb 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.c +++ b/libempathy-gtk/empathy-status-preset-dialog.c @@ -86,6 +86,8 @@ status_preset_dialog_setup_presets_update (EmpathyStatusPresetDialog *self) store = GTK_LIST_STORE (gtk_tree_view_get_model ( GTK_TREE_VIEW (priv->presets_treeview))); + gtk_list_store_clear (store); + for (i = 0; i < G_N_ELEMENTS (states); i++) { GList *presets, *l; @@ -152,6 +154,36 @@ status_preset_dialog_preset_selection_changed (GtkTreeSelection *selection, gtk_tree_selection_get_selected (selection, NULL, NULL)); } +static void +status_preset_dialog_preset_remove (GtkWidget *button, + EmpathyStatusPresetDialog *self) +{ + EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self); + GtkTreeSelection *selection; + GtkTreeModel *model; + GtkTreeIter iter; + McPresence state; + char *status; + + selection = gtk_tree_view_get_selection ( + GTK_TREE_VIEW (priv->presets_treeview)); + + g_return_if_fail (gtk_tree_selection_get_selected (selection, + &model, &iter)); + + gtk_tree_model_get (model, &iter, + PRESETS_STORE_STATE, &state, + PRESETS_STORE_STATUS, &status, + -1); + + DEBUG ("REMOVE PRESET (%i, %s)\n", state, status); + empathy_status_presets_remove (state, status); + + g_free (status); + + status_preset_dialog_setup_presets_update (self); +} + static void empathy_status_preset_dialog_init (EmpathyStatusPresetDialog *self) { @@ -184,6 +216,9 @@ empathy_status_preset_dialog_init (EmpathyStatusPresetDialog *self) "changed", G_CALLBACK (status_preset_dialog_preset_selection_changed), remove_button); + empathy_builder_connect (gui, self, + "remove-button", "clicked", status_preset_dialog_preset_remove, + NULL); gtk_box_pack_start(GTK_BOX (GTK_DIALOG (self)->vbox), toplevel_vbox, TRUE, TRUE, 0); -- cgit v1.2.3 From cf70c333979664fc8298b842e4d1d42df69a0dab Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Wed, 22 Apr 2009 09:37:33 +0800 Subject: Make [Add] work --- libempathy-gtk/empathy-status-preset-dialog.c | 155 ++++++++++++++++++++++++- libempathy-gtk/empathy-status-preset-dialog.ui | 1 + 2 files changed, 150 insertions(+), 6 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-status-preset-dialog.c b/libempathy-gtk/empathy-status-preset-dialog.c index cf28352eb..ecb794b44 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.c +++ b/libempathy-gtk/empathy-status-preset-dialog.c @@ -55,6 +55,11 @@ typedef struct _EmpathyStatusPresetDialogPriv EmpathyStatusPresetDialogPriv; struct _EmpathyStatusPresetDialogPriv { GtkWidget *presets_treeview; + GtkWidget *add_combobox; + GtkWidget *add_button; + + McPresence selected_state; + gboolean add_combo_changed; }; enum @@ -65,6 +70,15 @@ enum PRESETS_STORE_N_COLS }; +enum +{ + ADD_COMBO_STATE, + ADD_COMBO_ICON_NAME, + ADD_COMBO_STATUS, + ADD_COMBO_DEFAULT_TEXT, + ADD_COMBO_N_COLS +}; + static void empathy_status_preset_dialog_class_init (EmpathyStatusPresetDialogClass *class) { @@ -88,8 +102,7 @@ status_preset_dialog_setup_presets_update (EmpathyStatusPresetDialog *self) gtk_list_store_clear (store); - for (i = 0; i < G_N_ELEMENTS (states); i++) - { + for (i = 0; i < G_N_ELEMENTS (states); i++) { GList *presets, *l; const char *icon_name; @@ -111,6 +124,64 @@ status_preset_dialog_setup_presets_update (EmpathyStatusPresetDialog *self) } } +static void +status_preset_add_combo_reset (EmpathyStatusPresetDialog *self) +{ + EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self); + + gtk_combo_box_set_active (GTK_COMBO_BOX (priv->add_combobox), 0); +} + +static void +status_preset_dialog_setup_add_combobox (EmpathyStatusPresetDialog *self) +{ + EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self); + GtkWidget *combobox = priv->add_combobox; + GtkListStore *store; + GtkCellRenderer *renderer; + int i; + + store = gtk_list_store_new (ADD_COMBO_N_COLS, + MC_TYPE_PRESENCE, /* ADD_COMBO_STATE */ + G_TYPE_STRING, /* ADD_COMBO_ICON_NAME */ + G_TYPE_STRING, /* ADD_COMBO_STATUS */ + G_TYPE_STRING); /* ADD_COMBO_DEFAULT_TEXT */ + + gtk_combo_box_set_model (GTK_COMBO_BOX (combobox), + GTK_TREE_MODEL (store)); + g_object_unref (store); + + gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (combobox), + ADD_COMBO_DEFAULT_TEXT); + + for (i = 0; i < G_N_ELEMENTS (states); i++) { + gtk_list_store_insert_with_values (store, NULL, -1, + ADD_COMBO_STATE, states[i], + ADD_COMBO_ICON_NAME, empathy_icon_name_for_presence (states[i]), + ADD_COMBO_STATUS, empathy_presence_get_default_message (states[i]), + ADD_COMBO_DEFAULT_TEXT, _("Enter Custom Message"), + -1); + } + + gtk_cell_layout_clear (GTK_CELL_LAYOUT (combobox)); + + renderer = gtk_cell_renderer_pixbuf_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, FALSE); + gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combobox), renderer, + "icon-name", ADD_COMBO_ICON_NAME); + + renderer = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE); + gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combobox), renderer, + "text", ADD_COMBO_STATUS); + g_object_set (renderer, + "style", PANGO_STYLE_ITALIC, + "foreground", "Gray", /* FIXME - theme */ + NULL); + + status_preset_add_combo_reset (self); +} + static void status_preset_dialog_setup_presets_treeview (EmpathyStatusPresetDialog *self) { @@ -155,7 +226,7 @@ status_preset_dialog_preset_selection_changed (GtkTreeSelection *selection, } static void -status_preset_dialog_preset_remove (GtkWidget *button, +status_preset_dialog_preset_remove (GtkButton *button, EmpathyStatusPresetDialog *self) { EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self); @@ -184,6 +255,68 @@ status_preset_dialog_preset_remove (GtkWidget *button, status_preset_dialog_setup_presets_update (self); } +static void +status_preset_dialog_add_combo_changed (GtkComboBox *combo, + EmpathyStatusPresetDialog *self) +{ + EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self); + GtkWidget *entry; + GtkTreeModel *model; + GtkTreeIter iter; + + model = gtk_combo_box_get_model (combo); + entry = gtk_bin_get_child (GTK_BIN (combo)); + + if (gtk_combo_box_get_active_iter (combo, &iter)) { + char *icon_name; + GdkColor colour; + + gtk_tree_model_get (model, &iter, + PRESETS_STORE_STATE, &priv->selected_state, + PRESETS_STORE_ICON_NAME, &icon_name, + -1); + + gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry), + GTK_ENTRY_ICON_PRIMARY, + icon_name); + + g_free (icon_name); + + gtk_widget_grab_focus (entry); + gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1); + + priv->add_combo_changed = FALSE; + gtk_widget_set_sensitive (priv->add_button, FALSE); + + gdk_color_parse ("Gray", &colour); /* FIXME - theme */ + gtk_widget_modify_text (entry, GTK_STATE_NORMAL, &colour); + } else { + priv->add_combo_changed = TRUE; + gtk_widget_set_sensitive (priv->add_button, TRUE); + gtk_widget_modify_text (entry, GTK_STATE_NORMAL, NULL); + } +} + +static void +status_preset_dialog_add_preset (GtkWidget *widget, + EmpathyStatusPresetDialog *self) +{ + EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self); + GtkWidget *entry; + const char *status; + + g_return_if_fail (priv->add_combo_changed); + + entry = gtk_bin_get_child (GTK_BIN (priv->add_combobox)); + status = gtk_entry_get_text (GTK_ENTRY (entry)); + + DEBUG ("ADD PRESET (%i, %s)\n", priv->selected_state, status); + empathy_status_presets_set_last (priv->selected_state, status); + + status_preset_dialog_setup_presets_update (self); + status_preset_add_combo_reset (self); +} + static void empathy_status_preset_dialog_init (EmpathyStatusPresetDialog *self) { @@ -195,8 +328,6 @@ empathy_status_preset_dialog_init (EmpathyStatusPresetDialog *self) GtkWidget *toplevel_vbox, *remove_button; char *filename; - (void) priv; /* hack */ - gtk_dialog_set_has_separator (GTK_DIALOG (self), FALSE); gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); @@ -207,19 +338,31 @@ empathy_status_preset_dialog_init (EmpathyStatusPresetDialog *self) "toplevel-vbox", &toplevel_vbox, "presets-treeview", &priv->presets_treeview, "remove-button", &remove_button, + "add-combobox", &priv->add_combobox, + "add-button", &priv->add_button, NULL); g_free (filename); - status_preset_dialog_setup_presets_treeview (self); g_signal_connect (gtk_tree_view_get_selection ( GTK_TREE_VIEW (priv->presets_treeview)), "changed", G_CALLBACK (status_preset_dialog_preset_selection_changed), remove_button); + + g_signal_connect (gtk_bin_get_child (GTK_BIN (priv->add_combobox)), + "activate", + G_CALLBACK (status_preset_dialog_add_preset), + self); + empathy_builder_connect (gui, self, "remove-button", "clicked", status_preset_dialog_preset_remove, + "add-combobox", "changed", status_preset_dialog_add_combo_changed, + "add-button", "clicked", status_preset_dialog_add_preset, NULL); + status_preset_dialog_setup_presets_treeview (self); + status_preset_dialog_setup_add_combobox (self); + gtk_box_pack_start(GTK_BOX (GTK_DIALOG (self)->vbox), toplevel_vbox, TRUE, TRUE, 0); diff --git a/libempathy-gtk/empathy-status-preset-dialog.ui b/libempathy-gtk/empathy-status-preset-dialog.ui index 9bfae2cd4..2a1ee4c18 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.ui +++ b/libempathy-gtk/empathy-status-preset-dialog.ui @@ -66,6 +66,7 @@ gtk-add True + False True True True -- cgit v1.2.3 From 155a17d3ddc4d173a57429faa2d59bba01d5ac5c Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Wed, 22 Apr 2009 10:05:10 +0800 Subject: Connect new dialog into presence chooser, remove old dialog --- libempathy-gtk/Makefile.am | 1 - libempathy-gtk/empathy-presence-chooser.c | 237 +------------------------- libempathy-gtk/empathy-presence-chooser.ui | 140 --------------- libempathy-gtk/empathy-status-preset-dialog.c | 2 + 4 files changed, 11 insertions(+), 369 deletions(-) delete mode 100644 libempathy-gtk/empathy-presence-chooser.ui (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am index 7fb4579cf..63bcf5ae3 100644 --- a/libempathy-gtk/Makefile.am +++ b/libempathy-gtk/Makefile.am @@ -119,7 +119,6 @@ uidir = $(datadir)/empathy ui_DATA = \ empathy-contact-widget.ui \ empathy-contact-dialogs.ui \ - empathy-presence-chooser.ui \ empathy-account-widget-generic.ui \ empathy-account-widget-jabber.ui \ empathy-account-widget-msn.ui \ diff --git a/libempathy-gtk/empathy-presence-chooser.c b/libempathy-gtk/empathy-presence-chooser.c index 8e9574bc5..d565cf387 100644 --- a/libempathy-gtk/empathy-presence-chooser.c +++ b/libempathy-gtk/empathy-presence-chooser.c @@ -46,6 +46,7 @@ #include "empathy-ui-utils.h" #include "empathy-images.h" #include "empathy-presence-chooser.h" +#include "empathy-status-preset-dialog.h" /* Flashing delay for icons (milliseconds). */ #define FLASH_TIMEOUT 500 @@ -95,16 +96,6 @@ typedef struct { guint flash_timeout_id; } EmpathyPresenceChooserPriv; -typedef struct { - GtkWidget *dialog; - GtkWidget *checkbutton_save; - GtkWidget *comboboxentry_message; - GtkWidget *entry_message; - GtkWidget *combobox_status; - GtkTreeModel *model_status; -} CustomMessageDialog; - -static CustomMessageDialog *message_dialog = NULL; /* States to be listed in the menu. * Each state has a boolean telling if it can have custom message */ static guint states[] = {MC_PRESENCE_AVAILABLE, TRUE, @@ -130,7 +121,6 @@ static void presence_chooser_set_state (McPresence const gchar *status); static void presence_chooser_custom_activate_cb (GtkWidget *item, gpointer user_data); -static void presence_chooser_dialog_show (GtkWindow *parent); G_DEFINE_TYPE (EmpathyPresenceChooser, empathy_presence_chooser, GTK_TYPE_COMBO_BOX_ENTRY); @@ -576,7 +566,7 @@ presence_chooser_changed_cb (GtkComboBox *self, gpointer user_data) } if (type == ENTRY_TYPE_EDIT_CUSTOM) { - GtkWidget *window; + GtkWidget *window, *dialog; presence_chooser_reset_status (EMPATHY_PRESENCE_CHOOSER (self)); @@ -586,7 +576,9 @@ presence_chooser_changed_cb (GtkComboBox *self, gpointer user_data) window = NULL; } - presence_chooser_dialog_show (GTK_WINDOW (window)); + dialog = empathy_status_preset_dialog_new (GTK_WINDOW (window)); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); } else if (type == ENTRY_TYPE_CUSTOM) { gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry), @@ -1058,220 +1050,9 @@ static void presence_chooser_custom_activate_cb (GtkWidget *item, gpointer user_data) { - presence_chooser_dialog_show (NULL); -} - -static McPresence -presence_chooser_dialog_get_selected (CustomMessageDialog *dialog) -{ - GtkTreeModel *model; - GtkTreeIter iter; - McPresence presence = LAST_MC_PRESENCE; - - model = gtk_combo_box_get_model (GTK_COMBO_BOX (dialog->combobox_status)); - if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (dialog->combobox_status), &iter)) { - gtk_tree_model_get (model, &iter, - COL_PRESENCE, &presence, - -1); - } - - return presence; -} - -static void -presence_chooser_dialog_status_changed_cb (GtkWidget *widget, - CustomMessageDialog *dialog) -{ - GtkListStore *store; - GtkTreeIter iter; - McPresence presence = LAST_MC_PRESENCE; - GList *messages, *l; - - presence = presence_chooser_dialog_get_selected (dialog); - - store = gtk_list_store_new (1, G_TYPE_STRING); - messages = empathy_status_presets_get (presence, -1); - for (l = messages; l; l = l->next) { - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, l->data, -1); - } - - gtk_entry_set_text (GTK_ENTRY (dialog->entry_message), - messages ? messages->data : ""); - - g_list_free (messages); - - gtk_combo_box_set_model (GTK_COMBO_BOX (dialog->comboboxentry_message), - GTK_TREE_MODEL (store)); - - g_object_unref (store); -} - -static void -presence_chooser_dialog_message_changed_cb (GtkWidget *widget, - CustomMessageDialog *dialog) -{ - McPresence presence; - GList *messages, *l; - const gchar *text; - gboolean found = FALSE; - - presence = presence_chooser_dialog_get_selected (dialog); - text = gtk_entry_get_text (GTK_ENTRY (dialog->entry_message)); - - messages = empathy_status_presets_get (presence, -1); - for (l = messages; l; l = l->next) { - if (!tp_strdiff (text, l->data)) { - found = TRUE; - break; - } - } - g_list_free (messages); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->checkbutton_save), - found); -} - -static void -presence_chooser_dialog_save_toggled_cb (GtkWidget *widget, - CustomMessageDialog *dialog) -{ - gboolean active; - McPresence state; - const gchar *text; - - active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->checkbutton_save)); - state = presence_chooser_dialog_get_selected (dialog); - text = gtk_entry_get_text (GTK_ENTRY (dialog->entry_message)); - - if (active) { - empathy_status_presets_set_last (state, text); - } else { - empathy_status_presets_remove (state, text); - } -} - -static void -presence_chooser_dialog_setup (CustomMessageDialog *dialog) -{ - GtkListStore *store; - GtkCellRenderer *renderer; - GtkTreeIter iter; - guint i; - - store = gtk_list_store_new (COL_COUNT, - G_TYPE_STRING, /* Icon name */ - G_TYPE_STRING, /* Label */ - MC_TYPE_PRESENCE); /* Presence */ - gtk_combo_box_set_model (GTK_COMBO_BOX (dialog->combobox_status), - GTK_TREE_MODEL (store)); - - renderer = gtk_cell_renderer_pixbuf_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (dialog->combobox_status), renderer, FALSE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (dialog->combobox_status), renderer, - "icon-name", COL_ICON, - NULL); - g_object_set (renderer, "stock-size", GTK_ICON_SIZE_BUTTON, NULL); - - renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (dialog->combobox_status), renderer, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (dialog->combobox_status), renderer, - "text", COL_LABEL, - NULL); - - for (i = 0; i < G_N_ELEMENTS (states); i += 2) { - if (!states[i+1]) { - continue; - } - - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, - COL_ICON, empathy_icon_name_for_presence (states[i]), - COL_LABEL, empathy_presence_get_default_message (states[i]), - COL_PRESENCE, states[i], - -1); - } - - gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->combobox_status), 0); -} - -static void -presence_chooser_dialog_response_cb (GtkWidget *widget, - gint response, - CustomMessageDialog *dialog) -{ - if (response == GTK_RESPONSE_APPLY) { - McPresence state; - const gchar *text; - - state = presence_chooser_dialog_get_selected (dialog); - text = gtk_entry_get_text (GTK_ENTRY (dialog->entry_message)); + GtkWidget *dialog; - presence_chooser_set_state (state, text); - } - - gtk_widget_destroy (widget); + dialog = empathy_status_preset_dialog_new (NULL); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); } - -static void -presence_chooser_dialog_destroy_cb (GtkWidget *widget, - CustomMessageDialog *dialog) -{ - - g_free (dialog); - message_dialog = NULL; -} - -static void -presence_chooser_dialog_show (GtkWindow *parent) -{ - GtkBuilder *gui; - gchar *filename; - - if (message_dialog) { - gtk_window_present (GTK_WINDOW (message_dialog->dialog)); - return; - } - - message_dialog = g_new0 (CustomMessageDialog, 1); - - filename = empathy_file_lookup ("empathy-presence-chooser.ui", - "libempathy-gtk"); - gui = empathy_builder_get_file (filename, - "custom_message_dialog", &message_dialog->dialog, - "checkbutton_save", &message_dialog->checkbutton_save, - "comboboxentry_message", &message_dialog->comboboxentry_message, - "combobox_status", &message_dialog->combobox_status, - NULL); - g_free (filename); - - empathy_builder_connect (gui, message_dialog, - "custom_message_dialog", "destroy", presence_chooser_dialog_destroy_cb, - "custom_message_dialog", "response", presence_chooser_dialog_response_cb, - "combobox_status", "changed", presence_chooser_dialog_status_changed_cb, - "checkbutton_save", "toggled", presence_chooser_dialog_save_toggled_cb, - NULL); - - g_object_unref (gui); - - /* Setup the message combobox */ - message_dialog->entry_message = GTK_BIN (message_dialog->comboboxentry_message)->child; - gtk_entry_set_activates_default (GTK_ENTRY (message_dialog->entry_message), TRUE); - gtk_entry_set_width_chars (GTK_ENTRY (message_dialog->entry_message), 25); - g_signal_connect (message_dialog->entry_message, "changed", - G_CALLBACK (presence_chooser_dialog_message_changed_cb), - message_dialog); - - presence_chooser_dialog_setup (message_dialog); - - gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (message_dialog->comboboxentry_message), 0); - - if (parent) { - gtk_window_set_transient_for ( - GTK_WINDOW (message_dialog->dialog), - parent); - } - - gtk_widget_show_all (message_dialog->dialog); -} - diff --git a/libempathy-gtk/empathy-presence-chooser.ui b/libempathy-gtk/empathy-presence-chooser.ui deleted file mode 100644 index 6e0a155d0..000000000 --- a/libempathy-gtk/empathy-presence-chooser.ui +++ /dev/null @@ -1,140 +0,0 @@ - - - - - - True - 5 - Custom message - False - dialog - False - - - True - - - True - 5 - 3 - 2 - 6 - 6 - - - True - - - 1 - 2 - GTK_FILL - GTK_FILL - - - - - True - - - 1 - 2 - 1 - 2 - GTK_FILL - GTK_FILL - - - - - Save message - True - True - False - True - True - - - 2 - 2 - 3 - - - - - - True - 0 - Message: - - - 1 - 2 - GTK_FILL - - - - - - True - 0 - Status: - - - GTK_FILL - - - - - - 1 - - - - - True - end - - - gtk-cancel - True - True - True - False - True - - - False - False - 0 - - - - - gtk-apply - True - True - True - False - True - - - False - False - 1 - - - - - False - end - 0 - - - - - - closebutton1 - button1 - - - diff --git a/libempathy-gtk/empathy-status-preset-dialog.c b/libempathy-gtk/empathy-status-preset-dialog.c index ecb794b44..a428667e9 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.c +++ b/libempathy-gtk/empathy-status-preset-dialog.c @@ -328,6 +328,8 @@ empathy_status_preset_dialog_init (EmpathyStatusPresetDialog *self) GtkWidget *toplevel_vbox, *remove_button; char *filename; + gtk_window_set_title (GTK_WINDOW (self), + _("Edit Custom Messages")); gtk_dialog_set_has_separator (GTK_DIALOG (self), FALSE); gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); -- cgit v1.2.3 From 3f2af5f3ac6fc862cb99fb8dac2df69b9a82a152 Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Wed, 22 Apr 2009 10:28:53 +0800 Subject: Output GtkBuilder errors as g_critical() not DEBUG() --- libempathy-gtk/empathy-ui-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c index aa3492899..9a249e65b 100644 --- a/libempathy-gtk/empathy-ui-utils.c +++ b/libempathy-gtk/empathy-ui-utils.c @@ -102,7 +102,7 @@ builder_get_file_valist (const gchar *filename, gui = gtk_builder_new (); if (!gtk_builder_add_from_file (gui, filename, &error)) { - DEBUG ("Error: %s", error->message); + g_critical ("GtkBuilder Error: %s", error->message); g_clear_error (&error); g_object_unref (gui); return NULL; -- cgit v1.2.3 From 673bbbcbaf80c3ae640e329419fd0d29e3bd738d Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Wed, 22 Apr 2009 10:52:19 +0800 Subject: Add some labels to the UI --- libempathy-gtk/empathy-status-preset-dialog.ui | 37 +++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-status-preset-dialog.ui b/libempathy-gtk/empathy-status-preset-dialog.ui index 2a1ee4c18..ead8ab85d 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.ui +++ b/libempathy-gtk/empathy-status-preset-dialog.ui @@ -7,6 +7,21 @@ 6 vertical 6 + + + True + 0 + Saved Presets + add-combobox + + + + + + False + 0 + + True @@ -22,7 +37,7 @@ - 0 + 1 @@ -47,7 +62,23 @@ False - 1 + 2 + + + + + True + 0 + Add _New Preset + True + add-combobox + + + + + + False + 3 @@ -78,7 +109,7 @@ False - 2 + 4 -- cgit v1.2.3 From 814e6198069aaa5df9cf63e51b29afe78ef22dde Mon Sep 17 00:00:00 2001 From: Adam Schreiber Date: Tue, 21 Apr 2009 17:42:30 +0100 Subject: Display spelling suggestions in a submenu instead of in a separate dialog. Fixes bug #578399 --- libempathy-gtk/Makefile.am | 3 - libempathy-gtk/empathy-chat.c | 50 +++++-- libempathy-gtk/empathy-spell-dialog.c | 264 ---------------------------------- libempathy-gtk/empathy-spell-dialog.h | 39 ----- 4 files changed, 37 insertions(+), 319 deletions(-) delete mode 100644 libempathy-gtk/empathy-spell-dialog.c delete mode 100644 libempathy-gtk/empathy-spell-dialog.h (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am index 6f3b99ba6..470d44ea5 100644 --- a/libempathy-gtk/Makefile.am +++ b/libempathy-gtk/Makefile.am @@ -49,7 +49,6 @@ libempathy_gtk_la_SOURCES = \ empathy-profile-chooser.c \ empathy-smiley-manager.c \ empathy-spell.c \ - empathy-spell-dialog.c \ empathy-theme-boxes.c \ empathy-theme-irc.c \ empathy-theme-manager.c \ @@ -102,7 +101,6 @@ libempathy_gtk_headers = \ empathy-profile-chooser.h \ empathy-smiley-manager.h \ empathy-spell.h \ - empathy-spell-dialog.h \ empathy-theme-boxes.h \ empathy-theme-irc.h \ empathy-theme-manager.h \ @@ -128,7 +126,6 @@ ui_DATA = \ empathy-account-widget-yahoo.ui \ empathy-account-widget-groupwise.ui \ empathy-account-widget-aim.ui \ - empathy-spell-dialog.ui \ empathy-log-window.ui \ empathy-chat.ui \ empathy-new-message-dialog.ui diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index 7d9390274..dea3b874c 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -45,7 +45,6 @@ #include "empathy-chat.h" #include "empathy-conf.h" #include "empathy-spell.h" -#include "empathy-spell-dialog.h" #include "empathy-contact-list-store.h" #include "empathy-contact-list-view.h" #include "empathy-contact-menu.h" @@ -932,13 +931,37 @@ chat_spell_free (EmpathyChatSpell *chat_spell) } static void -chat_text_check_word_spelling_cb (GtkMenuItem *menuitem, - EmpathyChatSpell *chat_spell) +chat_spelling_menu_activate_cb (GtkMenuItem *menu_item, + EmpathyChatSpell *chat_spell) { - empathy_spell_dialog_show (chat_spell->chat, - &chat_spell->start, - &chat_spell->end, - chat_spell->word); + empathy_chat_correct_word (chat_spell->chat, + &(chat_spell->start), + &(chat_spell->end), + gtk_menu_item_get_label(menu_item)); +} + +static GtkWidget* +chat_spelling_build_menu (EmpathyChatSpell *chat_spell) +{ + GtkWidget *menu, *menu_item; + GList *suggestions, *l; + + menu = gtk_menu_new(); + suggestions = empathy_spell_get_suggestions (chat_spell->word); + for (l = suggestions; l; l=l->next) { + menu_item = gtk_menu_item_new_with_label (l->data); + g_signal_connect (G_OBJECT (menu_item), + "activate", + G_CALLBACK (chat_spelling_menu_activate_cb), + chat_spell); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); + } + + empathy_spell_free_suggestions (suggestions); + + gtk_widget_show_all (menu); + + return menu; } static void @@ -961,7 +984,8 @@ chat_input_populate_popup_cb (GtkTextView *view, GtkTextIter iter, start, end; GtkWidget *item; gchar *str = NULL; - EmpathyChatSpell *chat_spell; + EmpathyChatSpell *chat_spell; + GtkWidget *spell_menu; EmpathySmileyManager *smiley_manager; GtkWidget *smiley_menu; GtkWidget *image; @@ -1026,14 +1050,14 @@ chat_input_populate_popup_cb (GtkTextView *view, gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); - item = gtk_image_menu_item_new_with_mnemonic (_("_Check Word Spelling...")); + item = gtk_image_menu_item_new_with_mnemonic (_("_Spelling Suggestions...")); image = gtk_image_new_from_icon_name (GTK_STOCK_SPELL_CHECK, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); - g_signal_connect (item, - "activate", - G_CALLBACK (chat_text_check_word_spelling_cb), - chat_spell); + + spell_menu = chat_spelling_build_menu (chat_spell); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), spell_menu); + gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); } diff --git a/libempathy-gtk/empathy-spell-dialog.c b/libempathy-gtk/empathy-spell-dialog.c deleted file mode 100644 index 9ce80eebb..000000000 --- a/libempathy-gtk/empathy-spell-dialog.c +++ /dev/null @@ -1,264 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2004-2007 Imendio AB - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#include - -#include -#include - -#include - -#include "empathy-chat.h" -#include "empathy-spell.h" -#include "empathy-spell-dialog.h" -#include "empathy-ui-utils.h" - -typedef struct { - GtkWidget *window; - GtkWidget *button_replace; - GtkWidget *label_word; - GtkWidget *treeview_words; - - EmpathyChat *chat; - - gchar *word; - GtkTextIter start; - GtkTextIter end; -} EmpathySpellDialog; - -enum { - COL_SPELL_WORD, - COL_SPELL_COUNT -}; - -static void spell_dialog_model_populate_columns (EmpathySpellDialog *dialog); -static void spell_dialog_model_populate_suggestions (EmpathySpellDialog *dialog); -static void spell_dialog_model_row_activated_cb (GtkTreeView *tree_view, - GtkTreePath *path, - GtkTreeViewColumn *column, - EmpathySpellDialog *dialog); -static void spell_dialog_model_selection_changed_cb (GtkTreeSelection *treeselection, - EmpathySpellDialog *dialog); -static void spell_dialog_model_setup (EmpathySpellDialog *dialog); -static void spell_dialog_response_cb (GtkWidget *widget, - gint response, - EmpathySpellDialog *dialog); -static void spell_dialog_destroy_cb (GtkWidget *widget, - EmpathySpellDialog *dialog); - -static void -spell_dialog_model_populate_columns (EmpathySpellDialog *dialog) -{ - GtkTreeModel *model; - GtkTreeViewColumn *column; - GtkCellRenderer *renderer; - guint col_offset; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview_words)); - - renderer = gtk_cell_renderer_text_new (); - col_offset = gtk_tree_view_insert_column_with_attributes ( - GTK_TREE_VIEW (dialog->treeview_words), - -1, _("Word"), - renderer, - "text", COL_SPELL_WORD, - NULL); - - g_object_set_data (G_OBJECT (renderer), - "column", GINT_TO_POINTER (COL_SPELL_WORD)); - - column = gtk_tree_view_get_column (GTK_TREE_VIEW (dialog->treeview_words), col_offset - 1); - gtk_tree_view_column_set_sort_column_id (column, COL_SPELL_WORD); - gtk_tree_view_column_set_resizable (column, FALSE); - gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE); -} - -static void -spell_dialog_model_populate_suggestions (EmpathySpellDialog *dialog) -{ - GtkTreeModel *model; - GtkListStore *store; - GList *suggestions, *l; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview_words)); - store = GTK_LIST_STORE (model); - - suggestions = empathy_spell_get_suggestions (dialog->word); - for (l = suggestions; l; l=l->next) { - GtkTreeIter iter; - gchar *word; - - word = l->data; - - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, - COL_SPELL_WORD, word, - -1); - } - - empathy_spell_free_suggestions (suggestions); -} - -static void -spell_dialog_model_row_activated_cb (GtkTreeView *tree_view, - GtkTreePath *path, - GtkTreeViewColumn *column, - EmpathySpellDialog *dialog) -{ - spell_dialog_response_cb (dialog->window, GTK_RESPONSE_OK, dialog); -} - -static void -spell_dialog_model_selection_changed_cb (GtkTreeSelection *treeselection, - EmpathySpellDialog *dialog) -{ - gint count; - - count = gtk_tree_selection_count_selected_rows (treeselection); - gtk_widget_set_sensitive (dialog->button_replace, (count == 1)); -} - -static void -spell_dialog_model_setup (EmpathySpellDialog *dialog) -{ - GtkTreeView *view; - GtkListStore *store; - GtkTreeSelection *selection; - - view = GTK_TREE_VIEW (dialog->treeview_words); - - g_signal_connect (view, "row-activated", - G_CALLBACK (spell_dialog_model_row_activated_cb), - dialog); - - store = gtk_list_store_new (COL_SPELL_COUNT, - G_TYPE_STRING); /* word */ - - gtk_tree_view_set_model (view, GTK_TREE_MODEL (store)); - - selection = gtk_tree_view_get_selection (view); - gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); - - g_signal_connect (selection, "changed", - G_CALLBACK (spell_dialog_model_selection_changed_cb), - dialog); - - spell_dialog_model_populate_columns (dialog); - spell_dialog_model_populate_suggestions (dialog); - - g_object_unref (store); -} - -static void -spell_dialog_destroy_cb (GtkWidget *widget, - EmpathySpellDialog *dialog) -{ - g_object_unref (dialog->chat); - g_free (dialog->word); - - g_free (dialog); -} - -static void -spell_dialog_response_cb (GtkWidget *widget, - gint response, - EmpathySpellDialog *dialog) -{ - if (response == GTK_RESPONSE_OK) { - GtkTreeView *view; - GtkTreeModel *model; - GtkTreeSelection *selection; - GtkTreeIter iter; - - gchar *new_word; - - view = GTK_TREE_VIEW (dialog->treeview_words); - selection = gtk_tree_view_get_selection (view); - - if (!gtk_tree_selection_get_selected (selection, &model, &iter)) { - return; - } - - gtk_tree_model_get (model, &iter, COL_SPELL_WORD, &new_word, -1); - - empathy_chat_correct_word (dialog->chat, - &dialog->start, - &dialog->end, - new_word); - - g_free (new_word); - } - - gtk_widget_destroy (dialog->window); -} - -void -empathy_spell_dialog_show (EmpathyChat *chat, - GtkTextIter *start, - GtkTextIter *end, - const gchar *word) -{ - EmpathySpellDialog *dialog; - GtkBuilder *gui; - gchar *str; - gchar *filename; - - g_return_if_fail (chat != NULL); - g_return_if_fail (word != NULL); - - dialog = g_new0 (EmpathySpellDialog, 1); - - dialog->chat = g_object_ref (chat); - - dialog->word = g_strdup (word); - - dialog->start = *start; - dialog->end = *end; - - filename = empathy_file_lookup ("empathy-spell-dialog.ui", - "libempathy-gtk"); - gui = empathy_builder_get_file (filename, - "spell_dialog", &dialog->window, - "button_replace", &dialog->button_replace, - "label_word", &dialog->label_word, - "treeview_words", &dialog->treeview_words, - NULL); - g_free (filename); - - empathy_builder_connect (gui, dialog, - "spell_dialog", "response", spell_dialog_response_cb, - "spell_dialog", "destroy", spell_dialog_destroy_cb, - NULL); - - g_object_unref (gui); - - str = g_markup_printf_escaped ("%s:\n%s", - _("Suggestions for the word"), - word); - - gtk_label_set_markup (GTK_LABEL (dialog->label_word), str); - g_free (str); - - spell_dialog_model_setup (dialog); - - gtk_widget_show (dialog->window); -} diff --git a/libempathy-gtk/empathy-spell-dialog.h b/libempathy-gtk/empathy-spell-dialog.h deleted file mode 100644 index ce0218812..000000000 --- a/libempathy-gtk/empathy-spell-dialog.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2004-2007 Imendio AB - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: Martyn Russell - * Richard Hult - */ - -#ifndef __EMPATHY_SPELL_DIALOG_H__ -#define __EMPATHY_SPELL_DIALOG_H__ - -#include -#include "empathy-chat.h" - -G_BEGIN_DECLS - -void empathy_spell_dialog_show (EmpathyChat *chat, - GtkTextIter *start, - GtkTextIter *end, - const gchar *word); - -G_END_DECLS - -#endif /* __EMPATHY_SPELL_DIALOG_H__ */ -- cgit v1.2.3 From 6f3fd3de6db0fae7071f8665a62fe0ba092590e9 Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Wed, 22 Apr 2009 17:28:03 +0800 Subject: Fix up Add Preset combo focusing --- libempathy-gtk/empathy-status-preset-dialog.c | 101 +++++++++++++++++++++----- 1 file changed, 84 insertions(+), 17 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-status-preset-dialog.c b/libempathy-gtk/empathy-status-preset-dialog.c index a428667e9..22cba1a53 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.c +++ b/libempathy-gtk/empathy-status-preset-dialog.c @@ -54,6 +54,8 @@ static McPresence states[] = { typedef struct _EmpathyStatusPresetDialogPriv EmpathyStatusPresetDialogPriv; struct _EmpathyStatusPresetDialogPriv { + int block_add_combo_changed; + GtkWidget *presets_treeview; GtkWidget *add_combobox; GtkWidget *add_button; @@ -159,7 +161,7 @@ status_preset_dialog_setup_add_combobox (EmpathyStatusPresetDialog *self) ADD_COMBO_STATE, states[i], ADD_COMBO_ICON_NAME, empathy_icon_name_for_presence (states[i]), ADD_COMBO_STATUS, empathy_presence_get_default_message (states[i]), - ADD_COMBO_DEFAULT_TEXT, _("Enter Custom Message"), + ADD_COMBO_DEFAULT_TEXT, "", -1); } @@ -255,6 +257,36 @@ status_preset_dialog_preset_remove (GtkButton *button, status_preset_dialog_setup_presets_update (self); } +static void +status_preset_dialog_set_add_combo_changed (EmpathyStatusPresetDialog *self, + gboolean state, + gboolean reset_text) +{ + EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self); + GtkWidget *entry; + + entry = gtk_bin_get_child (GTK_BIN (priv->add_combobox)); + + priv->add_combo_changed = state; + gtk_widget_set_sensitive (priv->add_button, state); + + if (state) { + gtk_widget_modify_text (entry, GTK_STATE_NORMAL, NULL); + } else { + GdkColor colour; + + gdk_color_parse ("Gray", &colour); /* FIXME - theme */ + gtk_widget_modify_text (entry, GTK_STATE_NORMAL, &colour); + + if (reset_text) { + priv->block_add_combo_changed++; + gtk_entry_set_text (GTK_ENTRY (entry), + _("Enter Custom Message")); + priv->block_add_combo_changed--; + } + } +} + static void status_preset_dialog_add_combo_changed (GtkComboBox *combo, EmpathyStatusPresetDialog *self) @@ -264,12 +296,13 @@ status_preset_dialog_add_combo_changed (GtkComboBox *combo, GtkTreeModel *model; GtkTreeIter iter; + if (priv->block_add_combo_changed) return; + model = gtk_combo_box_get_model (combo); entry = gtk_bin_get_child (GTK_BIN (combo)); if (gtk_combo_box_get_active_iter (combo, &iter)) { char *icon_name; - GdkColor colour; gtk_tree_model_get (model, &iter, PRESETS_STORE_STATE, &priv->selected_state, @@ -282,18 +315,13 @@ status_preset_dialog_add_combo_changed (GtkComboBox *combo, g_free (icon_name); - gtk_widget_grab_focus (entry); - gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1); - - priv->add_combo_changed = FALSE; - gtk_widget_set_sensitive (priv->add_button, FALSE); - - gdk_color_parse ("Gray", &colour); /* FIXME - theme */ - gtk_widget_modify_text (entry, GTK_STATE_NORMAL, &colour); + status_preset_dialog_set_add_combo_changed (self, FALSE, TRUE); } else { - priv->add_combo_changed = TRUE; - gtk_widget_set_sensitive (priv->add_button, TRUE); - gtk_widget_modify_text (entry, GTK_STATE_NORMAL, NULL); + const char *status; + + status = gtk_entry_get_text (GTK_ENTRY (entry)); + status_preset_dialog_set_add_combo_changed (self, + strlen (status) > 0, FALSE); } } @@ -317,6 +345,40 @@ status_preset_dialog_add_preset (GtkWidget *widget, status_preset_add_combo_reset (self); } +static gboolean +status_preset_dialog_add_combo_press_event (GtkWidget *widget, + GdkEventButton *event, + EmpathyStatusPresetDialog *self) +{ + if (!GTK_WIDGET_HAS_FOCUS (widget)) { + /* if the widget isn't focused, focus it and select the text */ + gtk_widget_grab_focus (widget); + gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1); + + return TRUE; + } + + return FALSE; +} + +static gboolean +status_preset_dialog_add_combo_focus_out (GtkWidget *widget, + GdkEventFocus *event, + EmpathyStatusPresetDialog *self) +{ + EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self); + const char *status; + + gtk_editable_set_position (GTK_EDITABLE (widget), 0); + + status = gtk_entry_get_text (GTK_ENTRY (widget)); + status_preset_dialog_set_add_combo_changed (self, + priv->add_combo_changed && strlen (status) > 0, + TRUE); + + return FALSE; +} + static void empathy_status_preset_dialog_init (EmpathyStatusPresetDialog *self) { @@ -325,7 +387,7 @@ empathy_status_preset_dialog_init (EmpathyStatusPresetDialog *self) EMPATHY_TYPE_STATUS_PRESET_DIALOG, EmpathyStatusPresetDialogPriv); GtkBuilder *gui; - GtkWidget *toplevel_vbox, *remove_button; + GtkWidget *toplevel_vbox, *remove_button, *entry; char *filename; gtk_window_set_title (GTK_WINDOW (self), @@ -351,9 +413,14 @@ empathy_status_preset_dialog_init (EmpathyStatusPresetDialog *self) G_CALLBACK (status_preset_dialog_preset_selection_changed), remove_button); - g_signal_connect (gtk_bin_get_child (GTK_BIN (priv->add_combobox)), - "activate", - G_CALLBACK (status_preset_dialog_add_preset), + entry = gtk_bin_get_child (GTK_BIN (priv->add_combobox)); + g_signal_connect (entry, "activate", + G_CALLBACK (status_preset_dialog_add_preset), self); + g_signal_connect (entry, "button-press-event", + G_CALLBACK (status_preset_dialog_add_combo_press_event), + self); + g_signal_connect (entry, "focus-out-event", + G_CALLBACK (status_preset_dialog_add_combo_focus_out), self); empathy_builder_connect (gui, self, -- cgit v1.2.3 From 93cc6d738d5fc2a91b257c568dd08687368fe637 Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Wed, 22 Apr 2009 17:34:23 +0800 Subject: Don't reset the state to Available when you click [Add] --- libempathy-gtk/empathy-status-preset-dialog.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-status-preset-dialog.c b/libempathy-gtk/empathy-status-preset-dialog.c index 22cba1a53..085332f35 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.c +++ b/libempathy-gtk/empathy-status-preset-dialog.c @@ -60,7 +60,7 @@ struct _EmpathyStatusPresetDialogPriv GtkWidget *add_combobox; GtkWidget *add_button; - McPresence selected_state; + GtkTreeIter selected_iter; gboolean add_combo_changed; }; @@ -131,7 +131,8 @@ status_preset_add_combo_reset (EmpathyStatusPresetDialog *self) { EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self); - gtk_combo_box_set_active (GTK_COMBO_BOX (priv->add_combobox), 0); + gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->add_combobox), + &priv->selected_iter); } static void @@ -181,7 +182,7 @@ status_preset_dialog_setup_add_combobox (EmpathyStatusPresetDialog *self) "foreground", "Gray", /* FIXME - theme */ NULL); - status_preset_add_combo_reset (self); + gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0); } static void @@ -304,8 +305,8 @@ status_preset_dialog_add_combo_changed (GtkComboBox *combo, if (gtk_combo_box_get_active_iter (combo, &iter)) { char *icon_name; + priv->selected_iter = iter; gtk_tree_model_get (model, &iter, - PRESETS_STORE_STATE, &priv->selected_state, PRESETS_STORE_ICON_NAME, &icon_name, -1); @@ -330,16 +331,23 @@ status_preset_dialog_add_preset (GtkWidget *widget, EmpathyStatusPresetDialog *self) { EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self); + GtkTreeModel *model; GtkWidget *entry; + McPresence state; const char *status; g_return_if_fail (priv->add_combo_changed); + model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->add_combobox)); entry = gtk_bin_get_child (GTK_BIN (priv->add_combobox)); + status = gtk_entry_get_text (GTK_ENTRY (entry)); + gtk_tree_model_get (model, &priv->selected_iter, + PRESETS_STORE_STATE, &state, + -1); - DEBUG ("ADD PRESET (%i, %s)\n", priv->selected_state, status); - empathy_status_presets_set_last (priv->selected_state, status); + DEBUG ("ADD PRESET (%i, %s)\n", state, status); + empathy_status_presets_set_last (state, status); status_preset_dialog_setup_presets_update (self); status_preset_add_combo_reset (self); -- cgit v1.2.3 From cad495664dc69bee746b71f7b5e4bb941327ac56 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Sun, 15 Feb 2009 22:27:03 +0100 Subject: Port EmpathyChat to new API. --- libempathy-gtk/empathy-chat.c | 50 ++++++++++++++++--------------------------- libempathy-gtk/empathy-chat.h | 1 - 2 files changed, 18 insertions(+), 33 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index 7d9390274..6b2fb1ebd 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -190,17 +190,15 @@ chat_connect_channel_reconnected (EmpathyDispatchOperation *dispatch, } static void -chat_connection_changed_cb (EmpathyAccountManager *manager, - McAccount *account, - TpConnectionStatusReason reason, - TpConnectionStatus current, - TpConnectionStatus previous, - EmpathyChat *chat) +chat_new_connection_cb (EmpathyAccountManager *manager, + TpConnection *connection, + EmpathyChat *chat) { EmpathyChatPriv *priv = GET_PRIV (chat); + McAccount *account; - if (current == TP_CONNECTION_STATUS_CONNECTED && !priv->tp_chat && - empathy_account_equal (account, priv->account) && + account = empathy_account_manager_get_account (manager, connection); + if (!priv->tp_chat && empathy_account_equal (account, priv->account) && priv->handle_type != TP_HANDLE_TYPE_NONE && !EMP_STR_EMPTY (priv->id)) { @@ -208,12 +206,14 @@ chat_connection_changed_cb (EmpathyAccountManager *manager, switch (priv->handle_type) { case TP_HANDLE_TYPE_CONTACT: - empathy_dispatcher_chat_with_contact_id (account, priv->id, + empathy_dispatcher_chat_with_contact_id ( + connection, priv->id, chat_connect_channel_reconnected, chat); break; case TP_HANDLE_TYPE_ROOM: - empathy_dispatcher_join_muc (account, priv->id, + empathy_dispatcher_join_muc (connection, + priv->id, chat_connect_channel_reconnected, chat); break; @@ -1139,10 +1139,6 @@ chat_members_changed_cb (EmpathyTpChat *tp_chat, if (priv->block_events_timeout_id == 0) { gchar *str; - empathy_contact_run_until_ready (contact, - EMPATHY_CONTACT_READY_NAME, - NULL); - if (is_member) { str = g_strdup_printf (_("%s has joined the room"), empathy_contact_get_name (contact)); @@ -1434,7 +1430,7 @@ chat_finalize (GObject *object) chat_composing_remove_timeout (chat); g_signal_handlers_disconnect_by_func (priv->account_manager, - chat_connection_changed_cb, object); + chat_new_connection_cb, object); g_object_unref (priv->account_manager); g_object_unref (priv->log_manager); @@ -1578,8 +1574,8 @@ empathy_chat_init (EmpathyChat *chat) priv->account_manager = empathy_account_manager_dup_singleton (); g_signal_connect (priv->account_manager, - "account-connection-changed", - G_CALLBACK (chat_connection_changed_cb), + "new-connection", + G_CALLBACK (chat_new_connection_cb), chat); /* Block events for some time to avoid having "has come online" or @@ -1613,6 +1609,7 @@ empathy_chat_set_tp_chat (EmpathyChat *chat, EmpathyTpChat *tp_chat) { EmpathyChatPriv *priv = GET_PRIV (chat); + TpConnection *connection; g_return_if_fail (EMPATHY_IS_CHAT (chat)); g_return_if_fail (EMPATHY_IS_TP_CHAT (tp_chat)); @@ -1627,7 +1624,10 @@ empathy_chat_set_tp_chat (EmpathyChat *chat, } priv->tp_chat = g_object_ref (tp_chat); - priv->account = g_object_ref (empathy_tp_chat_get_account (tp_chat)); + connection = empathy_tp_chat_get_connection (priv->tp_chat); + priv->account = empathy_account_manager_get_account (priv->account_manager, + connection); + g_object_ref (priv->account); g_signal_connect (tp_chat, "message-received", G_CALLBACK (chat_message_received_cb), @@ -1730,20 +1730,6 @@ empathy_chat_get_remote_contact (EmpathyChat *chat) return priv->remote_contact; } -guint -empathy_chat_get_members_count (EmpathyChat *chat) -{ - EmpathyChatPriv *priv = GET_PRIV (chat); - - g_return_val_if_fail (EMPATHY_IS_CHAT (chat), 0); - - if (priv->tp_chat) { - return empathy_tp_chat_get_members_count (priv->tp_chat); - } - - return 0; -} - GtkWidget * empathy_chat_get_contact_menu (EmpathyChat *chat) { diff --git a/libempathy-gtk/empathy-chat.h b/libempathy-gtk/empathy-chat.h index 6b7fcf26e..f61ce4154 100644 --- a/libempathy-gtk/empathy-chat.h +++ b/libempathy-gtk/empathy-chat.h @@ -71,7 +71,6 @@ const gchar * empathy_chat_get_id (EmpathyChat *chat); const gchar * empathy_chat_get_name (EmpathyChat *chat); const gchar * empathy_chat_get_subject (EmpathyChat *chat); EmpathyContact * empathy_chat_get_remote_contact (EmpathyChat *chat); -guint empathy_chat_get_members_count (EmpathyChat *chat); GtkWidget * empathy_chat_get_contact_menu (EmpathyChat *chat); void empathy_chat_clear (EmpathyChat *chat); void empathy_chat_scroll_down (EmpathyChat *chat); -- cgit v1.2.3 From 155c6bfe659f017a9fda6c99caf71f3c2a63f92b Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Sun, 15 Feb 2009 22:28:11 +0100 Subject: Port EmpathyContactDialogs to new API. --- libempathy-gtk/empathy-contact-dialogs.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-contact-dialogs.c b/libempathy-gtk/empathy-contact-dialogs.c index 72b5b28b3..309cd649c 100644 --- a/libempathy-gtk/empathy-contact-dialogs.c +++ b/libempathy-gtk/empathy-contact-dialogs.c @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -242,12 +243,23 @@ static gboolean can_add_contact_to_account (McAccount *account, gpointer user_data) { - EmpathyContactManager *mgr; + EmpathyAccountManager *account_manager; + EmpathyContactManager *contact_manager; + TpConnection *connection; gboolean result; - mgr = empathy_contact_manager_dup_singleton (); - result = empathy_contact_manager_can_add (mgr, account); - g_object_unref (mgr); + account_manager = empathy_account_manager_dup_singleton (); + connection = empathy_account_manager_get_connection (account_manager, + account); + if (!connection) { + g_object_unref (account_manager); + return FALSE; + } + + contact_manager = empathy_contact_manager_dup_singleton (); + result = empathy_contact_manager_can_add (contact_manager, connection); + g_object_unref (contact_manager); + g_object_unref (account_manager); return result; } -- cgit v1.2.3 From 08153d80afd0c88ad5b8d4134266f3cef8078b7b Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Sun, 15 Feb 2009 23:36:14 +0100 Subject: Base EmpathyAvatarChooser on connection instead of account. --- libempathy-gtk/empathy-avatar-chooser.c | 112 +++++++++----------------------- 1 file changed, 29 insertions(+), 83 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-avatar-chooser.c b/libempathy-gtk/empathy-avatar-chooser.c index 02aa689eb..a70befbc6 100644 --- a/libempathy-gtk/empathy-avatar-chooser.c +++ b/libempathy-gtk/empathy-avatar-chooser.c @@ -30,7 +30,7 @@ #include #include -#include +#include #include "empathy-avatar-chooser.h" #include "empathy-conf.h" @@ -45,9 +45,8 @@ #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAvatarChooser) typedef struct { - EmpathyContactFactory *contact_factory; - McAccount *account; - EmpathyTpContactFactory *tp_contact_factory; + EmpathyTpContactFactory *factory; + TpConnection *connection; GtkFileChooser *chooser_dialog; gulong ready_handler_id; @@ -56,8 +55,8 @@ typedef struct { } EmpathyAvatarChooserPriv; static void avatar_chooser_finalize (GObject *object); -static void avatar_chooser_set_account (EmpathyAvatarChooser *self, - McAccount *account); +static void avatar_chooser_set_connection (EmpathyAvatarChooser *self, + TpConnection *connection); static void avatar_chooser_set_image (EmpathyAvatarChooser *chooser, EmpathyAvatar *avatar, GdkPixbuf *pixbuf, @@ -96,7 +95,7 @@ enum { enum { PROP_0, - PROP_ACCOUNT + PROP_CONNECTION }; static guint signals [LAST_SIGNAL]; @@ -125,8 +124,8 @@ avatar_chooser_get_property (GObject *object, EmpathyAvatarChooserPriv *priv = GET_PRIV (object); switch (param_id) { - case PROP_ACCOUNT: - g_value_set_object (value, priv->account); + case PROP_CONNECTION: + g_value_set_object (value, priv->connection); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); @@ -143,8 +142,8 @@ avatar_chooser_set_property (GObject *object, EmpathyAvatarChooser *self = EMPATHY_AVATAR_CHOOSER (object); switch (param_id) { - case PROP_ACCOUNT: - avatar_chooser_set_account (self, g_value_get_object (value)); + case PROP_CONNECTION: + avatar_chooser_set_connection (self, g_value_get_object (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); @@ -171,15 +170,15 @@ empathy_avatar_chooser_class_init (EmpathyAvatarChooserClass *klass) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - param_spec = g_param_spec_object ("account", - "McAccount", - "McAccount whose avatar should be " + param_spec = g_param_spec_object ("connection", + "TpConnection", + "TpConnection whose avatar should be " "shown and modified by this widget", - MC_TYPE_ACCOUNT, + TP_TYPE_CONNECTION, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); g_object_class_install_property (object_class, - PROP_ACCOUNT, + PROP_CONNECTION, param_spec); g_type_class_add_private (object_class, sizeof (EmpathyAvatarChooserPriv)); @@ -214,8 +213,6 @@ empathy_avatar_chooser_init (EmpathyAvatarChooser *chooser) G_CALLBACK (avatar_chooser_clicked_cb), chooser); - priv->contact_factory = empathy_contact_factory_dup_singleton (); - empathy_avatar_chooser_set (chooser, NULL); } @@ -226,11 +223,9 @@ avatar_chooser_finalize (GObject *object) priv = GET_PRIV (object); - avatar_chooser_set_account (EMPATHY_AVATAR_CHOOSER (object), NULL); - g_assert (priv->account == NULL); - g_assert (priv->tp_contact_factory == NULL); - - g_object_unref (priv->contact_factory); + avatar_chooser_set_connection (EMPATHY_AVATAR_CHOOSER (object), NULL); + g_assert (priv->connection == NULL); + g_assert (priv->factory == NULL); if (priv->avatar != NULL) { empathy_avatar_unref (priv->avatar); @@ -240,51 +235,22 @@ avatar_chooser_finalize (GObject *object) } static void -avatar_chooser_tp_cf_ready_cb (EmpathyTpContactFactory *tp_cf, - GParamSpec *unused, - EmpathyAvatarChooser *self) -{ - EmpathyAvatarChooserPriv *priv = GET_PRIV (self); - gboolean ready; - - /* sanity check that we're listening on the right ETpCF */ - g_assert (priv->tp_contact_factory == tp_cf); - - ready = empathy_tp_contact_factory_is_ready (tp_cf); - gtk_widget_set_sensitive (GTK_WIDGET (self), ready); -} - -static void -avatar_chooser_set_account (EmpathyAvatarChooser *self, - McAccount *account) +avatar_chooser_set_connection (EmpathyAvatarChooser *self, + TpConnection *connection) { EmpathyAvatarChooserPriv *priv = GET_PRIV (self); - if (priv->account != NULL) { - g_object_unref (priv->account); - priv->account = NULL; + if (priv->connection != NULL) { + g_object_unref (priv->connection); + priv->connection = NULL; - g_assert (priv->tp_contact_factory != NULL); - - g_signal_handler_disconnect (priv->tp_contact_factory, - priv->ready_handler_id); - priv->ready_handler_id = 0; - - g_object_unref (priv->tp_contact_factory); - priv->tp_contact_factory = NULL; + g_object_unref (priv->factory); + priv->factory = NULL; } - if (account != NULL) { - priv->account = g_object_ref (account); - priv->tp_contact_factory = g_object_ref ( - empathy_contact_factory_get_tp_factory ( - priv->contact_factory, priv->account)); - - priv->ready_handler_id = g_signal_connect ( - priv->tp_contact_factory, "notify::ready", - G_CALLBACK (avatar_chooser_tp_cf_ready_cb), self); - avatar_chooser_tp_cf_ready_cb (priv->tp_contact_factory, NULL, - self); + if (connection != NULL) { + priv->connection = g_object_ref (connection); + priv->factory = empathy_tp_contact_factory_dup_singleton (connection); } } @@ -412,7 +378,6 @@ avatar_chooser_maybe_convert_and_scale (EmpathyAvatarChooser *chooser, EmpathyAvatar *avatar) { EmpathyAvatarChooserPriv *priv = GET_PRIV (chooser); - EmpathyTpContactFactory *tp_cf = priv->tp_contact_factory; guint max_width = 0, max_height = 0, max_size = 0; gchar **mime_types = NULL; gboolean needs_conversion = FALSE; @@ -424,15 +389,7 @@ avatar_chooser_maybe_convert_and_scale (EmpathyAvatarChooser *chooser, gchar *converted_image_data = NULL; gsize converted_image_size = 0; - /* This should only be called if the user is setting a new avatar, - * which should only be allowed once the avatar requirements have been - * discovered. - */ - g_return_val_if_fail (tp_cf != NULL, NULL); - g_return_val_if_fail (empathy_tp_contact_factory_is_ready (tp_cf), - NULL); - - g_object_get (tp_cf, + g_object_get (priv->factory, "avatar-mime-types", &mime_types, /* Needs g_strfreev-ing */ "avatar-max-width", &max_width, "avatar-max-height", &max_height, @@ -901,16 +858,6 @@ avatar_chooser_response_cb (GtkWidget *widget, priv->chooser_dialog = NULL; - if (response == GTK_RESPONSE_CANCEL) { - goto out; - } - - /* Check if we went non-ready since displaying the dialog. */ - if (!empathy_tp_contact_factory_is_ready (priv->tp_contact_factory)) { - DEBUG ("Can't set avatar when contact factory isn't ready."); - goto out; - } - if (response == GTK_RESPONSE_OK) { gchar *filename; gchar *path; @@ -932,7 +879,6 @@ avatar_chooser_response_cb (GtkWidget *widget, avatar_chooser_clear_image (chooser); } -out: gtk_widget_destroy (widget); } -- cgit v1.2.3 From eef992ef2c1010aa31585629aa6990eda76b3f3d Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Sun, 15 Feb 2009 23:36:51 +0100 Subject: Add empathy_account_chooser_get_connection() --- libempathy-gtk/empathy-account-chooser.c | 18 ++++++++++++++++++ libempathy-gtk/empathy-account-chooser.h | 1 + 2 files changed, 19 insertions(+) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-account-chooser.c b/libempathy-gtk/empathy-account-chooser.c index 8c402c07a..ea3d6e513 100644 --- a/libempathy-gtk/empathy-account-chooser.c +++ b/libempathy-gtk/empathy-account-chooser.c @@ -241,6 +241,24 @@ empathy_account_chooser_get_account (EmpathyAccountChooser *chooser) return account; } +TpConnection * +empathy_account_chooser_get_connection (EmpathyAccountChooser *chooser) +{ + EmpathyAccountChooserPriv *priv; + McAccount *account; + TpConnection *connection; + + g_return_val_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (chooser), NULL); + + priv = GET_PRIV (chooser); + + account = empathy_account_chooser_get_account (chooser); + connection = empathy_account_manager_get_connection (priv->manager, account); + g_object_unref (account); + + return connection; +} + gboolean empathy_account_chooser_set_account (EmpathyAccountChooser *chooser, McAccount *account) diff --git a/libempathy-gtk/empathy-account-chooser.h b/libempathy-gtk/empathy-account-chooser.h index c15923bc3..4dfdc632e 100644 --- a/libempathy-gtk/empathy-account-chooser.h +++ b/libempathy-gtk/empathy-account-chooser.h @@ -57,6 +57,7 @@ struct _EmpathyAccountChooserClass { GType empathy_account_chooser_get_type (void) G_GNUC_CONST; GtkWidget * empathy_account_chooser_new (void); McAccount * empathy_account_chooser_get_account (EmpathyAccountChooser *chooser); +TpConnection * empathy_account_chooser_get_connection (EmpathyAccountChooser *chooser); gboolean empathy_account_chooser_set_account (EmpathyAccountChooser *chooser, McAccount *account); gboolean empathy_account_chooser_get_has_all_option (EmpathyAccountChooser *chooser); -- cgit v1.2.3 From 7b52ca928351def87e3857c24daf0cbc985bfc9f Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Sun, 15 Feb 2009 23:37:19 +0100 Subject: Port EmpathyContactWidget to new API. --- libempathy-gtk/empathy-contact-widget.c | 104 +++++++++++++++++++------------- 1 file changed, 62 insertions(+), 42 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c index ef259b0a4..0c836f93c 100644 --- a/libempathy-gtk/empathy-contact-widget.c +++ b/libempathy-gtk/empathy-contact-widget.c @@ -1,6 +1,6 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* - * Copyright (C) 2007-2008 Collabora Ltd. + * Copyright (C) 2007-2009 Collabora Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -30,7 +30,7 @@ #include #include -#include +#include #include #include #include @@ -49,7 +49,7 @@ typedef struct { - EmpathyContactFactory *factory; + EmpathyTpContactFactory *factory; EmpathyContactManager *manager; EmpathyContact *contact; EmpathyContactWidgetFlags flags; @@ -159,11 +159,12 @@ empathy_contact_widget_new (EmpathyContact *contact, { EmpathyContactWidget *information; GtkBuilder *gui; + TpConnection *connection; gchar *filename; + connection = empathy_contact_get_connection (contact); information = g_slice_new0 (EmpathyContactWidget); information->flags = flags; - information->factory = empathy_contact_factory_dup_singleton (); filename = empathy_file_lookup ("empathy-contact-widget.ui", "libempathy-gtk"); @@ -272,10 +273,6 @@ contact_widget_destroy_cb (GtkWidget *widget, { g_source_remove (information->widget_id_timeout); } - if (information->factory) - { - g_object_unref (information->factory); - } if (information->manager) { g_object_unref (information->manager); @@ -299,7 +296,9 @@ contact_widget_remove_contact (EmpathyContactWidget *information) contact_widget_groups_notify_cb, information); g_object_unref (information->contact); + g_object_unref (information->factory); information->contact = NULL; + information->factory = NULL; } } @@ -312,7 +311,13 @@ contact_widget_set_contact (EmpathyContactWidget *information, 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); + } /* Update information for widgets */ contact_widget_contact_update (information); @@ -491,10 +496,10 @@ static void update_avatar_chooser_account_cb (EmpathyAccountChooser *account_chooser, EmpathyAvatarChooser *avatar_chooser) { - McAccount *account; + TpConnection *connection; - account = empathy_account_chooser_get_account (account_chooser); - g_object_set (avatar_chooser, "account", account, NULL); + connection = empathy_account_chooser_get_connection (account_chooser); + g_object_set (avatar_chooser, "connection", connection, NULL); } static void @@ -683,27 +688,46 @@ contact_widget_contact_update (EmpathyContactWidget *information) } static void -contact_widget_change_contact_cb (EmpathyContact *contact, - const GError *error, - gpointer information, - GObject *weak_object) +contact_widget_got_contact_cb (EmpathyTpContactFactory *factory, + GList *contacts, + gpointer user_data, + GObject *weak_object) { - if (error) - DEBUG ("Error: %s", error->message); - else - contact_widget_set_contact (information, contact); - g_object_unref (contact); + EmpathyContactWidget *information = user_data; + + contact_widget_set_contact (information, contacts->data); +} + +static void +contact_widget_get_self_handle_cb (TpConnection *connection, + TpHandle self_handle, + const GError *error, + gpointer information, + GObject *weak_object) +{ + EmpathyTpContactFactory *factory; + + if (error != NULL) + { + DEBUG ("Error: %s", error->message); + return; + } + + factory = empathy_tp_contact_factory_dup_singleton (connection); + empathy_tp_contact_factory_get_from_handles (factory, 1, &self_handle, + contact_widget_got_contact_cb, information, NULL, + weak_object); + g_object_unref (factory); } static void contact_widget_change_contact (EmpathyContactWidget *information) { - EmpathyContact *contact; - McAccount *account; + TpConnection *connection; - account = empathy_account_chooser_get_account ( + connection = empathy_account_chooser_get_connection ( EMPATHY_ACCOUNT_CHOOSER (information->widget_account)); - if (!account) + if (!connection) return; if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID) @@ -711,26 +735,22 @@ contact_widget_change_contact (EmpathyContactWidget *information) const gchar *id; id = gtk_entry_get_text (GTK_ENTRY (information->widget_id)); - if (EMP_STR_EMPTY (id)) - return; + if (!EMP_STR_EMPTY (id)) + { + EmpathyTpContactFactory *factory; - contact = empathy_contact_factory_get_from_id (information->factory, - account, id); + factory = empathy_tp_contact_factory_dup_singleton (connection); + empathy_tp_contact_factory_get_from_ids (factory, 1, &id, + contact_widget_got_contact_cb, information, NULL, + G_OBJECT (information->vbox_contact_widget)); + g_object_unref (factory); + } } else { - contact = empathy_contact_factory_get_user (information->factory, - account); - } - - if (contact) - { - /* Give the contact ref to the callback */ - empathy_contact_call_when_ready (contact, - EMPATHY_CONTACT_READY_HANDLE | - EMPATHY_CONTACT_READY_ID, - contact_widget_change_contact_cb, - information, NULL, + /* FIXME: TpConnection should have a SelfHandle property */ + tp_cli_connection_call_get_self_handle (connection, -1, + contact_widget_get_self_handle_cb, information, NULL, G_OBJECT (information->vbox_contact_widget)); } } @@ -750,7 +770,7 @@ contact_widget_avatar_changed_cb (EmpathyAvatarChooser *chooser, empathy_avatar_chooser_get_image_data ( EMPATHY_AVATAR_CHOOSER (information->widget_avatar), &data, &size, &mime_type); - empathy_contact_factory_set_avatar (information->factory, account, + empathy_tp_contact_factory_set_avatar (information->factory, data, size, mime_type); } } @@ -781,7 +801,7 @@ contact_widget_entry_alias_focus_event_cb (GtkEditable *editable, const gchar *alias; alias = gtk_entry_get_text (GTK_ENTRY (editable)); - empathy_contact_factory_set_alias (information->factory, + empathy_tp_contact_factory_set_alias (information->factory, information->contact, alias); } -- cgit v1.2.3 From 782b0131b9c80d4ebf769d9b9b165801578aa888 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Sun, 15 Feb 2009 23:51:16 +0100 Subject: Port EmpathyNewMessageDialog to new API. --- libempathy-gtk/empathy-new-message-dialog.c | 100 +++++++++++++++------------- 1 file changed, 55 insertions(+), 45 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-new-message-dialog.c b/libempathy-gtk/empathy-new-message-dialog.c index f6eb46a5f..1192ecf73 100644 --- a/libempathy-gtk/empathy-new-message-dialog.c +++ b/libempathy-gtk/empathy-new-message-dialog.c @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include #include @@ -65,48 +65,54 @@ new_message_dialog_account_changed_cb (GtkWidget *widget, EmpathyNewMessageDialog *dialog) { EmpathyAccountChooser *chooser; - McAccount *account; + TpConnection *connection; EmpathyTpContactList *contact_list; - GList *members, *l; + GList *members; GtkListStore *store; GtkEntryCompletion *completion; GtkTreeIter iter; gchar *tmpstr; - chooser = EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser); - account = empathy_account_chooser_get_account (chooser); - contact_list = empathy_contact_manager_get_list (dialog->contact_manager, - account); - members = empathy_contact_list_get_members (EMPATHY_CONTACT_LIST (contact_list)); + /* Remove completions */ completion = gtk_entry_get_completion (GTK_ENTRY (dialog->entry_id)); store = GTK_LIST_STORE (gtk_entry_completion_get_model (completion)); gtk_list_store_clear (store); - for (l = members; l; l = l->next) { - EmpathyContact *contact = l->data; + /* Get members of the new account */ + chooser = EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser); + connection = empathy_account_chooser_get_connection (chooser); + if (!connection) { + return; + } + contact_list = empathy_contact_manager_get_list (dialog->contact_manager, + connection); + members = empathy_contact_list_get_members (EMPATHY_CONTACT_LIST (contact_list)); - if (!empathy_contact_is_online (contact)) { - continue; - } + /* Add members to the completion */ + while (members) { + EmpathyContact *contact = members->data; - DEBUG ("Adding contact ID %s, Name %s", - empathy_contact_get_id (contact), - empathy_contact_get_name (contact)); + if (empathy_contact_is_online (contact)) { + DEBUG ("Adding contact ID %s, Name %s", + empathy_contact_get_id (contact), + empathy_contact_get_name (contact)); - tmpstr = g_strdup_printf ("%s (%s)", - empathy_contact_get_name (contact), - empathy_contact_get_id (contact)); + tmpstr = g_strdup_printf ("%s (%s)", + empathy_contact_get_name (contact), + empathy_contact_get_id (contact)); - gtk_list_store_insert_with_values (store, &iter, -1, - COMPLETION_COL_TEXT, tmpstr, - COMPLETION_COL_ID, empathy_contact_get_id (contact), - COMPLETION_COL_NAME, empathy_contact_get_name (contact), - -1); + gtk_list_store_insert_with_values (store, &iter, -1, + COMPLETION_COL_TEXT, tmpstr, + COMPLETION_COL_ID, empathy_contact_get_id (contact), + COMPLETION_COL_NAME, empathy_contact_get_name (contact), + -1); - g_free (tmpstr); - } + g_free (tmpstr); + } - g_object_unref (account); + g_object_unref (contact); + members = g_list_delete_link (members, members); + } } static gboolean @@ -165,42 +171,46 @@ new_message_dialog_match_func (GtkEntryCompletion *completion, return FALSE; } +static void +new_message_dialog_call_got_contact_cb (EmpathyTpContactFactory *factory, + GList *contacts, + gpointer user_data, + GObject *weak_object) +{ + EmpathyCallFactory *call_factory; + + call_factory = empathy_call_factory_get(); + empathy_call_factory_new_call (call_factory, contacts->data); +} + static void new_message_dialog_response_cb (GtkWidget *widget, gint response, EmpathyNewMessageDialog *dialog) { - McAccount *account; + TpConnection *connection; const gchar *id; - account = empathy_account_chooser_get_account (EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser)); + connection = empathy_account_chooser_get_connection ( + EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser)); id = gtk_entry_get_text (GTK_ENTRY (dialog->entry_id)); - if (!account || EMP_STR_EMPTY (id)) { - if (account) { - g_object_unref (account); - } + if (!connection || EMP_STR_EMPTY (id)) { gtk_widget_destroy (widget); return; } if (response == 1) { - EmpathyContactFactory *factory; - EmpathyContact *contact; - EmpathyCallFactory *call_factory; - - factory = empathy_contact_factory_dup_singleton (); - contact = empathy_contact_factory_get_from_id (factory, account, id); + EmpathyTpContactFactory *factory; - call_factory = empathy_call_factory_get(); - empathy_call_factory_new_call (call_factory, contact); - - g_object_unref (contact); + factory = empathy_tp_contact_factory_dup_singleton (connection); + empathy_tp_contact_factory_get_from_ids (factory, 1, &id, + new_message_dialog_call_got_contact_cb, + NULL, NULL, NULL); g_object_unref (factory); } else if (response == 2) { - empathy_dispatcher_chat_with_contact_id (account, id, NULL, NULL); + empathy_dispatcher_chat_with_contact_id (connection, id, NULL, NULL); } - g_object_unref (account); gtk_widget_destroy (widget); } -- cgit v1.2.3 From 8dcee288a0733ece2681f437f9da4651f4b7f5d8 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Tue, 17 Feb 2009 14:23:52 +0100 Subject: - Split info/edit/personal dialogs into different functions. - Make sure empathy_contact_widget_new works with a NULL contact. --- libempathy-gtk/empathy-contact-dialogs.c | 166 +++++++++++++++++++++++-------- libempathy-gtk/empathy-contact-dialogs.h | 11 +- libempathy-gtk/empathy-contact-menu.c | 4 +- libempathy-gtk/empathy-contact-widget.c | 24 ++--- 4 files changed, 142 insertions(+), 63 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-contact-dialogs.c b/libempathy-gtk/empathy-contact-dialogs.c index 309cd649c..38e02409f 100644 --- a/libempathy-gtk/empathy-contact-dialogs.c +++ b/libempathy-gtk/empathy-contact-dialogs.c @@ -40,9 +40,10 @@ static GList *subscription_dialogs = NULL; static GList *information_dialogs = NULL; +static GList *edit_dialogs = NULL; +static GtkWidget *personal_dialog = NULL; static GtkWidget *new_contact_dialog = NULL; - static gint contact_dialogs_find (GtkDialog *dialog, EmpathyContact *contact) @@ -144,25 +145,22 @@ empathy_subscription_dialog_show (EmpathyContact *contact, */ static void -contact_information_response_cb (GtkDialog *dialog, - gint response, - GtkWidget *contact_widget) +contact_dialogs_response_cb (GtkDialog *dialog, + gint response, + GList **dialogs) { - information_dialogs = g_list_remove (information_dialogs, dialog); + *dialogs = g_list_remove (*dialogs, dialog); gtk_widget_destroy (GTK_WIDGET (dialog)); } void empathy_contact_information_dialog_show (EmpathyContact *contact, - GtkWindow *parent, - gboolean edit, - gboolean is_user) + GtkWindow *parent) { - GtkWidget *dialog; - GtkWidget *button; - GtkWidget *contact_widget; - GList *l; - EmpathyContactWidgetFlags flags = 0; + GtkWidget *dialog; + GtkWidget *button; + GtkWidget *contact_widget; + GList *l; g_return_if_fail (EMPATHY_IS_CONTACT (contact)); @@ -178,15 +176,7 @@ empathy_contact_information_dialog_show (EmpathyContact *contact, dialog = gtk_dialog_new (); gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); - if (is_user) { - gtk_window_set_title (GTK_WINDOW (dialog), _("Personal Information")); - } - else if (edit) { - gtk_window_set_title (GTK_WINDOW (dialog), _("Edit Contact Information")); - } - else { - gtk_window_set_title (GTK_WINDOW (dialog), _("Contact Information")); - } + gtk_window_set_title (GTK_WINDOW (dialog), _("Edit Contact Information")); /* Close button */ button = gtk_button_new_with_label (GTK_STOCK_CLOSE); @@ -199,34 +189,19 @@ empathy_contact_information_dialog_show (EmpathyContact *contact, gtk_widget_show (button); /* Contact info widget */ - if (edit) { - flags |= EMPATHY_CONTACT_WIDGET_EDIT_ALIAS; - } - if (is_user) { - flags |= EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT; - flags |= EMPATHY_CONTACT_WIDGET_EDIT_AVATAR; - } - if (!is_user && edit) { - flags |= EMPATHY_CONTACT_WIDGET_EDIT_GROUPS; - } - contact_widget = empathy_contact_widget_new (contact, flags); + contact_widget = empathy_contact_widget_new (contact, + EMPATHY_CONTACT_WIDGET_EDIT_NONE); gtk_container_set_border_width (GTK_CONTAINER (contact_widget), 8); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), contact_widget, TRUE, TRUE, 0); - if (flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT) { - empathy_contact_widget_set_account_filter (contact_widget, - empathy_account_chooser_filter_is_connected, - NULL); - } - gtk_widget_show (contact_widget); g_object_set_data (G_OBJECT (dialog), "contact_widget", contact_widget); information_dialogs = g_list_prepend (information_dialogs, dialog); g_signal_connect (dialog, "response", - G_CALLBACK (contact_information_response_cb), - contact_widget); + G_CALLBACK (contact_dialogs_response_cb), + &information_dialogs); if (parent) { gtk_window_set_transient_for (GTK_WINDOW (dialog), parent); @@ -235,6 +210,115 @@ empathy_contact_information_dialog_show (EmpathyContact *contact, gtk_widget_show (dialog); } +void +empathy_contact_edit_dialog_show (EmpathyContact *contact, + GtkWindow *parent) +{ + GtkWidget *dialog; + GtkWidget *button; + GtkWidget *contact_widget; + GList *l; + + g_return_if_fail (EMPATHY_IS_CONTACT (contact)); + + l = g_list_find_custom (edit_dialogs, + contact, + (GCompareFunc) contact_dialogs_find); + if (l) { + gtk_window_present (GTK_WINDOW (l->data)); + return; + } + + /* Create dialog */ + dialog = gtk_dialog_new (); + gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); + gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); + gtk_window_set_title (GTK_WINDOW (dialog), _("Edit Contact Information")); + + /* Close button */ + button = gtk_button_new_with_label (GTK_STOCK_CLOSE); + gtk_button_set_use_stock (GTK_BUTTON (button), TRUE); + gtk_dialog_add_action_widget (GTK_DIALOG (dialog), + button, + GTK_RESPONSE_CLOSE); + GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); + gtk_window_set_default (GTK_WINDOW (dialog), button); + gtk_widget_show (button); + + /* Contact info widget */ + contact_widget = empathy_contact_widget_new (contact, + EMPATHY_CONTACT_WIDGET_EDIT_ALIAS | + EMPATHY_CONTACT_WIDGET_EDIT_GROUPS); + gtk_container_set_border_width (GTK_CONTAINER (contact_widget), 8); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), + contact_widget, + TRUE, TRUE, 0); + g_object_set_data (G_OBJECT (dialog), "contact_widget", contact_widget); + edit_dialogs = g_list_prepend (edit_dialogs, dialog); + + g_signal_connect (dialog, "response", + G_CALLBACK (contact_dialogs_response_cb), + &edit_dialogs); + + if (parent) { + gtk_window_set_transient_for (GTK_WINDOW (dialog), parent); + } + + gtk_widget_show (dialog); +} + +void +empathy_contact_personal_dialog_show (GtkWindow *parent) +{ + GtkWidget *button; + GtkWidget *contact_widget; + + if (personal_dialog) { + gtk_window_present (GTK_WINDOW (personal_dialog)); + return; + } + + /* Create dialog */ + personal_dialog = gtk_dialog_new (); + gtk_dialog_set_has_separator (GTK_DIALOG (personal_dialog), FALSE); + gtk_window_set_resizable (GTK_WINDOW (personal_dialog), FALSE); + gtk_window_set_title (GTK_WINDOW (personal_dialog), _("Personal Information")); + + /* Close button */ + button = gtk_button_new_with_label (GTK_STOCK_CLOSE); + gtk_button_set_use_stock (GTK_BUTTON (button), TRUE); + gtk_dialog_add_action_widget (GTK_DIALOG (personal_dialog), + button, + GTK_RESPONSE_CLOSE); + GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); + gtk_window_set_default (GTK_WINDOW (personal_dialog), button); + gtk_widget_show (button); + + /* Contact info widget */ + contact_widget = empathy_contact_widget_new (NULL, + EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT | + EMPATHY_CONTACT_WIDGET_EDIT_ALIAS | + EMPATHY_CONTACT_WIDGET_EDIT_AVATAR); + gtk_container_set_border_width (GTK_CONTAINER (contact_widget), 8); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (personal_dialog)->vbox), + contact_widget, + TRUE, TRUE, 0); + empathy_contact_widget_set_account_filter (contact_widget, + empathy_account_chooser_filter_is_connected, + NULL); + + g_signal_connect (personal_dialog, "response", + G_CALLBACK (gtk_widget_destroy), NULL); + g_object_add_weak_pointer (G_OBJECT (personal_dialog), + (gpointer) &personal_dialog); + + if (parent) { + gtk_window_set_transient_for (GTK_WINDOW (personal_dialog), parent); + } + + gtk_widget_show (personal_dialog); +} + /* * New contact dialog */ diff --git a/libempathy-gtk/empathy-contact-dialogs.h b/libempathy-gtk/empathy-contact-dialogs.h index e375f959c..c714c6b96 100644 --- a/libempathy-gtk/empathy-contact-dialogs.h +++ b/libempathy-gtk/empathy-contact-dialogs.h @@ -29,12 +29,13 @@ G_BEGIN_DECLS void empathy_subscription_dialog_show (EmpathyContact *contact, - GtkWindow *parent); + GtkWindow *parent); void empathy_contact_information_dialog_show (EmpathyContact *contact, - GtkWindow *parent, - gboolean edit, - gboolean is_user); -void empathy_new_contact_dialog_show (GtkWindow *parent); + GtkWindow *parent); +void empathy_contact_edit_dialog_show (EmpathyContact *contact, + GtkWindow *parent); +void empathy_contact_personal_dialog_show (GtkWindow *parent); +void empathy_new_contact_dialog_show (GtkWindow *parent); G_END_DECLS diff --git a/libempathy-gtk/empathy-contact-menu.c b/libempathy-gtk/empathy-contact-menu.c index 9cd9a0b9f..a3cf1da26 100644 --- a/libempathy-gtk/empathy-contact-menu.c +++ b/libempathy-gtk/empathy-contact-menu.c @@ -236,7 +236,7 @@ empathy_contact_file_transfer_menu_item_new (EmpathyContact *contact) static void contact_info_menu_item_activate_cb (EmpathyContact *contact) { - empathy_contact_information_dialog_show (contact, NULL, FALSE, FALSE); + empathy_contact_information_dialog_show (contact, NULL); } GtkWidget * @@ -263,7 +263,7 @@ empathy_contact_info_menu_item_new (EmpathyContact *contact) static void contact_edit_menu_item_activate_cb (EmpathyContact *contact) { - empathy_contact_information_dialog_show (contact, NULL, TRUE, FALSE); + empathy_contact_edit_dialog_show (contact, NULL); } GtkWidget * diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c index 0c836f93c..165d48b44 100644 --- a/libempathy-gtk/empathy-contact-widget.c +++ b/libempathy-gtk/empathy-contact-widget.c @@ -106,8 +106,6 @@ static void contact_widget_contact_update (EmpathyContactWidget *information); static void contact_widget_change_contact (EmpathyContactWidget *information); static void contact_widget_avatar_changed_cb (EmpathyAvatarChooser *chooser, EmpathyContactWidget *information); -static void contact_widget_account_changed_cb (GtkComboBox *widget, - EmpathyContactWidget *information); static gboolean contact_widget_id_focus_out_cb (GtkWidget *widget, GdkEventFocus *event, EmpathyContactWidget *information); static gboolean contact_widget_entry_alias_focus_event_cb ( @@ -162,7 +160,8 @@ empathy_contact_widget_new (EmpathyContact *contact, TpConnection *connection; gchar *filename; - connection = empathy_contact_get_connection (contact); + g_return_val_if_fail (contact == NULL || EMPATHY_IS_CONTACT (contact), NULL); + information = g_slice_new0 (EmpathyContactWidget); information->flags = flags; @@ -207,7 +206,8 @@ empathy_contact_widget_new (EmpathyContact *contact, contact_widget_details_setup (information); contact_widget_client_setup (information); - contact_widget_set_contact (information, contact); + if (contact != NULL) + contact_widget_set_contact (information, contact); return empathy_builder_unref_and_keep_widget (gui, information->vbox_contact_widget); @@ -510,8 +510,9 @@ contact_widget_contact_setup (EmpathyContactWidget *information) { information->widget_account = empathy_account_chooser_new (); - g_signal_connect (information->widget_account, "changed", - G_CALLBACK (contact_widget_account_changed_cb), + contact_widget_change_contact (information); + g_signal_connect_swapped (information->widget_account, "changed", + G_CALLBACK (contact_widget_change_contact), information); } else @@ -641,12 +642,12 @@ contact_widget_contact_update (EmpathyContactWidget *information) if (account) { g_signal_handlers_block_by_func (information->widget_account, - contact_widget_account_changed_cb, + 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_account_changed_cb, information); + contact_widget_change_contact, information); } } else @@ -775,13 +776,6 @@ contact_widget_avatar_changed_cb (EmpathyAvatarChooser *chooser, } } -static void -contact_widget_account_changed_cb (GtkComboBox *widget, - EmpathyContactWidget *information) -{ - contact_widget_change_contact (information); -} - static gboolean contact_widget_id_focus_out_cb (GtkWidget *widget, GdkEventFocus *event, -- cgit v1.2.3 From 56337470e94a98a963e978d8b8f97f311cc817b7 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Tue, 17 Feb 2009 14:46:17 +0100 Subject: Do not use empathy_contact_equal anymore, pointer comparaison is guaranteed to be enough. --- libempathy-gtk/empathy-theme-boxes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-theme-boxes.c b/libempathy-gtk/empathy-theme-boxes.c index 0561ecac0..5b435f1d5 100644 --- a/libempathy-gtk/empathy-theme-boxes.c +++ b/libempathy-gtk/empathy-theme-boxes.c @@ -208,9 +208,9 @@ theme_boxes_maybe_append_header (EmpathyThemeBoxes *theme, DEBUG ("Maybe add fancy header"); /* Only insert a header if the previously inserted block is not the same - * as this one. This catches all the different cases: + * as this one. */ - if (last_contact && empathy_contact_equal (last_contact, contact)) { + if (last_contact == contact) { return; } -- cgit v1.2.3 From d928bb812f1772246b0c2f5bf4b0b9809bb4e9af Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Tue, 17 Feb 2009 16:44:02 +0100 Subject: Remove dead code --- libempathy-gtk/empathy-contact-widget.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c index 165d48b44..fa9fdefeb 100644 --- a/libempathy-gtk/empathy-contact-widget.c +++ b/libempathy-gtk/empathy-contact-widget.c @@ -762,12 +762,10 @@ contact_widget_avatar_changed_cb (EmpathyAvatarChooser *chooser, { if (information->contact && empathy_contact_is_user (information->contact)) { - McAccount *account; const gchar *data; gsize size; const gchar *mime_type; - account = empathy_contact_get_account (information->contact); empathy_avatar_chooser_get_image_data ( EMPATHY_AVATAR_CHOOSER (information->widget_avatar), &data, &size, &mime_type); -- cgit v1.2.3 From 321919b35b06d375f3c560d6b65b4f40ee68df46 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 18 Feb 2009 01:44:20 +0100 Subject: Remove useless condition --- libempathy-gtk/empathy-contact-widget.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c index fa9fdefeb..df876b603 100644 --- a/libempathy-gtk/empathy-contact-widget.c +++ b/libempathy-gtk/empathy-contact-widget.c @@ -760,18 +760,15 @@ static void contact_widget_avatar_changed_cb (EmpathyAvatarChooser *chooser, EmpathyContactWidget *information) { - if (information->contact && empathy_contact_is_user (information->contact)) - { - const gchar *data; - gsize size; - const gchar *mime_type; - - empathy_avatar_chooser_get_image_data ( - EMPATHY_AVATAR_CHOOSER (information->widget_avatar), - &data, &size, &mime_type); - empathy_tp_contact_factory_set_avatar (information->factory, - data, size, mime_type); - } + const gchar *data; + gsize size; + const gchar *mime_type; + + empathy_avatar_chooser_get_image_data ( + EMPATHY_AVATAR_CHOOSER (information->widget_avatar), + &data, &size, &mime_type); + empathy_tp_contact_factory_set_avatar (information->factory, + data, size, mime_type); } static gboolean -- cgit v1.2.3 From b8484ca5a72d50253a4ec86c79b188dfd46265ab Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 18 Feb 2009 11:27:34 +0100 Subject: Disconnect all signals from tp_chat when the UI is destroyed --- libempathy-gtk/empathy-chat.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index 6b2fb1ebd..985eaa4cf 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -65,7 +65,6 @@ #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyChat) typedef struct { EmpathyTpChat *tp_chat; - gulong tp_chat_destroy_handler; McAccount *account; gchar *id; gchar *name; @@ -1436,7 +1435,20 @@ chat_finalize (GObject *object) g_object_unref (priv->log_manager); if (priv->tp_chat) { - g_signal_handler_disconnect (priv->tp_chat, priv->tp_chat_destroy_handler); + g_signal_handlers_disconnect_by_func (priv->tp_chat, + chat_destroy_cb, 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_state_changed_cb, chat); + g_signal_handlers_disconnect_by_func (priv->tp_chat, + chat_property_changed_cb, chat); + g_signal_handlers_disconnect_by_func (priv->tp_chat, + chat_members_changed_cb, chat); + g_signal_handlers_disconnect_by_func (priv->tp_chat, + chat_remote_contact_changed_cb, chat); empathy_tp_chat_close (priv->tp_chat); g_object_unref (priv->tp_chat); } @@ -1629,6 +1641,9 @@ empathy_chat_set_tp_chat (EmpathyChat *chat, connection); g_object_ref (priv->account); + g_signal_connect (tp_chat, "destroy", + G_CALLBACK (chat_destroy_cb), + chat); g_signal_connect (tp_chat, "message-received", G_CALLBACK (chat_message_received_cb), chat); @@ -1647,10 +1662,6 @@ empathy_chat_set_tp_chat (EmpathyChat *chat, g_signal_connect_swapped (tp_chat, "notify::remote-contact", G_CALLBACK (chat_remote_contact_changed_cb), chat); - priv->tp_chat_destroy_handler = - g_signal_connect (tp_chat, "destroy", - G_CALLBACK (chat_destroy_cb), - chat); chat_remote_contact_changed_cb (chat); -- cgit v1.2.3 From dcd115814f40de200c3cf4da6693de84489592ac Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Tue, 3 Mar 2009 23:57:44 +0100 Subject: Port EmpathyContactListView's DnD to new API --- libempathy-gtk/empathy-contact-list-view.c | 170 +++++++++++++++++++---------- 1 file changed, 112 insertions(+), 58 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c index 3fdc7b327..289595df6 100644 --- a/libempathy-gtk/empathy-contact-list-view.c +++ b/libempathy-gtk/empathy-contact-list-view.c @@ -31,10 +31,12 @@ #include #include +#include #include +#include #include -#include +#include #include #include #include @@ -122,8 +124,8 @@ contact_list_view_tooltip_destroy_cb (GtkWidget *widget, if (priv->tooltip_widget) { DEBUG ("Tooltip destroyed"); + g_object_unref (priv->tooltip_widget); priv->tooltip_widget = NULL; - g_object_unref (widget); } } @@ -188,8 +190,48 @@ OUT: return ret; } +typedef struct { + gchar *new_group; + gchar *old_group; + GdkDragAction action; +} DndGetContactData; + +static void +contact_list_view_dnd_get_contact_free (DndGetContactData *data) +{ + g_free (data->new_group); + g_free (data->old_group); + g_slice_free (DndGetContactData, data); +} + +static void +contact_list_view_drag_got_contact (EmpathyTpContactFactory *factory, + GList *contacts, + gpointer user_data, + GObject *view) +{ + EmpathyContactListViewPriv *priv = GET_PRIV (view); + DndGetContactData *data = user_data; + EmpathyContactList *list; + EmpathyContact *contact = contacts->data; + + + DEBUG ("contact %s (%d) dragged from '%s' to '%s'", + empathy_contact_get_id (contact), + empathy_contact_get_handle (contact), + data->old_group, data->new_group); + + list = empathy_contact_list_store_get_list_iface (priv->store); + if (data->new_group) { + empathy_contact_list_add_to_group (list, contact, data->new_group); + } + if (data->old_group && data->action == GDK_ACTION_MOVE) { + empathy_contact_list_remove_from_group (list, contact, data->old_group); + } +} + static void -contact_list_view_drag_data_received (GtkWidget *widget, +contact_list_view_drag_data_received (GtkWidget *view, GdkDragContext *context, gint x, gint y, @@ -198,88 +240,100 @@ contact_list_view_drag_data_received (GtkWidget *widget, guint time) { EmpathyContactListViewPriv *priv; - EmpathyContactList *list; - EmpathyContactFactory *factory; + EmpathyAccountManager *account_manager; + EmpathyTpContactFactory *factory = NULL; McAccount *account; GtkTreeModel *model; - GtkTreePath *path; GtkTreeViewDropPosition position; - EmpathyContact *contact = NULL; + GtkTreePath *path; const gchar *id; - gchar **strv; + gchar **strv = NULL; + const gchar *account_id; + const gchar *contact_id; gchar *new_group = NULL; gchar *old_group = NULL; + DndGetContactData *data; gboolean is_row; + gboolean success = TRUE; - priv = GET_PRIV (widget); - - id = (const gchar*) selection->data; - DEBUG ("Received %s%s drag & drop contact from roster with id:'%s'", - context->action == GDK_ACTION_MOVE ? "move" : "", - context->action == GDK_ACTION_COPY ? "copy" : "", - id); + priv = GET_PRIV (view); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (view)); - strv = g_strsplit (id, "/", 2); - factory = empathy_contact_factory_dup_singleton (); - account = mc_account_lookup (strv[0]); - if (account) { - contact = empathy_contact_factory_get_from_id (factory, - account, - strv[1]); - g_object_unref (account); - } - g_object_unref (factory); - g_strfreev (strv); + /* Get destination group information. */ + is_row = gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (view), + x, + y, + &path, + &position); - if (!contact) { - DEBUG ("No contact found associated with drag & drop"); - return; + if (is_row) { + new_group = empathy_contact_list_store_get_parent_group (model, + path, NULL); + gtk_tree_path_free (path); } - empathy_contact_run_until_ready (contact, - EMPATHY_CONTACT_READY_HANDLE, - NULL); - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); - /* Get source group information. */ if (priv->drag_row) { path = gtk_tree_row_reference_get_path (priv->drag_row); if (path) { - old_group = empathy_contact_list_store_get_parent_group (model, path, NULL); + old_group = empathy_contact_list_store_get_parent_group ( + model, path, NULL); gtk_tree_path_free (path); } } - /* Get destination group information. */ - is_row = gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget), - x, - y, - &path, - &position); - - if (is_row) { - new_group = empathy_contact_list_store_get_parent_group (model, path, NULL); - gtk_tree_path_free (path); + if (!tp_strdiff (old_group, new_group)) { + g_free (new_group); + g_free (old_group); + goto OUT; } - DEBUG ("contact %s (%d) dragged from '%s' to '%s'", - empathy_contact_get_id (contact), - empathy_contact_get_handle (contact), - old_group, new_group); + id = (const gchar*) selection->data; + DEBUG ("Received %s%s drag & drop contact from roster with id:'%s'", + context->action == GDK_ACTION_MOVE ? "move" : "", + context->action == GDK_ACTION_COPY ? "copy" : "", + id); - list = empathy_contact_list_store_get_list_iface (priv->store); - if (new_group) { - empathy_contact_list_add_to_group (list, contact, new_group); + strv = g_strsplit (id, "/", 2); + account_id = strv[0]; + contact_id = strv[1]; + account = mc_account_lookup (account_id); + if (account) { + TpConnection *connection; + + /* FIXME: We assume we have already an account manager */ + account_manager = empathy_account_manager_dup_singleton (); + connection = empathy_account_manager_get_connection (account_manager, + account); + if (connection) { + factory = empathy_tp_contact_factory_dup_singleton (connection); + } + g_object_unref (account_manager); } - if (old_group && context->action == GDK_ACTION_MOVE) { - empathy_contact_list_remove_from_group (list, contact, old_group); + + if (!factory) { + DEBUG ("Failed to get factory for account '%s'", account_id); + success = FALSE; + g_free (new_group); + g_free (old_group); + goto OUT; } - g_free (old_group); - g_free (new_group); + data = g_slice_new0 (DndGetContactData); + data->new_group = new_group; + data->old_group = old_group; + data->action = context->action; - gtk_drag_finish (context, TRUE, FALSE, GDK_CURRENT_TIME); + empathy_tp_contact_factory_get_from_ids (factory, 1, &contact_id, + contact_list_view_drag_got_contact, + data, (GDestroyNotify) contact_list_view_dnd_get_contact_free, + G_OBJECT (view)); + + g_object_unref (factory); + +OUT: + g_strfreev (strv); + gtk_drag_finish (context, success, FALSE, GDK_CURRENT_TIME); } static gboolean -- cgit v1.2.3 From 9b9fcd3ce3b9c7fdc62836821d83377bec58d0a5 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 4 Mar 2009 11:41:28 +0100 Subject: Change EmpathyTpContactFactory API to look more like TpConnection. Add function to get only one contact from id/handle. --- libempathy-gtk/empathy-contact-list-view.c | 12 +++++++++--- libempathy-gtk/empathy-contact-widget.c | 15 +++++++++++---- libempathy-gtk/empathy-new-message-dialog.c | 12 +++++++++--- 3 files changed, 29 insertions(+), 10 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c index 289595df6..df7149b50 100644 --- a/libempathy-gtk/empathy-contact-list-view.c +++ b/libempathy-gtk/empathy-contact-list-view.c @@ -206,15 +206,19 @@ contact_list_view_dnd_get_contact_free (DndGetContactData *data) static void contact_list_view_drag_got_contact (EmpathyTpContactFactory *factory, - GList *contacts, + EmpathyContact *contact, + const GError *error, gpointer user_data, GObject *view) { EmpathyContactListViewPriv *priv = GET_PRIV (view); DndGetContactData *data = user_data; EmpathyContactList *list; - EmpathyContact *contact = contacts->data; + if (error != NULL) { + DEBUG ("Error: %s", error->message); + return; + } DEBUG ("contact %s (%d) dragged from '%s' to '%s'", empathy_contact_get_id (contact), @@ -324,7 +328,9 @@ contact_list_view_drag_data_received (GtkWidget *view, data->old_group = old_group; data->action = context->action; - empathy_tp_contact_factory_get_from_ids (factory, 1, &contact_id, + /* FIXME: We should probably wait for the cb before calling + * gtk_drag_finish */ + empathy_tp_contact_factory_get_from_id (factory, contact_id, contact_list_view_drag_got_contact, data, (GDestroyNotify) contact_list_view_dnd_get_contact_free, G_OBJECT (view)); diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c index df876b603..18d7f415a 100644 --- a/libempathy-gtk/empathy-contact-widget.c +++ b/libempathy-gtk/empathy-contact-widget.c @@ -690,13 +690,20 @@ contact_widget_contact_update (EmpathyContactWidget *information) static void contact_widget_got_contact_cb (EmpathyTpContactFactory *factory, - GList *contacts, + EmpathyContact *contact, + const GError *error, gpointer user_data, GObject *weak_object) { EmpathyContactWidget *information = user_data; - contact_widget_set_contact (information, contacts->data); + if (error != NULL) + { + DEBUG ("Error: %s", error->message); + return; + } + + contact_widget_set_contact (information, contact); } static void @@ -715,7 +722,7 @@ contact_widget_get_self_handle_cb (TpConnection *connection, } factory = empathy_tp_contact_factory_dup_singleton (connection); - empathy_tp_contact_factory_get_from_handles (factory, 1, &self_handle, + empathy_tp_contact_factory_get_from_handle (factory, self_handle, contact_widget_got_contact_cb, information, NULL, weak_object); g_object_unref (factory); @@ -741,7 +748,7 @@ contact_widget_change_contact (EmpathyContactWidget *information) EmpathyTpContactFactory *factory; factory = empathy_tp_contact_factory_dup_singleton (connection); - empathy_tp_contact_factory_get_from_ids (factory, 1, &id, + empathy_tp_contact_factory_get_from_id (factory, id, contact_widget_got_contact_cb, information, NULL, G_OBJECT (information->vbox_contact_widget)); g_object_unref (factory); diff --git a/libempathy-gtk/empathy-new-message-dialog.c b/libempathy-gtk/empathy-new-message-dialog.c index 1192ecf73..b1a35095b 100644 --- a/libempathy-gtk/empathy-new-message-dialog.c +++ b/libempathy-gtk/empathy-new-message-dialog.c @@ -173,14 +173,20 @@ new_message_dialog_match_func (GtkEntryCompletion *completion, static void new_message_dialog_call_got_contact_cb (EmpathyTpContactFactory *factory, - GList *contacts, + EmpathyContact *contact, + const GError *error, gpointer user_data, GObject *weak_object) { EmpathyCallFactory *call_factory; + if (error != NULL) { + DEBUG ("Error: %s", error->message); + return; + } + call_factory = empathy_call_factory_get(); - empathy_call_factory_new_call (call_factory, contacts->data); + empathy_call_factory_new_call (call_factory, contact); } static void @@ -203,7 +209,7 @@ new_message_dialog_response_cb (GtkWidget *widget, EmpathyTpContactFactory *factory; factory = empathy_tp_contact_factory_dup_singleton (connection); - empathy_tp_contact_factory_get_from_ids (factory, 1, &id, + empathy_tp_contact_factory_get_from_id (factory, id, new_message_dialog_call_got_contact_cb, NULL, NULL, NULL); g_object_unref (factory); -- cgit v1.2.3 From 7761eeb4a0e307c14a96906cca1a94346f39c3a6 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 18 Mar 2009 01:28:03 +0100 Subject: Use tp_connection_get_self_handle where needed --- libempathy-gtk/empathy-contact-widget.c | 36 +++++++-------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c index 18d7f415a..e8ddc01a2 100644 --- a/libempathy-gtk/empathy-contact-widget.c +++ b/libempathy-gtk/empathy-contact-widget.c @@ -706,31 +706,10 @@ contact_widget_got_contact_cb (EmpathyTpContactFactory *factory, contact_widget_set_contact (information, contact); } -static void -contact_widget_get_self_handle_cb (TpConnection *connection, - TpHandle self_handle, - const GError *error, - gpointer information, - GObject *weak_object) -{ - EmpathyTpContactFactory *factory; - - if (error != NULL) - { - DEBUG ("Error: %s", error->message); - return; - } - - factory = empathy_tp_contact_factory_dup_singleton (connection); - empathy_tp_contact_factory_get_from_handle (factory, self_handle, - contact_widget_got_contact_cb, information, NULL, - weak_object); - g_object_unref (factory); -} - static void contact_widget_change_contact (EmpathyContactWidget *information) { + EmpathyTpContactFactory *factory; TpConnection *connection; connection = empathy_account_chooser_get_connection ( @@ -738,6 +717,7 @@ contact_widget_change_contact (EmpathyContactWidget *information) if (!connection) return; + factory = empathy_tp_contact_factory_dup_singleton (connection); if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID) { const gchar *id; @@ -745,22 +725,20 @@ contact_widget_change_contact (EmpathyContactWidget *information) id = gtk_entry_get_text (GTK_ENTRY (information->widget_id)); if (!EMP_STR_EMPTY (id)) { - EmpathyTpContactFactory *factory; - - factory = empathy_tp_contact_factory_dup_singleton (connection); empathy_tp_contact_factory_get_from_id (factory, id, contact_widget_got_contact_cb, information, NULL, G_OBJECT (information->vbox_contact_widget)); - g_object_unref (factory); } } else { - /* FIXME: TpConnection should have a SelfHandle property */ - tp_cli_connection_call_get_self_handle (connection, -1, - contact_widget_get_self_handle_cb, information, NULL, + empathy_tp_contact_factory_get_from_handle (factory, + tp_connection_get_self_handle (connection), + contact_widget_got_contact_cb, information, NULL, G_OBJECT (information->vbox_contact_widget)); } + + g_object_unref (factory); } static void -- cgit v1.2.3 From a5356f9c7ea9979f05a6752a848d944a9ed7264d Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Tue, 21 Apr 2009 00:31:24 +0200 Subject: Add G_PARAM_STATIC_STRINGS to EmpathyContact properties --- libempathy-gtk/empathy-contact-widget.c | 1 - 1 file changed, 1 deletion(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c index e8ddc01a2..fc64d15c6 100644 --- a/libempathy-gtk/empathy-contact-widget.c +++ b/libempathy-gtk/empathy-contact-widget.c @@ -157,7 +157,6 @@ empathy_contact_widget_new (EmpathyContact *contact, { EmpathyContactWidget *information; GtkBuilder *gui; - TpConnection *connection; gchar *filename; g_return_val_if_fail (contact == NULL || EMPATHY_IS_CONTACT (contact), NULL); -- cgit v1.2.3 From 106a3a59f4a0192e7db510359dbbde0c1acc0b05 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 22 Apr 2009 10:35:40 +0200 Subject: Don't forget to show the contact widget in some places --- libempathy-gtk/empathy-contact-dialogs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-contact-dialogs.c b/libempathy-gtk/empathy-contact-dialogs.c index 38e02409f..056ec2d85 100644 --- a/libempathy-gtk/empathy-contact-dialogs.c +++ b/libempathy-gtk/empathy-contact-dialogs.c @@ -116,6 +116,7 @@ empathy_subscription_dialog_show (EmpathyContact *contact, g_free (filename); g_object_unref (gui); + /* Contact info widget */ contact_widget = empathy_contact_widget_new (contact, EMPATHY_CONTACT_WIDGET_EDIT_ALIAS | EMPATHY_CONTACT_WIDGET_EDIT_GROUPS); @@ -125,7 +126,6 @@ empathy_subscription_dialog_show (EmpathyContact *contact, 0); gtk_widget_show (contact_widget); - g_object_set_data (G_OBJECT (dialog), "contact_widget", contact_widget); subscription_dialogs = g_list_prepend (subscription_dialogs, dialog); @@ -195,6 +195,7 @@ empathy_contact_information_dialog_show (EmpathyContact *contact, gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), contact_widget, TRUE, TRUE, 0); + gtk_widget_show (contact_widget); g_object_set_data (G_OBJECT (dialog), "contact_widget", contact_widget); information_dialogs = g_list_prepend (information_dialogs, dialog); @@ -253,6 +254,8 @@ empathy_contact_edit_dialog_show (EmpathyContact *contact, gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), contact_widget, TRUE, TRUE, 0); + gtk_widget_show (contact_widget); + g_object_set_data (G_OBJECT (dialog), "contact_widget", contact_widget); edit_dialogs = g_list_prepend (edit_dialogs, dialog); @@ -304,8 +307,8 @@ empathy_contact_personal_dialog_show (GtkWindow *parent) contact_widget, TRUE, TRUE, 0); empathy_contact_widget_set_account_filter (contact_widget, - empathy_account_chooser_filter_is_connected, - NULL); + empathy_account_chooser_filter_is_connected, NULL); + gtk_widget_show (contact_widget); g_signal_connect (personal_dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL); -- cgit v1.2.3 From 03899c3c61a0e9a975caaaf2e6f30ccfeaeaeff5 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Wed, 22 Apr 2009 12:01:37 +0100 Subject: Renamed empathy_account_chooser_get_account to empathy_account_chooser_dup_account and fixed leaks. Signed-off-by: Jonny Lamb --- libempathy-gtk/empathy-account-chooser.c | 4 ++-- libempathy-gtk/empathy-account-chooser.h | 2 +- libempathy-gtk/empathy-log-window.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-account-chooser.c b/libempathy-gtk/empathy-account-chooser.c index ea3d6e513..859ba3353 100644 --- a/libempathy-gtk/empathy-account-chooser.c +++ b/libempathy-gtk/empathy-account-chooser.c @@ -220,7 +220,7 @@ empathy_account_chooser_new (void) } McAccount * -empathy_account_chooser_get_account (EmpathyAccountChooser *chooser) +empathy_account_chooser_dup_account (EmpathyAccountChooser *chooser) { EmpathyAccountChooserPriv *priv; McAccount *account; @@ -252,7 +252,7 @@ empathy_account_chooser_get_connection (EmpathyAccountChooser *chooser) priv = GET_PRIV (chooser); - account = empathy_account_chooser_get_account (chooser); + account = empathy_account_chooser_dup_account (chooser); connection = empathy_account_manager_get_connection (priv->manager, account); g_object_unref (account); diff --git a/libempathy-gtk/empathy-account-chooser.h b/libempathy-gtk/empathy-account-chooser.h index 4dfdc632e..580c21695 100644 --- a/libempathy-gtk/empathy-account-chooser.h +++ b/libempathy-gtk/empathy-account-chooser.h @@ -56,7 +56,7 @@ struct _EmpathyAccountChooserClass { GType empathy_account_chooser_get_type (void) G_GNUC_CONST; GtkWidget * empathy_account_chooser_new (void); -McAccount * empathy_account_chooser_get_account (EmpathyAccountChooser *chooser); +McAccount * empathy_account_chooser_dup_account (EmpathyAccountChooser *chooser); TpConnection * empathy_account_chooser_get_connection (EmpathyAccountChooser *chooser); gboolean empathy_account_chooser_set_account (EmpathyAccountChooser *chooser, McAccount *account); diff --git a/libempathy-gtk/empathy-log-window.c b/libempathy-gtk/empathy-log-window.c index 2cec17783..13d9bcbd3 100644 --- a/libempathy-gtk/empathy-log-window.c +++ b/libempathy-gtk/empathy-log-window.c @@ -618,7 +618,7 @@ log_window_chats_populate (EmpathyLogWindow *window) GtkTreeIter iter; account_chooser = EMPATHY_ACCOUNT_CHOOSER (window->account_chooser_chats); - account = empathy_account_chooser_get_account (account_chooser); + account = empathy_account_chooser_dup_account (account_chooser); view = GTK_TREE_VIEW (window->treeview_chats); model = gtk_tree_view_get_model (view); -- cgit v1.2.3 From 10a93b8c864c38dacc49a9f33b7ebf0cff549cfb Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Wed, 22 Apr 2009 12:07:29 +0100 Subject: Renamed empathy_contact_list_view_get_selected to empathy_contact_list_view_dup_selected and fixed leaks. Signed-off-by: Jonny Lamb --- libempathy-gtk/empathy-contact-list-view.c | 8 ++++---- libempathy-gtk/empathy-contact-list-view.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c index df7149b50..ca224f526 100644 --- a/libempathy-gtk/empathy-contact-list-view.c +++ b/libempathy-gtk/empathy-contact-list-view.c @@ -474,7 +474,7 @@ contact_list_view_drag_data_get (GtkWidget *widget, gtk_tree_path_free (src_path); - contact = empathy_contact_list_view_get_selected (EMPATHY_CONTACT_LIST_VIEW (widget)); + contact = empathy_contact_list_view_dup_selected (EMPATHY_CONTACT_LIST_VIEW (widget)); if (!contact) { return; } @@ -1218,7 +1218,7 @@ empathy_contact_list_view_new (EmpathyContactListStore *store, } EmpathyContact * -empathy_contact_list_view_get_selected (EmpathyContactListView *view) +empathy_contact_list_view_dup_selected (EmpathyContactListView *view) { EmpathyContactListViewPriv *priv; GtkTreeSelection *selection; @@ -1384,7 +1384,7 @@ contact_list_view_remove_activate_cb (GtkMenuItem *menuitem, EmpathyContactListViewPriv *priv = GET_PRIV (view); EmpathyContact *contact; - contact = empathy_contact_list_view_get_selected (view); + contact = empathy_contact_list_view_dup_selected (view); if (contact) { gchar *text; @@ -1417,7 +1417,7 @@ empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view) g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL); - contact = empathy_contact_list_view_get_selected (view); + contact = empathy_contact_list_view_dup_selected (view); if (!contact) { return NULL; } diff --git a/libempathy-gtk/empathy-contact-list-view.h b/libempathy-gtk/empathy-contact-list-view.h index 82990d64f..bb6766c4a 100644 --- a/libempathy-gtk/empathy-contact-list-view.h +++ b/libempathy-gtk/empathy-contact-list-view.h @@ -70,7 +70,7 @@ GType empathy_contact_list_view_get_type (void) G EmpathyContactListView * empathy_contact_list_view_new (EmpathyContactListStore *store, EmpathyContactListFeatureFlags list_features, EmpathyContactFeatureFlags contact_features); -EmpathyContact * empathy_contact_list_view_get_selected (EmpathyContactListView *view); +EmpathyContact * empathy_contact_list_view_dup_selected (EmpathyContactListView *view); gchar * empathy_contact_list_view_get_selected_group (EmpathyContactListView *view); GtkWidget * empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view); GtkWidget * empathy_contact_list_view_get_group_menu (EmpathyContactListView *view); -- cgit v1.2.3 From 5303246bdec46980c2a447e77759f4c107967bca Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Wed, 22 Apr 2009 12:09:38 +0100 Subject: Renamed empathy_profile_chooser_get_selected to empathy_profile_chooser_dup_selected and fixed leaks. Signed-off-by: Jonny Lamb --- libempathy-gtk/empathy-profile-chooser.c | 2 +- libempathy-gtk/empathy-profile-chooser.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-profile-chooser.c b/libempathy-gtk/empathy-profile-chooser.c index fd68dd8b0..897e38344 100644 --- a/libempathy-gtk/empathy-profile-chooser.c +++ b/libempathy-gtk/empathy-profile-chooser.c @@ -38,7 +38,7 @@ enum { }; McProfile* -empathy_profile_chooser_get_selected (GtkWidget *widget) +empathy_profile_chooser_dup_selected (GtkWidget *widget) { GtkTreeModel *model; GtkTreeIter iter; diff --git a/libempathy-gtk/empathy-profile-chooser.h b/libempathy-gtk/empathy-profile-chooser.h index 8cdc33d67..74c761cc4 100644 --- a/libempathy-gtk/empathy-profile-chooser.h +++ b/libempathy-gtk/empathy-profile-chooser.h @@ -27,7 +27,7 @@ G_BEGIN_DECLS GtkWidget * empathy_profile_chooser_new (void); -McProfile * empathy_profile_chooser_get_selected (GtkWidget *widget); +McProfile * empathy_profile_chooser_dup_selected (GtkWidget *widget); gint empathy_profile_chooser_n_profiles (GtkWidget *widget); G_END_DECLS -- cgit v1.2.3 From db53174019108700d3e944f145c17c7ab4e623d2 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Wed, 22 Apr 2009 11:40:23 +0100 Subject: empathy-account-widget-irc.ui: the network dialog doesn't have to be visible by default. Fixes #579800 --- libempathy-gtk/empathy-account-widget-irc.ui | 1 - 1 file changed, 1 deletion(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-account-widget-irc.ui b/libempathy-gtk/empathy-account-widget-irc.ui index f499866eb..b7cb79d33 100644 --- a/libempathy-gtk/empathy-account-widget-irc.ui +++ b/libempathy-gtk/empathy-account-widget-irc.ui @@ -3,7 +3,6 @@ - True 5 Network center-on-parent -- cgit v1.2.3 From 05007fc365715586cd17d49c1c8254b267b7748b Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Wed, 22 Apr 2009 17:59:14 +0100 Subject: rename button_remove to button_remove_network to fix id clash --- libempathy-gtk/empathy-account-widget-irc.c | 4 ++-- libempathy-gtk/empathy-account-widget-irc.ui | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-account-widget-irc.c b/libempathy-gtk/empathy-account-widget-irc.c index 3af842415..4546cfd23 100644 --- a/libempathy-gtk/empathy-account-widget-irc.c +++ b/libempathy-gtk/empathy-account-widget-irc.c @@ -464,7 +464,7 @@ empathy_account_widget_irc_new (McAccount *account) "combobox_network", &settings->combobox_network, "button_network", &settings->button_network, "button_add_network", &settings->button_add_network, - "button_remove", &settings->button_remove, + "button_remove_network", &settings->button_remove, NULL); g_free (filename); @@ -501,7 +501,7 @@ empathy_account_widget_irc_new (McAccount *account) "vbox_irc_settings", "destroy", account_widget_irc_destroy_cb, "button_network", "clicked", account_widget_irc_button_edit_network_clicked_cb, "button_add_network", "clicked", account_widget_irc_button_add_network_clicked_cb, - "button_remove", "clicked", account_widget_irc_button_remove_clicked_cb, + "button_remove_network", "clicked", account_widget_irc_button_remove_clicked_cb, "combobox_network", "changed", account_widget_irc_combobox_network_changed_cb, NULL); diff --git a/libempathy-gtk/empathy-account-widget-irc.ui b/libempathy-gtk/empathy-account-widget-irc.ui index b7cb79d33..bcfc67fe2 100644 --- a/libempathy-gtk/empathy-account-widget-irc.ui +++ b/libempathy-gtk/empathy-account-widget-irc.ui @@ -417,7 +417,7 @@ - + True True True -- cgit v1.2.3 From 87075dd29c374be6e28f82eb90e6430a992517dc Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Wed, 22 Apr 2009 18:05:49 +0100 Subject: fix another id clash --- libempathy-gtk/empathy-account-widget-irc.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-account-widget-irc.ui b/libempathy-gtk/empathy-account-widget-irc.ui index bcfc67fe2..76c67f711 100644 --- a/libempathy-gtk/empathy-account-widget-irc.ui +++ b/libempathy-gtk/empathy-account-widget-irc.ui @@ -443,7 +443,7 @@ - + True 0 Network: -- cgit v1.2.3 From 8c4a034f53f36e1200d3f839161f22b3b6d9c603 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Wed, 22 Apr 2009 18:11:39 +0100 Subject: empathy_irc_network_dialog_show: call show_all on the dialog --- libempathy-gtk/empathy-irc-network-dialog.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-irc-network-dialog.c b/libempathy-gtk/empathy-irc-network-dialog.c index 89ee5b284..8f7f47bda 100644 --- a/libempathy-gtk/empathy-irc-network-dialog.c +++ b/libempathy-gtk/empathy-irc-network-dialog.c @@ -572,6 +572,7 @@ empathy_irc_network_dialog_show (EmpathyIrcNetwork *network, gtk_window_set_modal (GTK_WINDOW (dialog->dialog), TRUE); irc_network_dialog_network_update_buttons (dialog); + gtk_widget_show_all (dialog->dialog); return dialog->dialog; } -- cgit v1.2.3 From 8fa3ff8e73893a46d3821babc69a9b57a0f29170 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Wed, 22 Apr 2009 21:00:30 +0100 Subject: Add documentation for EmpathyAccountChooser. Signed-off-by: Jonny Lamb --- libempathy-gtk/empathy-account-chooser.c | 103 +++++++++++++++++++++++++++++++ libempathy-gtk/empathy-account-chooser.h | 2 + 2 files changed, 105 insertions(+) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-account-chooser.c b/libempathy-gtk/empathy-account-chooser.c index 859ba3353..aa6cf29e0 100644 --- a/libempathy-gtk/empathy-account-chooser.c +++ b/libempathy-gtk/empathy-account-chooser.c @@ -37,6 +37,23 @@ #include "empathy-ui-utils.h" #include "empathy-account-chooser.h" +/** + * SECTION:empathy-account-chooser + * @title:EmpathyAccountChooser + * @short_description: A widget used to choose from a list of accounts + * @include: libempathy-gtk/empathy-account-chooser.h + * + * #EmpathyAccountChooser is a widget which extends #GtkComboBox to provide + * a chooser of available accounts. + */ + +/** + * EmpathyAccountChooser: + * @parent: parent object + * + * Widget which extends #GtkComboBox to provide a chooser of available accounts. + */ + #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountChooser) typedef struct { EmpathyAccountManager *manager; @@ -112,6 +129,11 @@ empathy_account_chooser_class_init (EmpathyAccountChooserClass *klass) object_class->get_property = account_chooser_get_property; object_class->set_property = account_chooser_set_property; + /** + * EmpathyAccountChooser:has-all-option: + * + * Have an additional option in the list to mean all accounts. + */ g_object_class_install_property (object_class, PROP_HAS_ALL_OPTION, g_param_spec_boolean ("has-all-option", @@ -209,6 +231,13 @@ account_chooser_set_property (GObject *object, }; } +/** + * empathy_account_chooser_new: + * + * Creates a new #EmpathyAccountChooser. + * + * Return value: A new #EmpathyAccountChooser + */ GtkWidget * empathy_account_chooser_new (void) { @@ -219,6 +248,16 @@ empathy_account_chooser_new (void) return chooser; } +/** + * empathy_account_chooser_dup_account: + * @chooser: an #EmpathyAccountChooser + * + * Returns the account which is currently selected in the chooser or %NULL + * if there is no account selected. The #McAccount returned should be + * unrefed when finished with. + * + * Return value: a new ref to the #McAccount currently selected, or %NULL. + */ McAccount * empathy_account_chooser_dup_account (EmpathyAccountChooser *chooser) { @@ -241,6 +280,14 @@ empathy_account_chooser_dup_account (EmpathyAccountChooser *chooser) return account; } +/** + * empathy_account_chooser_get_connection: + * @chooser: an #EmpathyAccountChooser + * + * Returns the #TpConnection associated with the account currently selected. + * + * Return value: the #TpConnection associated with the account curently selected. + */ TpConnection * empathy_account_chooser_get_connection (EmpathyAccountChooser *chooser) { @@ -259,6 +306,15 @@ empathy_account_chooser_get_connection (EmpathyAccountChooser *chooser) return connection; } +/** + * empathy_account_chooser_set_account: + * @chooser: an #EmpathyAccountChooser + * @account: an #McAccount + * + * Sets the currently selected account to @account, if it exists in the list. + * + * Return value: whether the chooser was set to @account. + */ gboolean empathy_account_chooser_set_account (EmpathyAccountChooser *chooser, McAccount *account) @@ -284,6 +340,16 @@ empathy_account_chooser_set_account (EmpathyAccountChooser *chooser, return data.set; } +/** + * empathy_account_chooser_get_has_all_option: + * @chooser: an #EmpathyAccountChooser + * + * Returns whether @chooser has the #EmpathyAccountChooser:has-all-option property + * set to true. + * + * Return value: whether @chooser has the #EmpathyAccountChooser:has-all-option property + * enabled. + */ gboolean empathy_account_chooser_get_has_all_option (EmpathyAccountChooser *chooser) { @@ -296,6 +362,13 @@ empathy_account_chooser_get_has_all_option (EmpathyAccountChooser *chooser) return priv->has_all_option; } +/** + * empathy_account_chooser_set_has_all_option: + * @chooser: an #EmpathyAccountChooser + * @has_all_option: a new value for the #EmpathyAccountChooser:has-all-option property + * + * Sets the #EmpathyAccountChooser:has-all-option property. + */ void empathy_account_chooser_set_has_all_option (EmpathyAccountChooser *chooser, gboolean has_all_option) @@ -636,6 +709,15 @@ account_chooser_filter_foreach (GtkTreeModel *model, return FALSE; } +/** + * empathy_account_chooser_set_filter: + * @chooser: an #EmpathyAccountChooser + * @filter: a filter + * @user_data: data to pass to @filter, or %NULL + * + * Sets a filter on the @chooser so only accounts that are %TRUE in the eyes + * of the filter are visible in the @chooser. + */ void empathy_account_chooser_set_filter (EmpathyAccountChooser *chooser, EmpathyAccountChooserFilterFunc filter, @@ -657,6 +739,27 @@ empathy_account_chooser_set_filter (EmpathyAccountChooser *chooser, gtk_tree_model_foreach (model, account_chooser_filter_foreach, chooser); } +/** + * EmpathyAccountChooserFilterFunc: + * @account: an #McAccount + * @user_data: user data, or %NULL + * + * A function which decides whether the account indicated by @account + * is visible. + * + * Return value: whether the account indicated by @account is visible. + */ + +/** + * empathy_account_chooser_filter_is_connected: + * @account: an #McAccount + * @user_data: user data or %NULL + * + * A useful #EmpathyAccountChooserFilterFunc that one could pass into + * empathy_account_chooser_set_filter() and only show connected accounts. + * + * Return value: Whether @account is connected + */ gboolean empathy_account_chooser_filter_is_connected (McAccount *account, gpointer user_data) diff --git a/libempathy-gtk/empathy-account-chooser.h b/libempathy-gtk/empathy-account-chooser.h index 580c21695..98d568bcc 100644 --- a/libempathy-gtk/empathy-account-chooser.h +++ b/libempathy-gtk/empathy-account-chooser.h @@ -47,6 +47,8 @@ typedef struct _EmpathyAccountChooserClass EmpathyAccountChooserClass; struct _EmpathyAccountChooser { GtkComboBox parent; + + /**/ gpointer priv; }; -- cgit v1.2.3 From 8874db95d33d68487ac98e1323c15dbd03015629 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Wed, 22 Apr 2009 21:22:38 +0100 Subject: Add documentation for EmpathyContactSelector. Signed-off-by: Jonny Lamb --- libempathy-gtk/empathy-contact-selector.c | 68 ++++++++++++++++++++++++++++++- libempathy-gtk/empathy-contact-selector.h | 2 + 2 files changed, 68 insertions(+), 2 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-contact-selector.c b/libempathy-gtk/empathy-contact-selector.c index 539629a23..a51d8d3fe 100644 --- a/libempathy-gtk/empathy-contact-selector.c +++ b/libempathy-gtk/empathy-contact-selector.c @@ -31,6 +31,23 @@ #include "empathy-contact-selector.h" +/** + * SECTION:empathy-contact-selector + * @title:EmpathyContactSelector + * @short_description: A widget used to choose from a list of contacts. + * @include: libempathy-gtk/empathy-contact-selector.h + * + * #EmpathyContactSelector is a widget which extends #GtkComboBox to provide + * a chooser of available contacts. + */ + +/** + * EmpathyContactSelector: + * @parent: parent object + * + * Widget which extends #GtkComboBox to provide a chooser of available contacts. + */ + G_DEFINE_TYPE (EmpathyContactSelector, empathy_contact_selector, GTK_TYPE_COMBO_BOX) @@ -320,14 +337,27 @@ empathy_contact_selector_class_init (EmpathyContactSelectorClass *klass) object_class->get_property = contact_selector_get_property; g_type_class_add_private (klass, sizeof (EmpathyContactSelectorPriv)); + /** + * EmpathyContactSelector:contact-list: + * + * An #EmpathyContactList containing the contacts for the + * #EmpathyContactSelector. + */ g_object_class_install_property (object_class, PROP_CONTACT_LIST, g_param_spec_object ("contact-list", "contact list", "contact list", EMPATHY_TYPE_CONTACT_LIST, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); } -/* public methods */ - +/** + * empathy_contact_selector_new: + * @contact_list: an #EmpathyContactList containing the contacts to list in + * the contact selector + * + * Creates a new #EmpathyContactSelector. + * + * Return value: A new #EmpathyContactSelector + */ GtkWidget * empathy_contact_selector_new (EmpathyContactList *contact_list) { @@ -337,6 +367,16 @@ empathy_contact_selector_new (EmpathyContactList *contact_list) "contact-list", contact_list, NULL)); } +/** + * empathy_contact_selector_dup_selected: + * @selector: An #EmpathyContactSelector + * + * Returns a new reference to the contact which is currently selected in + * @selector, or %NULL if there is no contact selected. The contact should + * be unrefed with g_object_unref() when finished with. + * + * Return value: A new reference to the contact currently selected, or %NULL + */ EmpathyContact * empathy_contact_selector_dup_selected (EmpathyContactSelector *selector) { @@ -390,6 +430,19 @@ contact_selector_filter_visible_func (GtkTreeModel *model, return visible; } +/** + * empathy_contact_selector_set_visible: + * @selector: an #EmpathyContactSelector + * @func: an #EmpathyContactSelectorFilterFunc to filter the contacts + * @user_data: data to pass to @func or %NULL + * + * Sets a filter on the @selector so only contacts that return %TRUE + * when passed into @func are visible. + * + * A typical usage for this function would be to only show contacts that + * can send or receive files. In this case, one could use the + * empathy_contact_can_send_files() function + */ void empathy_contact_selector_set_visible (EmpathyContactSelector *selector, EmpathyContactSelectorFilterFunc func, @@ -407,3 +460,14 @@ empathy_contact_selector_set_visible (EmpathyContactSelector *selector, gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (priv->model)); } + +/** + * EmpathyContactSelectorFilterFunc: + * @contact: an #EmpathyContact + * @user_data: user data or %NULL + * + * A function which decides whether the contact indicated by @contact + * is visible. + * + * Return value: whether @contact is visible + */ diff --git a/libempathy-gtk/empathy-contact-selector.h b/libempathy-gtk/empathy-contact-selector.h index f7af92f2c..205b9e411 100644 --- a/libempathy-gtk/empathy-contact-selector.h +++ b/libempathy-gtk/empathy-contact-selector.h @@ -49,6 +49,8 @@ typedef struct _EmpathyContactSelectorClass EmpathyContactSelectorClass; struct _EmpathyContactSelector { GtkComboBox parent; + + /**/ gpointer priv; }; -- cgit v1.2.3 From 796cc2509860254f98c24d56c1f8bb9f1887e9c8 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Thu, 23 Apr 2009 00:16:33 +0100 Subject: Add documentation for EmpathyContactWidget. Signed-off-by: Jonny Lamb --- libempathy-gtk/empathy-contact-widget.c | 52 +++++++++++++++++++++++++++++++++ libempathy-gtk/empathy-contact-widget.h | 21 +++++++++++++ 2 files changed, 73 insertions(+) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c index fc64d15c6..c78aafeaa 100644 --- a/libempathy-gtk/empathy-contact-widget.c +++ b/libempathy-gtk/empathy-contact-widget.c @@ -44,6 +44,25 @@ #define DEBUG_FLAG EMPATHY_DEBUG_CONTACT #include +/** + * SECTION:empathy-contact-widget + * @title:EmpathyContactWidget + * @short_description: A widget used to display and edit details about a contact + * @include: libempathy-empathy-contact-widget.h + * + * #EmpathyContactWidget is a widget which displays appropriate widgets + * with details about a contact, also allowing changing these details, + * if desired. + */ + +/** + * EmpathyContactWidget: + * @parent: parent object + * + * Widget which displays appropriate widgets with details about a contact, + * also allowing changing these details, if desired. + */ + /* Delay before updating the widget when the id entry changed (seconds) */ #define ID_CHANGED_TIMEOUT 1 @@ -151,6 +170,15 @@ enum COL_COUNT }; +/** + * empathy_contact_widget_new: + * @contact: an #EmpathyContact + * @flags: #EmpathyContactWidgetFlags for the new contact widget + * + * Creates a new #EmpathyContactWidget. + * + * Return value: a new #EmpathyContactWidget + */ GtkWidget * empathy_contact_widget_new (EmpathyContact *contact, EmpathyContactWidgetFlags flags) @@ -212,6 +240,14 @@ empathy_contact_widget_new (EmpathyContact *contact, information->vbox_contact_widget); } +/** + * empathy_contact_widget_get_contact: + * @widget: an #EmpathyContactWidget + * + * Get the #EmpathyContact related with the #EmpathyContactWidget @widget. + * + * Returns: the #EmpathyContact associated with @widget + */ EmpathyContact * empathy_contact_widget_get_contact (GtkWidget *widget) { @@ -226,6 +262,13 @@ empathy_contact_widget_get_contact (GtkWidget *widget) return information->contact; } +/** + * empathy_contact_widget_set_contact: + * @widget: an #EmpathyContactWidget + * @contact: a different #EmpathyContact + * + * Change the #EmpathyContact related with the #EmpathyContactWidget @widget. + */ void empathy_contact_widget_set_contact (GtkWidget *widget, EmpathyContact *contact) @@ -242,6 +285,15 @@ empathy_contact_widget_set_contact (GtkWidget *widget, contact_widget_set_contact (information, contact); } +/** + * empathy_contact_widget_set_account_filter: + * @widget: an #EmpathyContactWidget + * @filter: a #EmpathyAccountChooserFilterFunc + * @user_data: user data to pass to @filter, or %NULL + * + * Set a filter on the #EmpathyAccountChooser included in the + * #EmpathyContactWidget. + */ void empathy_contact_widget_set_account_filter ( GtkWidget *widget, diff --git a/libempathy-gtk/empathy-contact-widget.h b/libempathy-gtk/empathy-contact-widget.h index 4ba75e17f..db739ad19 100644 --- a/libempathy-gtk/empathy-contact-widget.h +++ b/libempathy-gtk/empathy-contact-widget.h @@ -29,6 +29,27 @@ G_BEGIN_DECLS +/** + * EmpathyContactWidgetFlags: + * @EMPATHY_CONTACT_WIDGET_EDIT_NONE: Don't show any widgets to edit any details + * of the contact. This should be the option for widgets that merely display + * information about a contact. + * @EMPATHY_CONTACT_WIDGET_EDIT_ALIAS: Show a #GtkEntry allowing changes to the + * contact's alias. + * @EMPATHY_CONTACT_WIDGET_EDIT_AVATAR: Show an #EmpathyAvatarChooser allowing + * changes to the contact's avatar. + * @EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT: Show an #EmpathyAccountChooser allowing + * changes to the contact's account. + * @EMPATHY_CONTACT_WIDGET_EDIT_ID: Show a #GtkEntry allowing changes to the + * contact's identifier. + * @EMPATHY_CONTACT_WIDGET_EDIT_GROUPS: Show a widget to change the groups the + * contact is in. + * @EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP: Make widgets more designed for a tooltip. + * For example, make widgets not selectable. + * + * Options to instruct the #EmpathyContactWidget what features should be + * enabled. + */ typedef enum { EMPATHY_CONTACT_WIDGET_EDIT_NONE = 0, -- cgit v1.2.3 From 56fa37ef682ea7e8f676f4c974b76c06242466d2 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Thu, 23 Apr 2009 00:27:42 +0100 Subject: Add documentation for EmpathyPresenceChooser. Signed-off-by: Jonny Lamb --- libempathy-gtk/empathy-presence-chooser.c | 31 +++++++++++++++++++++++++++++++ libempathy-gtk/empathy-presence-chooser.h | 2 ++ 2 files changed, 33 insertions(+) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-presence-chooser.c b/libempathy-gtk/empathy-presence-chooser.c index 8e9574bc5..36e837692 100644 --- a/libempathy-gtk/empathy-presence-chooser.c +++ b/libempathy-gtk/empathy-presence-chooser.c @@ -47,6 +47,23 @@ #include "empathy-images.h" #include "empathy-presence-chooser.h" +/** + * SECTION:empathy-presence-chooser + * @title:EmpathyPresenceChooser + * @short_description: A widget used to change presence + * @include: libempathy-gtk/empathy-presence-chooser.h + * + * #EmpathyPresenceChooser is a widget which extends #GtkComboBoxEntry + * to change presence. + */ + +/** + * EmpathyAccountChooser: + * @parent: parent object + * + * Widget which extends #GtkComboBoxEntry to change presence. + */ + /* Flashing delay for icons (milliseconds). */ #define FLASH_TIMEOUT 500 @@ -789,6 +806,13 @@ presence_chooser_finalize (GObject *object) G_OBJECT_CLASS (empathy_presence_chooser_parent_class)->finalize (object); } +/** + * empathy_presence_chooser_new: + * + * Creates a new #EmpathyPresenceChooser widget. + * + * Return value: A new #EmpathyPresenceChooser widget + */ GtkWidget * empathy_presence_chooser_new (void) { @@ -946,6 +970,13 @@ presence_chooser_flash_stop (EmpathyPresenceChooser *chooser, empathy_icon_name_for_presence (state)); } +/** + * empathy_presence_chooser_create_menu: + * + * Creates a new #GtkMenu allowing users to change their presence from a menu. + * + * Return value: a new #GtkMenu for changing presence in a menu. + */ GtkWidget * empathy_presence_chooser_create_menu (void) { diff --git a/libempathy-gtk/empathy-presence-chooser.h b/libempathy-gtk/empathy-presence-chooser.h index 138e1dc7f..dab95f553 100644 --- a/libempathy-gtk/empathy-presence-chooser.h +++ b/libempathy-gtk/empathy-presence-chooser.h @@ -43,6 +43,8 @@ typedef struct _EmpathyPresenceChooserClass EmpathyPresenceChooserClass; struct _EmpathyPresenceChooser { GtkComboBoxEntry parent; + + /**/ gpointer priv; }; -- cgit v1.2.3 From 3b01b7ca985d788eca42749fd7a63c970b7ecde2 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Thu, 23 Apr 2009 00:44:36 +0100 Subject: Add documentation for EmpathyAvatarChooser. Signed-off-by: Jonny Lamb --- libempathy-gtk/empathy-avatar-chooser.c | 53 +++++++++++++++++++++++++++++++++ libempathy-gtk/empathy-avatar-chooser.h | 2 ++ 2 files changed, 55 insertions(+) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-avatar-chooser.c b/libempathy-gtk/empathy-avatar-chooser.c index a70befbc6..c86b85d25 100644 --- a/libempathy-gtk/empathy-avatar-chooser.c +++ b/libempathy-gtk/empathy-avatar-chooser.c @@ -39,6 +39,23 @@ #define DEBUG_FLAG EMPATHY_DEBUG_OTHER #include +/** + * SECTION:empathy-avatar-chooser + * @title: EmpathyAvatarChooser + * @short_description: A widget used to change avatar + * @include: libempathy-gtk/empathy-avatar-chooser.h + * + * #EmpathyAvatarChooser is a widget which extends #GtkButton to + * provide a way of changing avatar. + */ + +/** + * EmpathyAvatarChooser: + * @parent: parent object + * + * Widget which extends #GtkButton to provide a way of changing avatar. + */ + #define AVATAR_SIZE_SAVE 96 #define AVATAR_SIZE_VIEW 64 #define DEFAULT_DIR DATADIR"/pixmaps/faces" @@ -161,6 +178,13 @@ empathy_avatar_chooser_class_init (EmpathyAvatarChooserClass *klass) object_class->get_property = avatar_chooser_get_property; object_class->set_property = avatar_chooser_set_property; + /** + * EmpathyAvatarChooser::changed: + * @chooser: an #EmpathyAvatarChooser + * + * Emitted when the chosen avatar has changed. + * + */ signals[CHANGED] = g_signal_new ("changed", G_TYPE_FROM_CLASS (klass), @@ -170,6 +194,12 @@ empathy_avatar_chooser_class_init (EmpathyAvatarChooserClass *klass) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + /** + * EmpathyAvatarChooser:connection: + * + * The #TpConnection whose avatar should be shown and modified by + * the #EmpathyAvatarChooser instance. + */ param_spec = g_param_spec_object ("connection", "TpConnection", "TpConnection whose avatar should be " @@ -983,12 +1013,26 @@ avatar_chooser_clicked_cb (GtkWidget *button, g_free (saved_dir); } +/** + * empathy_avatar_chooser_new: + * + * Creates a new #EmpathyAvatarChooser. + * + * Return value: a new #EmpathyAvatarChooser + */ GtkWidget * empathy_avatar_chooser_new () { return g_object_new (EMPATHY_TYPE_AVATAR_CHOOSER, NULL); } +/** + * empathy_avatar_chooser_set: + * @chooser: an #EmpathyAvatarChooser + * @avatar: a new #EmpathyAvatar + * + * Sets the @chooser to display the avatar indicated by @avatar. + */ void empathy_avatar_chooser_set (EmpathyAvatarChooser *chooser, EmpathyAvatar *avatar) @@ -1002,6 +1046,15 @@ empathy_avatar_chooser_set (EmpathyAvatarChooser *chooser, } } +/** + * empathy_avatar_chooser_get_image_data: + * @chooser: an #EmpathyAvatarChooser + * @data: avatar bytes + * @data_size: size of @data + * @mime_type: avatar mime-type + * + * Gets image data about the currently selected avatar. + */ void empathy_avatar_chooser_get_image_data (EmpathyAvatarChooser *chooser, const gchar **data, diff --git a/libempathy-gtk/empathy-avatar-chooser.h b/libempathy-gtk/empathy-avatar-chooser.h index bdc5b40ae..564c1f37d 100644 --- a/libempathy-gtk/empathy-avatar-chooser.h +++ b/libempathy-gtk/empathy-avatar-chooser.h @@ -41,6 +41,8 @@ typedef struct _EmpathyAvatarChooserClass EmpathyAvatarChooserClass; struct _EmpathyAvatarChooser { GtkButton parent; + + /**/ gpointer priv; }; -- cgit v1.2.3 From 0913854d6a7d78e60a0d08897d6ba45140fd5237 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Thu, 23 Apr 2009 00:52:08 +0100 Subject: Add documentation for EmpathyAvatarImage. Signed-off-by: Jonny Lamb --- libempathy-gtk/empathy-avatar-image.c | 30 ++++++++++++++++++++++++++++++ libempathy-gtk/empathy-avatar-image.h | 2 ++ 2 files changed, 32 insertions(+) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-avatar-image.c b/libempathy-gtk/empathy-avatar-image.c index 51f30bdd5..e5513231b 100644 --- a/libempathy-gtk/empathy-avatar-image.c +++ b/libempathy-gtk/empathy-avatar-image.c @@ -33,6 +33,22 @@ #include "empathy-avatar-image.h" #include "empathy-ui-utils.h" +/** + * SECTION:empathy-avatar-image + * @title: EmpathyAvatarImage + * @short_description: A widget to display an avatar + * @include: libempathy-gtk/empathy-avatar-image.h + * + * #EmpathyAvatarImage is a widget which displays an avatar. + */ + +/** + * EmpathyAvatarImage: + * @parent: parent object + * + * Widget which displays an avatar. + */ + #define MAX_SMALL 64 #define MAX_LARGE 400 @@ -251,6 +267,13 @@ avatar_image_button_release_event (GtkWidget *widget, GdkEventButton *event) return TRUE; } +/** + * empathy_avatar_image_new: + * + * Creates a new #EmpathyAvatarImage. + * + * Return value: a new #EmpathyAvatarImage + */ GtkWidget * empathy_avatar_image_new (void) { @@ -261,6 +284,13 @@ empathy_avatar_image_new (void) return GTK_WIDGET (avatar_image); } +/** + * empathy_avatar_image_set: + * @avatar_image: an #EmpathyAvatarImage + * @avatar: the #EmpathyAvatar to set @avatar_image to + * + * Sets @avatar_image to display the avatar indicated by @avatar. + */ void empathy_avatar_image_set (EmpathyAvatarImage *avatar_image, EmpathyAvatar *avatar) diff --git a/libempathy-gtk/empathy-avatar-image.h b/libempathy-gtk/empathy-avatar-image.h index d6a6cd0b0..8969c1227 100644 --- a/libempathy-gtk/empathy-avatar-image.h +++ b/libempathy-gtk/empathy-avatar-image.h @@ -42,6 +42,8 @@ typedef struct _EmpathyAvatarImageClass EmpathyAvatarImageClass; struct _EmpathyAvatarImage { GtkEventBox parent; + + /**/ gpointer priv; }; -- cgit v1.2.3 From efc083f8db0c2116e05be9d894a0dbac39a5d433 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Thu, 23 Apr 2009 01:02:46 +0100 Subject: Add documentation for EmpathyProfileChooser. Signed-off-by: Jonny Lamb --- libempathy-gtk/empathy-profile-chooser.c | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-profile-chooser.c b/libempathy-gtk/empathy-profile-chooser.c index 897e38344..495956169 100644 --- a/libempathy-gtk/empathy-profile-chooser.c +++ b/libempathy-gtk/empathy-profile-chooser.c @@ -30,6 +30,16 @@ #include "empathy-profile-chooser.h" #include "empathy-ui-utils.h" +/** + * SECTION:empathy-profile-chooser + * @title: EmpathyProfileChooser + * @short_description: A widget used to choose from a list of profiles + * @include: libempathy-gtk/empathy-account-chooser.h + * + * #EmpathyProfileChooser is a widget which provides a chooser of available + * profiles. + */ + enum { COL_ICON, COL_LABEL, @@ -37,6 +47,14 @@ enum { COL_COUNT }; +/** + * empathy_profile_chooser_dup_selected: + * @widget: an #EmpathyProfileChooser + * + * Returns a new reference to the selected #McProfile in @widget. + * + * Return value: a new reference to the selected #McProfile + */ McProfile* empathy_profile_chooser_dup_selected (GtkWidget *widget) { @@ -54,6 +72,14 @@ empathy_profile_chooser_dup_selected (GtkWidget *widget) return profile; } +/** + * empathy_profile_chooser_n_profiles: + * @widget: an #EmpathyProfileChooser + * + * Returns the number of profiles in @widget. + * + * Return value: the number of profiles in @widget + */ gint empathy_profile_chooser_n_profiles (GtkWidget *widget) { @@ -115,6 +141,13 @@ profile_chooser_sort_func (GtkTreeModel *model, return cmp; } +/** + * empathy_profile_chooser_new: + * + * Creates a new #EmpathyProfileChooser widget. + * + * Return value: a new #EmpathyProfileChooser widget + */ GtkWidget * empathy_profile_chooser_new (void) { -- cgit v1.2.3 From 78f1e5cec3c97700d1ebd70fc949ba1ddf4ffa6b Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Thu, 23 Apr 2009 01:28:28 +0100 Subject: Add documentation for EmpathyNewMessageDialog. Signed-off-by: Jonny Lamb --- libempathy-gtk/empathy-new-message-dialog.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-new-message-dialog.c b/libempathy-gtk/empathy-new-message-dialog.c index b1a35095b..3e6e3f11d 100644 --- a/libempathy-gtk/empathy-new-message-dialog.c +++ b/libempathy-gtk/empathy-new-message-dialog.c @@ -44,6 +44,16 @@ #include "empathy-new-message-dialog.h" #include "empathy-account-chooser.h" +/** + * SECTION:empathy-new-message-dialog + * @title: EmpathyNewMessageDialog + * @short_description: A dialog to show a new message + * @include: libempathy-gtk/empathy-new-message-dialog.h + * + * #EmpathyNewMessageDialog is a dialog which allows a text chat or + * call to be started with any contact on any enabled account. + */ + typedef struct { GtkWidget *dialog; GtkWidget *table_contact; @@ -242,6 +252,14 @@ new_message_dialog_destroy_cb (GtkWidget *widget, g_free (dialog); } +/** + * empathy_new_message_dialog_show: + * @parent: parent #GtkWindow of the dialog + * + * Create a new #EmpathyNewMessageDialog and show it. + * + * Return value: the new #EmpathyNewMessageDialog + */ GtkWidget * empathy_new_message_dialog_show (GtkWindow *parent) { -- cgit v1.2.3 From 40b9a5d3b177c458555342a90a56934a40564f59 Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Thu, 23 Apr 2009 15:29:57 +0800 Subject: Fix function naming --- libempathy-gtk/empathy-status-preset-dialog.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-status-preset-dialog.c b/libempathy-gtk/empathy-status-preset-dialog.c index 085332f35..76ae06d40 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.c +++ b/libempathy-gtk/empathy-status-preset-dialog.c @@ -93,7 +93,7 @@ empathy_status_preset_dialog_class_init (EmpathyStatusPresetDialogClass *class) } static void -status_preset_dialog_setup_presets_update (EmpathyStatusPresetDialog *self) +status_preset_dialog_presets_update (EmpathyStatusPresetDialog *self) { EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self); GtkListStore *store; @@ -203,7 +203,7 @@ status_preset_dialog_setup_presets_treeview (EmpathyStatusPresetDialog *self) GTK_TREE_MODEL (store)); g_object_unref (store); - status_preset_dialog_setup_presets_update (self); + status_preset_dialog_presets_update (self); column = gtk_tree_view_column_new (); gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column); @@ -255,7 +255,7 @@ status_preset_dialog_preset_remove (GtkButton *button, g_free (status); - status_preset_dialog_setup_presets_update (self); + status_preset_dialog_presets_update (self); } static void @@ -349,7 +349,7 @@ status_preset_dialog_add_preset (GtkWidget *widget, DEBUG ("ADD PRESET (%i, %s)\n", state, status); empathy_status_presets_set_last (state, status); - status_preset_dialog_setup_presets_update (self); + status_preset_dialog_presets_update (self); status_preset_add_combo_reset (self); } -- cgit v1.2.3 From a41c75aceabdee7a14e54f5314d4cafc8eab9020 Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Thu, 23 Apr 2009 15:49:42 +0800 Subject: Make it possible to edit a status message by double-clicking on it --- libempathy-gtk/empathy-status-preset-dialog.c | 52 +++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-status-preset-dialog.c b/libempathy-gtk/empathy-status-preset-dialog.c index 76ae06d40..4913e4b86 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.c +++ b/libempathy-gtk/empathy-status-preset-dialog.c @@ -185,6 +185,53 @@ status_preset_dialog_setup_add_combobox (EmpathyStatusPresetDialog *self) gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0); } +static void +status_preset_dialog_status_edited (GtkCellRendererText *renderer, + char *path_str, + char *new_status, + EmpathyStatusPresetDialog *self) +{ + EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self); + GtkTreeModel *model; + GtkTreePath *path; + GtkTreeIter iter; + McPresence state; + char *old_status; + gboolean valid; + + if (strlen (new_status) == 0) { + /* status is empty, ignore */ + return; + } + + model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->presets_treeview)); + path = gtk_tree_path_new_from_string (path_str); + valid = gtk_tree_model_get_iter (model, &iter, path); + gtk_tree_path_free (path); + + if (!valid) return; + + gtk_tree_model_get (model, &iter, + PRESETS_STORE_STATE, &state, + PRESETS_STORE_STATUS, &old_status, + -1); + + if (!strcmp (old_status, new_status)) { + /* statuses are the same */ + g_free (old_status); + return; + } + + DEBUG ("EDITED STATUS (%s) -> (%s)\n", old_status, new_status); + + empathy_status_presets_remove (state, old_status); + empathy_status_presets_set_last (state, new_status); + + g_free (old_status); + + status_preset_dialog_presets_update (self); +} + static void status_preset_dialog_setup_presets_treeview (EmpathyStatusPresetDialog *self) { @@ -217,6 +264,11 @@ status_preset_dialog_setup_presets_treeview (EmpathyStatusPresetDialog *self) gtk_tree_view_column_pack_start (column, renderer, TRUE); gtk_tree_view_column_add_attribute (column, renderer, "text", PRESETS_STORE_STATUS); + g_object_set (renderer, + "editable", TRUE, + NULL); + g_signal_connect (renderer, "edited", + G_CALLBACK (status_preset_dialog_status_edited), self); } static void -- cgit v1.2.3 From 56beb181035248b4aff6927b3397708755ce6588 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Thu, 23 Apr 2009 10:03:06 +0100 Subject: Misc. gtk-doc updates, including being more explicit about refs. Signed-off-by: Jonny Lamb --- libempathy-gtk/empathy-account-chooser.c | 9 ++++++--- libempathy-gtk/empathy-contact-selector.c | 4 ++-- libempathy-gtk/empathy-contact-widget.h | 4 ++-- libempathy-gtk/empathy-profile-chooser.c | 3 ++- 4 files changed, 12 insertions(+), 8 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-account-chooser.c b/libempathy-gtk/empathy-account-chooser.c index aa6cf29e0..5d11e8e1e 100644 --- a/libempathy-gtk/empathy-account-chooser.c +++ b/libempathy-gtk/empathy-account-chooser.c @@ -254,7 +254,7 @@ empathy_account_chooser_new (void) * * Returns the account which is currently selected in the chooser or %NULL * if there is no account selected. The #McAccount returned should be - * unrefed when finished with. + * unrefed with g_object_unref() when finished with. * * Return value: a new ref to the #McAccount currently selected, or %NULL. */ @@ -284,9 +284,12 @@ empathy_account_chooser_dup_account (EmpathyAccountChooser *chooser) * empathy_account_chooser_get_connection: * @chooser: an #EmpathyAccountChooser * - * Returns the #TpConnection associated with the account currently selected. + * Returns a borrowed reference to the #TpConnection associated with the + * account currently selected. The caller must reference the returned object with + * g_object_ref() if it will be kept * - * Return value: the #TpConnection associated with the account curently selected. + * Return value: a borrowed reference to the #TpConnection associated with the + * account curently selected. */ TpConnection * empathy_account_chooser_get_connection (EmpathyAccountChooser *chooser) diff --git a/libempathy-gtk/empathy-contact-selector.c b/libempathy-gtk/empathy-contact-selector.c index a51d8d3fe..f4a302c5b 100644 --- a/libempathy-gtk/empathy-contact-selector.c +++ b/libempathy-gtk/empathy-contact-selector.c @@ -372,8 +372,8 @@ empathy_contact_selector_new (EmpathyContactList *contact_list) * @selector: An #EmpathyContactSelector * * Returns a new reference to the contact which is currently selected in - * @selector, or %NULL if there is no contact selected. The contact should - * be unrefed with g_object_unref() when finished with. + * @selector, or %NULL if there is no contact selected. The returned contact + * should be unrefed with g_object_unref() when finished with. * * Return value: A new reference to the contact currently selected, or %NULL */ diff --git a/libempathy-gtk/empathy-contact-widget.h b/libempathy-gtk/empathy-contact-widget.h index db739ad19..0da5580a3 100644 --- a/libempathy-gtk/empathy-contact-widget.h +++ b/libempathy-gtk/empathy-contact-widget.h @@ -47,8 +47,8 @@ G_BEGIN_DECLS * @EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP: Make widgets more designed for a tooltip. * For example, make widgets not selectable. * - * Options to instruct the #EmpathyContactWidget what features should be - * enabled. + * Flags used when creating an #EmpathyContactWidget to specify which features + * should be available. */ typedef enum { diff --git a/libempathy-gtk/empathy-profile-chooser.c b/libempathy-gtk/empathy-profile-chooser.c index 495956169..10eb3791a 100644 --- a/libempathy-gtk/empathy-profile-chooser.c +++ b/libempathy-gtk/empathy-profile-chooser.c @@ -51,7 +51,8 @@ enum { * empathy_profile_chooser_dup_selected: * @widget: an #EmpathyProfileChooser * - * Returns a new reference to the selected #McProfile in @widget. + * Returns a new reference to the selected #McProfile in @widget. The returned + * #McProfile should be unrefed with g_object_unref() when finished with. * * Return value: a new reference to the selected #McProfile */ -- cgit v1.2.3 From 84d5c65d562270af009173247b160732a5b1232d Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Thu, 23 Apr 2009 10:43:44 +0100 Subject: empathy-account-widget-irc: rename button_remove to button_remove_network so it has the same name as the UI id --- libempathy-gtk/empathy-account-widget-irc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-account-widget-irc.c b/libempathy-gtk/empathy-account-widget-irc.c index 4546cfd23..aa57fdc11 100644 --- a/libempathy-gtk/empathy-account-widget-irc.c +++ b/libempathy-gtk/empathy-account-widget-irc.c @@ -52,7 +52,7 @@ typedef struct { GtkWidget *combobox_network; GtkWidget *button_add_network; GtkWidget *button_network; - GtkWidget *button_remove; + GtkWidget *button_remove_network; } EmpathyAccountWidgetIrc; enum { @@ -464,7 +464,7 @@ empathy_account_widget_irc_new (McAccount *account) "combobox_network", &settings->combobox_network, "button_network", &settings->button_network, "button_add_network", &settings->button_add_network, - "button_remove_network", &settings->button_remove, + "button_remove_network", &settings->button_remove_network, NULL); g_free (filename); -- cgit v1.2.3 From 2f154e3477a56517bbcbcabb6684b0989e95995e Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Thu, 23 Apr 2009 10:52:53 +0100 Subject: empathy-account-widget-irc: remove unused widgets --- libempathy-gtk/empathy-account-widget-irc.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-account-widget-irc.c b/libempathy-gtk/empathy-account-widget-irc.c index aa57fdc11..cc86a5aaa 100644 --- a/libempathy-gtk/empathy-account-widget-irc.c +++ b/libempathy-gtk/empathy-account-widget-irc.c @@ -50,9 +50,6 @@ typedef struct { GtkWidget *vbox_settings; GtkWidget *combobox_network; - GtkWidget *button_add_network; - GtkWidget *button_network; - GtkWidget *button_remove_network; } EmpathyAccountWidgetIrc; enum { @@ -462,9 +459,6 @@ empathy_account_widget_irc_new (McAccount *account) gui = empathy_builder_get_file (filename, "vbox_irc_settings", &settings->vbox_settings, "combobox_network", &settings->combobox_network, - "button_network", &settings->button_network, - "button_add_network", &settings->button_add_network, - "button_remove_network", &settings->button_remove_network, NULL); g_free (filename); -- cgit v1.2.3 From 88e713991752dfccebc37309571384165d557d6c Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Thu, 23 Apr 2009 19:20:44 +0800 Subject: gtk-doc entry --- libempathy-gtk/empathy-status-preset-dialog.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-status-preset-dialog.c b/libempathy-gtk/empathy-status-preset-dialog.c index 4913e4b86..562b9e4d9 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.c +++ b/libempathy-gtk/empathy-status-preset-dialog.c @@ -498,6 +498,15 @@ empathy_status_preset_dialog_init (EmpathyStatusPresetDialog *self) g_object_unref (gui); } +/** + * empathy_status_preset_dialog_new: + * @parent: the parent window of this dialog (or NULL) + * + * Creates a new #EmpathyStatusPresetDialog that allows the user to + * add/remove/edit their saved status messages. + * + * Returns: the newly constructed dialog. + */ GtkWidget * empathy_status_preset_dialog_new (GtkWindow *parent) { -- cgit v1.2.3 From 7a94f85d284baebdd3bbc0607205d3ced82748a2 Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Thu, 23 Apr 2009 19:30:48 +0800 Subject: Sort presets alphabetically in the list --- libempathy-gtk/empathy-presence-chooser.c | 3 ++- libempathy-gtk/empathy-status-preset-dialog.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-presence-chooser.c b/libempathy-gtk/empathy-presence-chooser.c index d565cf387..d97abea0c 100644 --- a/libempathy-gtk/empathy-presence-chooser.c +++ b/libempathy-gtk/empathy-presence-chooser.c @@ -170,7 +170,8 @@ presence_chooser_create_model (EmpathyPresenceChooser *self) if (states[i+1]) { /* Set custom messages if wanted */ - list = empathy_status_presets_get (states[i], 5); + list = empathy_status_presets_get (states[i], -1); + list = g_list_sort (list, (GCompareFunc) g_utf8_collate); for (l = list; l; l = l->next) { gtk_list_store_insert_with_values (store, NULL, -1, diff --git a/libempathy-gtk/empathy-status-preset-dialog.c b/libempathy-gtk/empathy-status-preset-dialog.c index 562b9e4d9..d8416a585 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.c +++ b/libempathy-gtk/empathy-status-preset-dialog.c @@ -108,8 +108,9 @@ status_preset_dialog_presets_update (EmpathyStatusPresetDialog *self) GList *presets, *l; const char *icon_name; - presets = empathy_status_presets_get (states[i], -1); icon_name = empathy_icon_name_for_presence (states[i]); + presets = empathy_status_presets_get (states[i], -1); + presets = g_list_sort (presets, (GCompareFunc) g_utf8_collate); for (l = presets; l; l = l->next) { char *preset = (char *) l->data; -- cgit v1.2.3 From e1a592f9b27d98b4bf6c8f05fb2c524a177f185e Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Thu, 23 Apr 2009 19:33:42 +0800 Subject: Add a comment for cassidy ;-) --- libempathy-gtk/empathy-status-preset-dialog.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-status-preset-dialog.c b/libempathy-gtk/empathy-status-preset-dialog.c index d8416a585..0fe577d97 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.c +++ b/libempathy-gtk/empathy-status-preset-dialog.c @@ -54,6 +54,7 @@ static McPresence states[] = { typedef struct _EmpathyStatusPresetDialogPriv EmpathyStatusPresetDialogPriv; struct _EmpathyStatusPresetDialogPriv { + /* block status_preset_dialog_add_combo_changed() when > 0 */ int block_add_combo_changed; GtkWidget *presets_treeview; -- cgit v1.2.3 From 5b4b6de8f4bc1484184ee469e1c976e1e7d96034 Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Thu, 23 Apr 2009 19:47:52 +0800 Subject: Preserve the status message across combo box changes --- libempathy-gtk/empathy-status-preset-dialog.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-status-preset-dialog.c b/libempathy-gtk/empathy-status-preset-dialog.c index 0fe577d97..f7171e4ef 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.c +++ b/libempathy-gtk/empathy-status-preset-dialog.c @@ -63,6 +63,7 @@ struct _EmpathyStatusPresetDialogPriv GtkTreeIter selected_iter; gboolean add_combo_changed; + char *saved_status; }; enum @@ -82,12 +83,23 @@ enum ADD_COMBO_N_COLS }; +static void +empathy_status_preset_dialog_finalize (GObject *self) +{ + EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self); + + g_free (priv->saved_status); + + G_OBJECT_CLASS (empathy_status_preset_dialog_parent_class)->finalize (self); +} + static void empathy_status_preset_dialog_class_init (EmpathyStatusPresetDialogClass *class) { GObjectClass *gobject_class; gobject_class = G_OBJECT_CLASS (class); + gobject_class->finalize = empathy_status_preset_dialog_finalize; g_type_class_add_private (gobject_class, sizeof (EmpathyStatusPresetDialogPriv)); @@ -371,12 +383,17 @@ status_preset_dialog_add_combo_changed (GtkComboBox *combo, g_free (icon_name); status_preset_dialog_set_add_combo_changed (self, FALSE, TRUE); + if (priv->saved_status && strlen (priv->saved_status) > 0) { + gtk_entry_set_text (GTK_ENTRY (entry), + priv->saved_status); + } } else { - const char *status; + g_free (priv->saved_status); + priv->saved_status = g_strdup ( + gtk_entry_get_text (GTK_ENTRY (entry))); - status = gtk_entry_get_text (GTK_ENTRY (entry)); status_preset_dialog_set_add_combo_changed (self, - strlen (status) > 0, FALSE); + strlen (priv->saved_status) > 0, FALSE); } } -- cgit v1.2.3 From 2315303fa0d4cf3532a9a1e63e7bb118b386c48c Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Thu, 23 Apr 2009 20:00:48 +0800 Subject: Rest of gtk-doc --- libempathy-gtk/empathy-status-preset-dialog.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-status-preset-dialog.c b/libempathy-gtk/empathy-status-preset-dialog.c index f7171e4ef..734ac356a 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.c +++ b/libempathy-gtk/empathy-status-preset-dialog.c @@ -24,6 +24,15 @@ * * Authors: Davyd Madeley */ +/** + * SECTION:empathy-status-preset-dialog + * @title: EmpathyStatusPresetDialog + * @short_description: a dialog for editing the saved status messages + * @include: libempathy-gtk/empathy-status-preset-dialog.h + * + * #EmpathyStatusPresetDialog is a dialog allowing the user to add/remove/edit + * their saved status messages. + */ #include "config.h" -- cgit v1.2.3 From 56c5e3c45349484a703d9df03d3969edde121a1e Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Thu, 23 Apr 2009 16:34:38 +0100 Subject: empathy-contact-widget: call contact_widget_change_contact after widget's setup. Fixes #579971 --- libempathy-gtk/empathy-contact-widget.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c index c78aafeaa..0821066fa 100644 --- a/libempathy-gtk/empathy-contact-widget.c +++ b/libempathy-gtk/empathy-contact-widget.c @@ -234,7 +234,11 @@ empathy_contact_widget_new (EmpathyContact *contact, contact_widget_client_setup (information); if (contact != NULL) - contact_widget_set_contact (information, contact); + contact_widget_set_contact (information, contact); + + else if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT || + information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID) + contact_widget_change_contact (information); return empathy_builder_unref_and_keep_widget (gui, information->vbox_contact_widget); @@ -561,7 +565,6 @@ contact_widget_contact_setup (EmpathyContactWidget *information) { information->widget_account = empathy_account_chooser_new (); - contact_widget_change_contact (information); g_signal_connect_swapped (information->widget_account, "changed", G_CALLBACK (contact_widget_change_contact), information); -- cgit v1.2.3 From 6856c3dc3bdac6d7690d450e69ab66e3d9fa7fb4 Mon Sep 17 00:00:00 2001 From: Adam Schreiber Date: Fri, 24 Apr 2009 08:47:45 +0800 Subject: Fixes based on feedback Some cleanup still required, done by Davyd Madeley --- libempathy-gtk/empathy-chat.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index dea3b874c..8b69fa815 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -595,7 +595,7 @@ chat_property_changed_cb (EmpathyTpChat *tp_chat, static void chat_input_text_buffer_changed_cb (GtkTextBuffer *buffer, - EmpathyChat *chat) + EmpathyChat *chat) { EmpathyChatPriv *priv; GtkTextIter start, end; @@ -611,8 +611,8 @@ chat_input_text_buffer_changed_cb (GtkTextBuffer *buffer, } empathy_conf_get_bool (empathy_conf_get (), - EMPATHY_PREFS_CHAT_SPELL_CHECKER_ENABLED, - &spell_checker); + EMPATHY_PREFS_CHAT_SPELL_CHECKER_ENABLED, + &spell_checker); gtk_text_buffer_get_start_iter (buffer, &start); @@ -934,10 +934,10 @@ static void chat_spelling_menu_activate_cb (GtkMenuItem *menu_item, EmpathyChatSpell *chat_spell) { - empathy_chat_correct_word (chat_spell->chat, - &(chat_spell->start), - &(chat_spell->end), - gtk_menu_item_get_label(menu_item)); + empathy_chat_correct_word (chat_spell->chat, + &(chat_spell->start), + &(chat_spell->end), + gtk_menu_item_get_label (menu_item)); } static GtkWidget* @@ -946,17 +946,22 @@ chat_spelling_build_menu (EmpathyChatSpell *chat_spell) GtkWidget *menu, *menu_item; GList *suggestions, *l; - menu = gtk_menu_new(); + menu = gtk_menu_new (); suggestions = empathy_spell_get_suggestions (chat_spell->word); - for (l = suggestions; l; l=l->next) { - menu_item = gtk_menu_item_new_with_label (l->data); - g_signal_connect (G_OBJECT (menu_item), - "activate", - G_CALLBACK (chat_spelling_menu_activate_cb), - chat_spell); + if (suggestions == NULL) { + menu_item = gtk_menu_item_new_with_label (_("(No Suggestions)")); + gtk_widget_set_sensitive (menu_item, FALSE); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); - } - + } else { + for (l = suggestions; l; l = l->next) { + menu_item = gtk_menu_item_new_with_label (l->data); + g_signal_connect (G_OBJECT (menu_item), + "activate", + G_CALLBACK (chat_spelling_menu_activate_cb), + chat_spell); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); + } + } empathy_spell_free_suggestions (suggestions); gtk_widget_show_all (menu); @@ -1050,7 +1055,7 @@ chat_input_populate_popup_cb (GtkTextView *view, gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); - item = gtk_image_menu_item_new_with_mnemonic (_("_Spelling Suggestions...")); + item = gtk_image_menu_item_new_with_mnemonic (_("_Spelling Suggestions")); image = gtk_image_new_from_icon_name (GTK_STOCK_SPELL_CHECK, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); -- cgit v1.2.3 From 9470af93eb777cc4054389a09c19bdff7d491946 Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Fri, 24 Apr 2009 08:50:49 +0800 Subject: Fix trailing whitespace --- libempathy-gtk/empathy-chat.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index 8b69fa815..c8ec59f1b 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -945,7 +945,7 @@ chat_spelling_build_menu (EmpathyChatSpell *chat_spell) { GtkWidget *menu, *menu_item; GList *suggestions, *l; - + menu = gtk_menu_new (); suggestions = empathy_spell_get_suggestions (chat_spell->word); if (suggestions == NULL) { @@ -963,9 +963,9 @@ chat_spelling_build_menu (EmpathyChatSpell *chat_spell) } } empathy_spell_free_suggestions (suggestions); - + gtk_widget_show_all (menu); - + return menu; } @@ -1059,10 +1059,10 @@ chat_input_populate_popup_cb (GtkTextView *view, image = gtk_image_new_from_icon_name (GTK_STOCK_SPELL_CHECK, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); - + spell_menu = chat_spelling_build_menu (chat_spell); gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), spell_menu); - + gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); } -- cgit v1.2.3 From e792e16499f942c6669ce12417118968a71a75c0 Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Fri, 24 Apr 2009 08:52:24 +0800 Subject: Remove spell dialog from POTFILES.in; remove GtkBuilder file --- libempathy-gtk/empathy-spell-dialog.ui | 131 --------------------------------- 1 file changed, 131 deletions(-) delete mode 100644 libempathy-gtk/empathy-spell-dialog.ui (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-spell-dialog.ui b/libempathy-gtk/empathy-spell-dialog.ui deleted file mode 100644 index 382346c1a..000000000 --- a/libempathy-gtk/empathy-spell-dialog.ui +++ /dev/null @@ -1,131 +0,0 @@ - - - - - 5 - Spell Checker - True - GTK_WIN_POS_CENTER_ON_PARENT - 275 - 225 - GDK_WINDOW_TYPE_HINT_DIALOG - False - - - True - 2 - - - True - 5 - 6 - - - True - 0 - Suggestions for the word: - True - True - - - False - False - - - - - True - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - - - True - True - False - - - - - 1 - - - - - 1 - - - - - True - GTK_BUTTONBOX_END - - - True - True - True - gtk-cancel - True - - - - - True - False - True - True - - - True - 0 - 0 - - - True - 2 - - - True - gtk-convert - - - False - False - - - - - True - _Replace - True - - - False - False - 1 - - - - - - - - - 1 - - - - - False - GTK_PACK_END - - - - - - button_cancel - button_replace - - - -- cgit v1.2.3