X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fhildon2%2Fmodest-connection-specific-smtp-window.c;h=2de48967621b2c920e73eb80c807f5eea23ae3dd;hb=54468304d70281e5847f1d92acd70c4a758e97a1;hp=3f98dedd031a59ab82affea6c3d21326415ff0f2;hpb=a7be4d9c27d5a6074f3a1701b12bcc2c45887022;p=modest diff --git a/src/hildon2/modest-connection-specific-smtp-window.c b/src/hildon2/modest-connection-specific-smtp-window.c index 3f98ded..2de4896 100644 --- a/src/hildon2/modest-connection-specific-smtp-window.c +++ b/src/hildon2/modest-connection-specific-smtp-window.c @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include #include @@ -63,7 +63,6 @@ struct _ModestConnectionSpecificSmtpWindowPrivate { GtkTreeView *treeview; GtkTreeModel *model; - GtkWidget *button_edit; ModestAccountMgr *account_manager; }; @@ -209,7 +208,8 @@ modest_connection_specific_smtp_window_fill_with_connections (ModestConnectionSp MODEL_COL_SERVER_ACCOUNT_NAME, server_account_name, -1); - g_free (server_account_name); + if (server_account_name) + g_free (server_account_name); } iter = g_slist_next (iter); @@ -225,7 +225,7 @@ modest_connection_specific_smtp_window_fill_with_connections (ModestConnectionSp } static void -on_button_edit (ModestConnectionSpecificSmtpWindow *self) +edit_account (ModestConnectionSpecificSmtpWindow *self, GtkTreePath *path) { ModestConnectionSpecificSmtpWindowPrivate *priv = CONNECTION_SPECIFIC_SMTP_WINDOW_GET_PRIVATE (self); ModestAccountMgr *mgr = modest_runtime_get_account_mgr (); @@ -234,10 +234,8 @@ on_button_edit (ModestConnectionSpecificSmtpWindow *self) gchar *connection_name = NULL; gchar *server_account_name = NULL; ModestServerAccountSettings *server_settings = NULL; - GtkTreeSelection *sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview)); GtkTreeIter iter; - GtkTreeModel *model = 0; - if (gtk_tree_selection_get_selected (sel, &model, &iter)) { + if (gtk_tree_model_get_iter (priv->model, &iter, path)) { gtk_tree_model_get (priv->model, &iter, MODEL_COL_ID, &id, MODEL_COL_NAME, &connection_name, @@ -267,7 +265,7 @@ on_button_edit (ModestConnectionSpecificSmtpWindow *self) server_settings = NULL; } - modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (window)); + modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (window), GTK_WINDOW (self)); gint response = gtk_dialog_run (GTK_DIALOG (window)); if (response == GTK_RESPONSE_OK) { @@ -307,17 +305,10 @@ on_button_edit (ModestConnectionSpecificSmtpWindow *self) } static void -on_selection_changed (GtkTreeSelection *sel, ModestConnectionSpecificSmtpWindow *self) +on_row_activated (GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, + ModestConnectionSpecificSmtpWindow *self) { - ModestConnectionSpecificSmtpWindowPrivate *priv = - CONNECTION_SPECIFIC_SMTP_WINDOW_GET_PRIVATE (self); - - GtkTreeModel *model = NULL; - GtkTreeIter iter; - const gboolean has_selection = - gtk_tree_selection_get_selected (sel, &model, &iter); - - gtk_widget_set_sensitive (priv->button_edit, has_selection); + edit_account (self, path); } static void @@ -325,9 +316,8 @@ modest_connection_specific_smtp_window_init (ModestConnectionSpecificSmtpWindow { ModestWindowMgr *mgr; - /* Specify a default size, because the GtkTreeView's default requested size - * is not big enough: */ - gtk_window_set_default_size (GTK_WINDOW (self), 500, 300); + /* Specify a default size */ + gtk_window_set_default_size (GTK_WINDOW (self), -1, 320); /* This seems to be necessary to make the window show at the front with decoration. * If we use property type=GTK_WINDOW_TOPLEVEL instead of the default GTK_WINDOW_POPUP+decoration, @@ -346,13 +336,8 @@ modest_connection_specific_smtp_window_init (ModestConnectionSpecificSmtpWindow G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER)); /* Setup the tree view: */ - priv->treeview = GTK_TREE_VIEW (gtk_tree_view_new_with_model (priv->model)); + priv->treeview = GTK_TREE_VIEW (hildon_gtk_tree_view_new_with_model (HILDON_UI_MODE_NORMAL, priv->model)); - /* Show the column headers, - * which does not seem to be the default on Maemo. - */ - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(priv->treeview), TRUE); - /* name column: * The ID model column in not shown in the view. */ GtkTreeViewColumn *view_column = gtk_tree_view_column_new (); @@ -360,7 +345,6 @@ modest_connection_specific_smtp_window_init (ModestConnectionSpecificSmtpWindow gtk_tree_view_column_pack_start(view_column, renderer, TRUE); gtk_tree_view_column_set_attributes (view_column, renderer, "text", MODEL_COL_NAME, NULL); - gtk_tree_view_column_set_title (view_column, _("mcen_ia_optionalsmtp_connection_name")); gtk_tree_view_append_column (priv->treeview, view_column); @@ -370,7 +354,6 @@ modest_connection_specific_smtp_window_init (ModestConnectionSpecificSmtpWindow gtk_tree_view_column_pack_start(view_column, renderer, TRUE); gtk_tree_view_column_set_attributes (view_column, renderer, "text", MODEL_COL_SERVER_NAME, NULL); - gtk_tree_view_column_set_title (view_column, _("mcen_ia_optionalsmtp_servername")); gtk_tree_view_append_column (priv->treeview, view_column); /* The application must call modest_connection_specific_smtp_window_fill_with_connections(). */ @@ -382,35 +365,27 @@ modest_connection_specific_smtp_window_init (ModestConnectionSpecificSmtpWindow /* TODO: For some reason this label does not wrap. It is truncated. */ GtkWidget *label = gtk_label_new(_("mcen_ia_optionalsmtp_note")); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); /* So that it is shown without being truncated: */ - gtk_label_set_max_width_chars (GTK_LABEL (label), 20); + /* gtk_label_set_max_width_chars (GTK_LABEL (label), 20); */ /* The documentation for gtk_label_set_line_wrap() says that we must * call gtk_widget_set_size_request() with a hard-coded width, * though I wonder why gtk_label_set_max_width_chars() isn't enough. */ - gtk_widget_set_size_request (label, 400, -1); + /* gtk_widget_set_size_request (label, 400, -1); */ gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, MODEST_MARGIN_HALF); - /* Put the treeview in a scrolled window and add it to the box: */ - GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), MODEST_MARGIN_DEFAULT); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, - GTK_POLICY_AUTOMATIC); - gtk_widget_show (scrolled_window); - gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (priv->treeview)); - gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (scrolled_window), TRUE, TRUE, MODEST_MARGIN_HALF); + /* Put the treeview in a pannable and add it to the box: */ + GtkWidget *pannable = hildon_pannable_area_new (); + g_object_set (G_OBJECT (pannable), "initial-hint", TRUE, NULL); + gtk_container_set_border_width (GTK_CONTAINER (pannable), MODEST_MARGIN_DEFAULT); + gtk_widget_show (pannable); + gtk_container_add (GTK_CONTAINER (pannable), GTK_WIDGET (priv->treeview)); + gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (pannable), TRUE, TRUE, MODEST_MARGIN_HALF); gtk_widget_show (GTK_WIDGET (priv->treeview)); gtk_widget_show (vbox); - /* Hack: we use the response apply to identify the click on the edit button */ - priv->button_edit = gtk_dialog_add_button (GTK_DIALOG(self), _("mcen_bd_edit"), GTK_RESPONSE_APPLY); - gtk_dialog_add_button (GTK_DIALOG(self), _("mcen_bd_close"), GTK_RESPONSE_CLOSE); - - /* Disable the Edit button when nothing is selected: */ - GtkTreeSelection *sel = gtk_tree_view_get_selection (priv->treeview); - g_signal_connect (sel, "changed", - G_CALLBACK(on_selection_changed), self); - on_selection_changed (sel, self); + g_signal_connect (G_OBJECT (priv->treeview), "row-activated", G_CALLBACK (on_row_activated), self); /* When this window is shown, hibernation should not be possible, * because there is no sensible way to save the state: */ @@ -423,9 +398,6 @@ modest_connection_specific_smtp_window_init (ModestConnectionSpecificSmtpWindow g_signal_connect (self, "response", G_CALLBACK (on_response), NULL); - hildon_help_dialog_help_enable (GTK_DIALOG(self), - "email_connectionsspecificsmtpconf", - modest_maemo_utils_get_osso_context()); } ModestConnectionSpecificSmtpWindow* @@ -564,18 +536,6 @@ on_response (GtkDialog *dialog, gint response, gpointer user_data) { - switch (response) { - case GTK_RESPONSE_APPLY: - /* We use it for the edit button */ - on_button_edit (MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (dialog)); - g_signal_stop_emission_by_name (dialog, "response"); - break; - case GTK_RESPONSE_CLOSE: - case GTK_RESPONSE_NONE: - case GTK_RESPONSE_DELETE_EVENT: - /* Generated as a response to delete-event, i.e, - pressin Esc, or by pressing the Close button */ - modest_connection_specific_smtp_window_save_server_accounts (MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (dialog)); - gtk_widget_destroy (GTK_WIDGET (dialog)); - } + modest_connection_specific_smtp_window_save_server_accounts (MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (dialog)); + gtk_widget_destroy (GTK_WIDGET (dialog)); }