diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2009-11-17 20:16:31 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2010-01-11 18:58:34 +0800 |
commit | b24ca484fb47cc6acc7585fb56377e7b3e6a71cf (patch) | |
tree | f4052e2bb8c0d0b26a0d378829759b7d555eab64 | |
parent | 309dc2bba3edec26b99cb9cce97802d280090916 (diff) | |
download | gsoc2013-empathy-b24ca484fb47cc6acc7585fb56377e7b3e6a71cf.tar gsoc2013-empathy-b24ca484fb47cc6acc7585fb56377e7b3e6a71cf.tar.gz gsoc2013-empathy-b24ca484fb47cc6acc7585fb56377e7b3e6a71cf.tar.bz2 gsoc2013-empathy-b24ca484fb47cc6acc7585fb56377e7b3e6a71cf.tar.lz gsoc2013-empathy-b24ca484fb47cc6acc7585fb56377e7b3e6a71cf.tar.xz gsoc2013-empathy-b24ca484fb47cc6acc7585fb56377e7b3e6a71cf.tar.zst gsoc2013-empathy-b24ca484fb47cc6acc7585fb56377e7b3e6a71cf.zip |
accounts-dialog: inherit from GtkDialog (#600023)
-rw-r--r-- | src/empathy-accounts-dialog.c | 156 | ||||
-rw-r--r-- | src/empathy-accounts-dialog.h | 4 | ||||
-rw-r--r-- | src/empathy-accounts-dialog.ui | 376 |
3 files changed, 244 insertions, 292 deletions
diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 88f5e0a73..0f6a283e4 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -69,13 +69,11 @@ _("Your new account has not been saved yet.") #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountsDialog) -G_DEFINE_TYPE (EmpathyAccountsDialog, empathy_accounts_dialog, G_TYPE_OBJECT); +G_DEFINE_TYPE (EmpathyAccountsDialog, empathy_accounts_dialog, GTK_TYPE_DIALOG); static EmpathyAccountsDialog *dialog_singleton = NULL; typedef struct { - GtkWidget *window; - GtkWidget *alignment_settings; GtkWidget *alignment_infobar; @@ -127,7 +125,7 @@ typedef struct { gboolean force_change_row; GtkTreeRowReference *destination_row; - + gboolean dispose_has_run; } EmpathyAccountsDialogPriv; enum { @@ -567,9 +565,8 @@ accounts_dialog_show_question_dialog (EmpathyAccountsDialog *dialog, va_list button_args; GtkWidget *message_dialog; const gchar *button_text; - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); - message_dialog = gtk_message_dialog_new (GTK_WINDOW (priv->window), + message_dialog = gtk_message_dialog_new (GTK_WINDOW (dialog), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, @@ -1490,20 +1487,12 @@ accounts_dialog_account_enabled_cb (TpAccountManager *manager, } static void -accounts_dialog_button_help_clicked_cb (GtkWidget *button, - EmpathyAccountsDialog *dialog) -{ - empathy_url_show (button, "ghelp:empathy?accounts-window"); -} - -static void accounts_dialog_button_import_clicked_cb (GtkWidget *button, EmpathyAccountsDialog *dialog) { - EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); GtkWidget *import_dialog; - import_dialog = empathy_import_dialog_new (GTK_WINDOW (priv->window), + import_dialog = empathy_import_dialog_new (GTK_WINDOW (dialog), FALSE); gtk_widget_show (import_dialog); } @@ -1521,33 +1510,6 @@ accounts_dialog_close_response_cb (GtkDialog *message_dialog, gtk_widget_destroy (account_dialog); } -static void -accounts_dialog_response_cb (GtkWidget *widget, - gint response, - EmpathyAccountsDialog *dialog) -{ - TpAccount *account = NULL; - - if (accounts_dialog_has_pending_change (dialog, &account)) - { - gchar *question_dialog_primary_text = get_dialog_primary_text (account); - - accounts_dialog_show_question_dialog (dialog, - question_dialog_primary_text, - _("You are about to close the window, which will discard\n" - "your changes. Are you sure you want to proceed?"), - G_CALLBACK (accounts_dialog_close_response_cb), - widget, - GTK_STOCK_CANCEL, GTK_RESPONSE_NO, - GTK_STOCK_DISCARD, GTK_RESPONSE_YES, NULL); - - g_free (question_dialog_primary_text); - } - else if (response == GTK_RESPONSE_CLOSE || - response == GTK_RESPONSE_DELETE_EVENT) - gtk_widget_destroy (widget); -} - static gboolean accounts_dialog_delete_event_cb (GtkWidget *widget, GdkEvent *event, @@ -1558,15 +1520,6 @@ accounts_dialog_delete_event_cb (GtkWidget *widget, } static void -accounts_dialog_destroy_cb (GtkObject *obj, - EmpathyAccountsDialog *dialog) -{ - DEBUG ("%p", obj); - - g_object_unref (dialog); -} - -static void accounts_dialog_set_selected_account (EmpathyAccountsDialog *dialog, TpAccount *account) { @@ -1659,20 +1612,58 @@ accounts_dialog_manager_ready_cb (GObject *source_object, } static void +dialog_response_cb (GtkWidget *widget, + gint response_id, + gpointer user_data) +{ + EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (widget); + + if (response_id == GTK_RESPONSE_HELP) + { + empathy_url_show (widget, "ghelp:empathy?accounts-window"); + } + else if (response_id == GTK_RESPONSE_CLOSE || + response_id == GTK_RESPONSE_DELETE_EVENT) + { + TpAccount *account = NULL; + + if (accounts_dialog_has_pending_change (dialog, &account)) + { + gchar *question_dialog_primary_text = get_dialog_primary_text ( + account); + + accounts_dialog_show_question_dialog (dialog, + question_dialog_primary_text, + _("You are about to close the window, which will discard\n" + "your changes. Are you sure you want to proceed?"), + G_CALLBACK (accounts_dialog_close_response_cb), + widget, + GTK_STOCK_CANCEL, GTK_RESPONSE_NO, + GTK_STOCK_DISCARD, GTK_RESPONSE_YES, NULL); + + g_free (question_dialog_primary_text); + } + else + { + gtk_widget_destroy (widget); + } + } +} + +static void accounts_dialog_build_ui (EmpathyAccountsDialog *dialog) { + GtkWidget *top_hbox; GtkBuilder *gui; gchar *filename; EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); GtkWidget *content_area; -#ifdef HAVE_MOBLIN - GtkWidget *action_area; -#endif + GtkWidget *action_area; filename = empathy_file_lookup ("empathy-accounts-dialog.ui", "src"); gui = empathy_builder_get_file (filename, - "accounts_dialog", &priv->window, + "accounts_dialog_hbox", &top_hbox, "vbox_details", &priv->vbox_details, "frame_no_protocol", &priv->frame_no_protocol, "alignment_settings", &priv->alignment_settings, @@ -1687,18 +1678,19 @@ accounts_dialog_build_ui (EmpathyAccountsDialog *dialog) g_free (filename); empathy_builder_connect (gui, dialog, - "accounts_dialog", "response", accounts_dialog_response_cb, - "accounts_dialog", "destroy", accounts_dialog_destroy_cb, - "accounts_dialog", "delete-event", accounts_dialog_delete_event_cb, "button_add", "clicked", accounts_dialog_button_add_clicked_cb, - "button_help", "clicked", accounts_dialog_button_help_clicked_cb, "button_import", "clicked", accounts_dialog_button_import_clicked_cb, NULL); + content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); + + gtk_container_add (GTK_CONTAINER (content_area), top_hbox); + g_object_unref (gui); + action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog)); + #ifdef HAVE_MOBLIN - action_area = gtk_dialog_get_action_area (GTK_DIALOG (priv->window)); gtk_widget_hide (action_area); #endif @@ -1710,7 +1702,7 @@ accounts_dialog_build_ui (EmpathyAccountsDialog *dialog) dialog); if (priv->parent_window) - gtk_window_set_transient_for (GTK_WINDOW (priv->window), + gtk_window_set_transient_for (GTK_WINDOW (dialog), priv->parent_window); /* set up spinner */ @@ -1734,6 +1726,30 @@ accounts_dialog_build_ui (EmpathyAccountsDialog *dialog) gtk_box_pack_start (GTK_BOX (content_area), priv->image_status, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (content_area), priv->label_status); + + /* Tweak the dialog */ + gtk_window_set_title (GTK_WINDOW (dialog), _("Accounts")); + gtk_window_set_role (GTK_WINDOW (dialog), "accounts"); + + gtk_window_set_default_size (GTK_WINDOW (dialog), 640, -1); + + gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_DIALOG); + + gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); + + /* add dialog buttons */ + gtk_button_box_set_layout (GTK_BUTTON_BOX (action_area), GTK_BUTTONBOX_END); + + gtk_dialog_add_buttons (GTK_DIALOG (dialog), + GTK_STOCK_HELP, GTK_RESPONSE_HELP, + GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, + NULL); + + g_signal_connect (dialog, "response", + G_CALLBACK (dialog_response_cb), dialog); + + g_signal_connect (dialog, "delete-event", + G_CALLBACK (accounts_dialog_delete_event_cb), dialog); } static void @@ -1742,6 +1758,11 @@ do_dispose (GObject *obj) EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (obj); EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + if (priv->dispose_has_run) + return; + + priv->dispose_has_run = TRUE; + /* Disconnect signals */ g_signal_handlers_disconnect_by_func (priv->account_manager, accounts_dialog_account_validity_changed_cb, @@ -1791,7 +1812,6 @@ do_constructor (GType type, if (dialog_singleton) { retval = G_OBJECT (dialog_singleton); - g_object_ref (retval); } else { @@ -1801,9 +1821,6 @@ do_constructor (GType type, dialog_singleton = EMPATHY_ACCOUNTS_DIALOG (retval); g_object_add_weak_pointer (retval, (gpointer) &dialog_singleton); - /* We add an extra reference that we'll release when the dialog is - * destroyed (accounts_dialog_destroy_cb) */ - g_object_ref (retval); } return retval; @@ -1874,7 +1891,7 @@ do_constructed (GObject *object) empathy_conf_set_bool (empathy_conf_get (), EMPATHY_PREFS_IMPORT_ASKED, TRUE); - import_dialog = empathy_import_dialog_new (GTK_WINDOW (priv->window), + import_dialog = empathy_import_dialog_new (GTK_WINDOW (dialog), FALSE); gtk_widget_show (import_dialog); } @@ -1938,10 +1955,7 @@ empathy_accounts_dialog_show (GtkWindow *parent, priv->initial_selection = g_object_ref (selected_account); } - gtk_window_present (GTK_WINDOW (priv->window)); - /* EmpathyAccountsDialog kepts a ref on itself until the dialog is - * destroyed so we can release the ref returned by the constructor now. */ - g_object_unref (dialog); + gtk_window_present (GTK_WINDOW (dialog)); - return priv->window; + return GTK_WIDGET (dialog); } diff --git a/src/empathy-accounts-dialog.h b/src/empathy-accounts-dialog.h index 2d9d60c2b..6decad71d 100644 --- a/src/empathy-accounts-dialog.h +++ b/src/empathy-accounts-dialog.h @@ -43,14 +43,14 @@ G_BEGIN_DECLS (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_ACCOUNTS_DIALOG, EmpathyAccountsDialogClass)) typedef struct { - GObject parent; + GtkDialog parent; /* private */ gpointer priv; } EmpathyAccountsDialog; typedef struct { - GObjectClass parent_class; + GtkDialogClass parent_class; } EmpathyAccountsDialogClass; GType empathy_accounts_dialog_get_type (void); diff --git a/src/empathy-accounts-dialog.ui b/src/empathy-accounts-dialog.ui index 1f60bd6fa..35876ceb3 100644 --- a/src/empathy-accounts-dialog.ui +++ b/src/empathy-accounts-dialog.ui @@ -2,76 +2,138 @@ <interface> <requires lib="gtk+" version="2.16"/> <!-- interface-naming-policy toplevel-contextual --> - <object class="GtkDialog" id="accounts_dialog"> - <property name="border_width">5</property> - <property name="title" translatable="yes">Accounts</property> - <property name="role">accounts</property> - <property name="default_width">640</property> - <property name="type_hint">dialog</property> - <property name="has_separator">False</property> - <child internal-child="vbox"> - <object class="GtkVBox" id="dialog-vbox3"> + <object class="GtkHBox" id="accounts_dialog_hbox"> + <property name="visible">True</property> + <property name="border_width">6</property> + <property name="spacing">18</property> + <child> + <object class="GtkVBox" id="vbox195"> <property name="visible">True</property> - <property name="spacing">2</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> <child> - <object class="GtkHBox" id="hbox146"> + <object class="GtkScrolledWindow" id="scrolledwindow17"> + <property name="height_request">200</property> <property name="visible">True</property> - <property name="border_width">6</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">never</property> + <property name="vscrollbar_policy">automatic</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="treeview"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="enable_search">False</property> + </object> + </child> + </object> + <packing> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkVBox" id="vbox1"> + <property name="visible">True</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <property name="homogeneous">True</property> + <child> + <object class="GtkButton" id="button_add"> + <property name="label" translatable="yes">_Add…</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="image">add_image</property> + <property name="use_underline">True</property> + </object> + <packing> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="button_import"> + <property name="label" translatable="yes">_Import…</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_underline">True</property> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkVBox" id="vbox214"> + <property name="visible">True</property> + <property name="orientation">vertical</property> + <property name="spacing">18</property> + <child> + <object class="GtkHBox" id="hbox_protocol"> + <property name="visible">True</property> + <property name="spacing">6</property> + <child> + <object class="GtkLabel" id="label_protocol"> + <property name="visible">True</property> + <property name="label" translatable="yes">Protocol:</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkVBox" id="vbox_details"> + <property name="visible">True</property> + <property name="orientation">vertical</property> <property name="spacing">18</property> <child> - <object class="GtkVBox" id="vbox195"> + <object class="GtkHBox" id="hbox183"> <property name="visible">True</property> <property name="spacing">6</property> <child> - <object class="GtkScrolledWindow" id="scrolledwindow17"> - <property name="height_request">200</property> + <object class="GtkLabel" id="label_name"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="hscrollbar_policy">never</property> - <property name="vscrollbar_policy">automatic</property> - <property name="shadow_type">in</property> - <child> - <object class="GtkTreeView" id="treeview"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="enable_search">False</property> - </object> - </child> + <property name="selectable">True</property> + <attributes> + <attribute name="weight" value="bold"/> + <attribute name="scale" value="1,000000"/> + </attributes> </object> <packing> <property name="position">0</property> </packing> </child> <child> - <object class="GtkVBox" id="vbox1"> + <object class="GtkImage" id="image_type"> <property name="visible">True</property> - <property name="orientation">vertical</property> - <property name="spacing">6</property> - <property name="homogeneous">True</property> - <child> - <object class="GtkButton" id="button_add"> - <property name="label" translatable="yes">_Add…</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="image">add_image</property> - <property name="use_underline">True</property> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkButton" id="button_import"> - <property name="label" translatable="yes">_Import…</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="use_underline">True</property> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> + <property name="yalign">0</property> + <property name="stock">gtk-cut</property> + <property name="icon-size">6</property> </object> <packing> <property name="expand">False</property> @@ -87,146 +149,28 @@ </packing> </child> <child> - <object class="GtkVBox" id="vbox214"> + <object class="GtkAlignment" id="alignment_infobar"> <property name="visible">True</property> - <property name="spacing">18</property> - <child> - <object class="GtkHBox" id="hbox_protocol"> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <object class="GtkLabel" id="label_protocol"> - <property name="visible">True</property> - <property name="label" translatable="yes">Protocol:</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkVBox" id="vbox_details"> - <property name="visible">True</property> - <property name="spacing">18</property> - <child> - <object class="GtkHBox" id="hbox183"> - <property name="visible">True</property> - <property name="spacing">6</property> - <child> - <object class="GtkLabel" id="label_name"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="selectable">True</property> - <attributes> - <attribute name="weight" value="bold"/> - <attribute name="scale" value="1,000000"/> - </attributes> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkImage" id="image_type"> - <property name="visible">True</property> - <property name="yalign">0</property> - <property name="stock">gtk-cut</property> - <property name="icon-size">6</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment_infobar"> - <property name="visible">True</property> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment_settings"> - <property name="visible">True</property> - <property name="top_padding">6</property> - <property name="left_padding">20</property> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="position">2</property> - </packing> - </child> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> <child> - <object class="GtkFrame" id="frame_no_protocol"> - <property name="label_xalign">0</property> - <property name="shadow_type">none</property> - <child> - <object class="GtkAlignment" id="alignment21"> - <property name="visible">True</property> - <property name="top_padding">6</property> - <property name="left_padding">12</property> - <child> - <object class="GtkLabel" id="label2"> - <property name="visible">True</property> - <property name="label" translatable="yes">To add a new account, you first have to install a backend for each protocol you want to use.</property> - <property name="wrap">True</property> - </object> - </child> - </object> - </child> - <child type="label"> - <object class="GtkLabel" id="label_no_protocol"> - <property name="visible">True</property> - <property name="label" translatable="yes">No protocol installed</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">2</property> - </packing> + <placeholder/> </child> + </object> + <packing> + <property name="expand">False</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkAlignment" id="alignment_settings"> + <property name="visible">True</property> + <property name="top_padding">6</property> + <property name="left_padding">20</property> <child> <placeholder/> </child> </object> <packing> - <property name="position">1</property> + <property name="position">2</property> </packing> </child> </object> @@ -234,54 +178,48 @@ <property name="position">1</property> </packing> </child> - <child internal-child="action_area"> - <object class="GtkHButtonBox" id="dialog-action_area"> - <property name="visible">True</property> - <property name="layout_style">end</property> + <child> + <object class="GtkFrame" id="frame_no_protocol"> + <property name="label_xalign">0</property> + <property name="shadow_type">none</property> <child> - <object class="GtkButton" id="button_help"> - <property name="label">gtk-help</property> + <object class="GtkAlignment" id="alignment21"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="receives_default">False</property> - <property name="use_stock">True</property> + <property name="top_padding">6</property> + <property name="left_padding">12</property> + <child> + <object class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="label" translatable="yes">To add a new account, you first have to install a backend for each protocol you want to use.</property> + <property name="wrap">True</property> + </object> + </child> </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - <property name="secondary">True</property> - </packing> </child> - <child> - <object class="GtkButton" id="button_close"> - <property name="label">gtk-close</property> + <child type="label"> + <object class="GtkLabel" id="label_no_protocol"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="receives_default">False</property> - <property name="use_stock">True</property> + <property name="label" translatable="yes">No protocol installed</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> </child> </object> <packing> <property name="expand">False</property> - <property name="pack_type">end</property> - <property name="position">0</property> + <property name="fill">False</property> + <property name="position">2</property> </packing> </child> + <child> + <placeholder/> + </child> </object> + <packing> + <property name="position">1</property> + </packing> </child> - <action-widgets> - <action-widget response="-11">button_help</action-widget> - <action-widget response="-7">button_close</action-widget> - </action-widgets> </object> <object class="GtkImage" id="add_image"> <property name="stock">gtk-add</property> |