Forgotten files
authorJose Dapena Paz <jdapena@igalia.com>
Tue, 17 Nov 2009 22:49:54 +0000 (23:49 +0100)
committerJose Dapena Paz <jdapena@igalia.com>
Wed, 25 Nov 2009 16:01:03 +0000 (17:01 +0100)
src/widgets/modest-gtk-security-options-view.c
src/widgets/modest-toolkit-utils.c [new file with mode: 0644]
src/widgets/modest-toolkit-utils.h [new file with mode: 0644]

index 1a46c7c..7654ce9 100644 (file)
@@ -35,6 +35,7 @@
 #include "modest-account-protocol.h"
 #include "widgets/modest-ui-constants.h"
 #include "widgets/modest-validating-entry.h"
+#include "modest-toolkit-utils.h"
 
 #define PORT_MIN 1
 #define PORT_MAX 65535
@@ -256,8 +257,10 @@ create_outgoing_security (ModestSecurityOptionsView* self,
                ppriv->user_entry = GTK_WIDGET (modest_validating_entry_new ());
 
                /* Auto-capitalization is the default, so let's turn it off: */
+#ifdef MAEMO_CHANGES
                hildon_gtk_entry_set_input_mode (GTK_ENTRY (ppriv->user_entry), 
                                                 HILDON_GTK_INPUT_MODE_FULL);
+#endif
 
                user_label = g_strdup_printf("%s*", _("mail_fi_username"));
                user_caption = modest_toolkit_utils_create_captioned (title_size_group, value_size_group,
@@ -277,7 +280,7 @@ create_outgoing_security (ModestSecurityOptionsView* self,
                ppriv->pwd_entry = gtk_entry_new ();
 
                /* Auto-capitalization is the default, so let's turn it off */
-#ifdef MODEST_TOOLKIT_HILDON2
+#ifdef MAEMO_CHANGES
                hildon_gtk_entry_set_input_mode (GTK_ENTRY (ppriv->pwd_entry),
                                                 HILDON_GTK_INPUT_MODE_FULL | 
                                                 HILDON_GTK_INPUT_MODE_INVISIBLE);
diff --git a/src/widgets/modest-toolkit-utils.c b/src/widgets/modest-toolkit-utils.c
new file mode 100644 (file)
index 0000000..45e88c5
--- /dev/null
@@ -0,0 +1,330 @@
+/* Copyright (c) 2006, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived from
+ *   this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <errno.h>
+#include <string.h> /* for strlen */
+#include <modest-runtime.h>
+
+#include <modest-defs.h>
+#include "modest-toolkit-utils.h"
+#include "modest-ui-constants.h"
+#ifdef MODEST_TOOLKIT_HILDON2
+#include <hildon/hildon.h>
+#endif
+
+/* Label child of a captioned */
+#define CAPTIONED_LABEL_CHILD "captioned-label"
+
+
+GtkWidget *
+modest_toolkit_utils_get_manager_menubar_as_menu (GtkUIManager *manager,
+                                                 const gchar *item_name)
+{
+       GtkWidget *new_menu;
+       GtkWidget *menubar;
+       GList *children, *iter;
+
+       menubar = gtk_ui_manager_get_widget (manager, item_name);
+       new_menu = gtk_menu_new ();
+
+       children = gtk_container_get_children (GTK_CONTAINER (menubar));
+       for (iter = children; iter != NULL; iter = g_list_next (iter)) {
+               GtkWidget *menu;
+
+               menu = GTK_WIDGET (iter->data);
+               gtk_widget_reparent (menu, new_menu);
+       }
+       
+       g_list_free (children);
+
+       return new_menu;
+}
+
+/**
+ * modest_toolkit_utils_create_captioned:
+ * @title_size_group: a #GtkSizeGroup
+ * @value_size_group: a #GtkSizeGroup
+ * @title: a string
+ * @control: a #GtkWidget
+ *
+ * this creates a widget (a #GtkHBox) with a control, and a label
+ * (@string) captioning it. It also uses the proper size groups for title
+ * and control.
+ *
+ * Returns: a widget containing the control and a proper label.
+ */
+GtkWidget *
+modest_toolkit_utils_create_captioned    (GtkSizeGroup *title_size_group,
+                                         GtkSizeGroup *value_size_group,
+                                         const gchar *title,
+                                         gboolean use_markup,
+                                         GtkWidget *control)
+{
+       return modest_toolkit_utils_create_captioned_with_size_type (title_size_group,
+                                                                    value_size_group,
+                                                                    title,
+                                                                    use_markup,
+                                                                    control,
+                                                                    0);
+}
+
+GtkWidget *
+modest_toolkit_utils_create_vcaptioned    (GtkSizeGroup *size_group,
+                                          const gchar *title,
+                                          gboolean use_markup,
+                                          GtkWidget *control)
+{
+       return modest_toolkit_utils_create_vcaptioned_with_size_type (size_group,
+                                                                     title,
+                                                                     use_markup,
+                                                                     control,
+                                                                     0);
+}
+
+/**
+ * modest_toolkit_utils_create_captioned_with_size_type:
+ * @title_size_group: a #GtkSizeGroup
+ * @value_size_group: a #GtkSizeGroup
+ * @title: a string
+ * @control: a #GtkWidget
+ * @size_type: a #HildonSizeType
+ *
+ * this creates a widget (a #GtkHBox) with a control, and a label
+ * (@string) captioning it. It also uses the proper size groups for title
+ * and control.
+ *
+ * Returns: a widget containing the control and a proper label.
+ */
+GtkWidget *
+modest_toolkit_utils_create_captioned_with_size_type    (GtkSizeGroup *title_size_group,
+                                                        GtkSizeGroup *value_size_group,
+                                                        const gchar *title,
+                                                        gboolean use_markup,
+                                                        GtkWidget *control,
+                                                        ModestToolkitSizeType size_type)
+{
+       GtkWidget *label;
+       GtkWidget *align;
+       GtkWidget *box;
+  
+       if (use_markup) {
+               label = gtk_label_new (NULL);
+               gtk_label_set_markup (GTK_LABEL (label), title);
+       } else {
+               label = gtk_label_new (title);
+       }
+       align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
+       gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 0, MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DOUBLE);
+
+       gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+#ifdef MAEMO_CHANGES
+       hildon_gtk_widget_set_theme_size (label, HILDON_SIZE_FINGER_HEIGHT);
+#endif
+       gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+       gtk_widget_show (label);
+       gtk_widget_show (align);
+       box = gtk_hbox_new (FALSE, 0);
+       gtk_container_add (GTK_CONTAINER (align), label);
+       gtk_box_pack_start (GTK_BOX (box), align, FALSE, FALSE, 0);
+       gtk_box_pack_start (GTK_BOX (box), control, TRUE, TRUE, 0);
+       if (title_size_group)
+               gtk_size_group_add_widget (title_size_group, label);
+       if (value_size_group)
+               gtk_size_group_add_widget (value_size_group, control);
+
+#ifdef MAEMO_CHANGES
+       hildon_gtk_widget_set_theme_size (control, size_type);
+#endif
+
+       g_object_set_data (G_OBJECT (box), CAPTIONED_LABEL_CHILD, label);
+
+       return box;
+}
+
+GtkWidget *
+modest_toolkit_utils_create_vcaptioned_with_size_type    (GtkSizeGroup *size_group,
+                                                         const gchar *title,
+                                                         gboolean use_markup,
+                                                         GtkWidget *control,
+                                                         ModestToolkitSizeType size_type)
+{
+       GtkWidget *label;
+       GtkWidget *align;
+       GtkWidget *box;
+  
+       if (use_markup) {
+               label = gtk_label_new (NULL);
+               gtk_label_set_markup (GTK_LABEL (label), title);
+       } else {
+               label = gtk_label_new (title);
+       }
+       align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
+       gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 0, MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DOUBLE);
+
+       gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+#ifdef MAEMO_CHANGES
+       hildon_gtk_widget_set_theme_size (label, HILDON_SIZE_FINGER_HEIGHT);
+#endif
+       gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+       gtk_widget_show (label);
+       gtk_widget_show (align);
+       box = gtk_vbox_new (FALSE, 0);
+       gtk_container_add (GTK_CONTAINER (align), label);
+       gtk_box_pack_start (GTK_BOX (box), align, FALSE, FALSE, 0);
+       gtk_box_pack_start (GTK_BOX (box), control, TRUE, TRUE, 0);
+       if (size_group) {
+               gtk_size_group_add_widget (size_group, label);
+               gtk_size_group_add_widget (size_group, control);
+       }
+
+#ifdef MAEMO_CHANGES
+       hildon_gtk_widget_set_theme_size (control, size_type);
+#endif
+
+       g_object_set_data (G_OBJECT (box), CAPTIONED_LABEL_CHILD, label);
+
+       return box;
+}
+
+/**
+ * modest_toolkit_utils_captioned_set_label:
+ * @captioned: a #GtkWidget built as captioned
+ * @new_label: a string
+ * @use_markup: a #gboolean
+ *
+ * set a new label for the captioned
+ */
+void
+modest_toolkit_utils_captioned_set_label (GtkWidget *captioned,
+                                         const gchar *new_label,
+                                         gboolean use_markup)
+{
+       GtkWidget *label;
+
+       g_return_if_fail (GTK_IS_WIDGET (captioned));
+
+       label = g_object_get_data (G_OBJECT (captioned), CAPTIONED_LABEL_CHILD);
+       g_return_if_fail (GTK_IS_LABEL (label));
+
+       if (use_markup) {
+               gtk_label_set_markup (GTK_LABEL (label), new_label);
+       } else {
+               gtk_label_set_text (GTK_LABEL (label), new_label);
+       }
+}
+
+/**
+ * modest_toolkit_utils_captioned_get_label_widget:
+ * @captioned: a #GtkWidget built as captioned
+ *
+ * obtains the label widget for the captioned
+ *
+ * Returns: a #GtkLabel
+ */
+GtkWidget *
+modest_toolkit_utils_captioned_get_label_widget (GtkWidget *captioned)
+{
+       GtkWidget *label;
+
+       g_return_val_if_fail (GTK_IS_WIDGET (captioned), NULL);
+
+       label = g_object_get_data (G_OBJECT (captioned), CAPTIONED_LABEL_CHILD);
+       g_return_val_if_fail (GTK_IS_LABEL (label), NULL);
+
+       return label;
+
+}
+
+/**
+ * modest_toolkit_utils_set_hbutton_layout:
+ * @title_sizegroup: a #GtkSizeGroup, or %NULL
+ * @value_sizegroup: a #GtkSizeGroup, or %NULL
+ * @title: a string
+ * @button: a #HildonButton
+ *
+ * Configures the alignment and layout of @button. If @title_sizegroup is provided,
+ * the title will be aligned to the left using it. If @value_sizegroup is provided,
+ * the value will be aligned to the left using it. It also sets the title
+ * of the button.
+ *
+ * The alignment is left for the title and for the value.
+ */
+void
+modest_toolkit_utils_set_hbutton_layout (GtkSizeGroup *title_sizegroup, 
+                                      GtkSizeGroup *value_sizegroup,
+                                      const gchar *title, 
+                                      GtkWidget *button)
+{
+#ifdef MODEST_TOOLKIT_HILDON2
+       hildon_button_set_title (HILDON_BUTTON (button), title);
+       if (title_sizegroup)
+               hildon_button_add_title_size_group (HILDON_BUTTON (button), title_sizegroup);
+       if (value_sizegroup)
+               hildon_button_add_value_size_group (HILDON_BUTTON (button), value_sizegroup);
+       hildon_button_set_alignment (HILDON_BUTTON (button), 0.0, 0.5, 1.0, 0.0);
+       hildon_button_set_title_alignment (HILDON_BUTTON (button), 0.0, 0.5);
+       hildon_button_set_value_alignment (HILDON_BUTTON (button), 0.0, 0.5);
+#endif
+}
+
+void
+modest_toolkit_utils_set_vbutton_layout (GtkSizeGroup *sizegroup, 
+                                        const gchar *title, 
+                                        GtkWidget *button)
+{
+#ifdef MODEST_TOOLKIT_HILDON2
+       hildon_button_set_title (HILDON_BUTTON (button), title);
+       if (sizegroup) {
+               hildon_button_add_title_size_group (HILDON_BUTTON (button), sizegroup);
+               hildon_button_add_value_size_group (HILDON_BUTTON (button), sizegroup);
+       }
+       hildon_button_set_alignment (HILDON_BUTTON (button), 0.0, 0.5, 1.0, 0.0);
+       hildon_button_set_title_alignment (HILDON_BUTTON (button), 0.0, 0.5);
+       hildon_button_set_value_alignment (HILDON_BUTTON (button), 0.0, 0.5);
+#endif
+}
+
+GtkWidget *
+modest_toolkit_utils_create_group_box (const gchar *label_text, GtkWidget *contents)
+{
+       GtkWidget *label;
+       GtkWidget *box;
+
+       label = gtk_label_new (label_text);
+       gtk_widget_show (label);
+
+       box = gtk_vbox_new (FALSE, MODEST_MARGIN_HALF);
+       gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
+       gtk_box_pack_start (GTK_BOX (box), contents, TRUE, TRUE, 0);
+       gtk_widget_show (box);
+
+       return box;
+}
diff --git a/src/widgets/modest-toolkit-utils.h b/src/widgets/modest-toolkit-utils.h
new file mode 100644 (file)
index 0000000..43f08fc
--- /dev/null
@@ -0,0 +1,89 @@
+/* Copyright (c) 2006, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived from
+ *   this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#ifndef __MODEST_TOOLKIT_UTILS_H__
+#define __MODEST_TOOLKIT_UTILS_H__
+
+#include <gtk/gtk.h>
+#include <stdio.h> /* for FILE* */
+#include <tny-fs-stream.h>
+#include <libosso.h>
+#include "widgets/modest-global-settings-dialog.h"
+#include "widgets/modest-validating-entry.h"
+
+#ifdef MAEMO_CHANGES
+#include <hildon/hildon-gtk.h>
+#define ModestToolkitSizeType HildonSizeType
+#else
+#define ModestToolkitSizeType gint
+#endif
+
+GtkWidget *modest_toolkit_utils_create_captioned    (GtkSizeGroup *title_size_group,
+                                                  GtkSizeGroup *value_size_group,
+                                                  const gchar *title,
+                                                  gboolean use_markup,
+                                                  GtkWidget *control);
+GtkWidget *modest_toolkit_utils_create_vcaptioned    (GtkSizeGroup *size_group,
+                                                   const gchar *title,
+                                                   gboolean use_markup,
+                                                   GtkWidget *control);
+
+GtkWidget *modest_toolkit_utils_create_captioned_with_size_type    (GtkSizeGroup *title_size_group,
+                                                                   GtkSizeGroup *value_size_group,
+                                                                   const gchar *title,
+                                                                   gboolean use_markup,
+                                                                   GtkWidget *control,
+                                                                   ModestToolkitSizeType size_type);
+
+GtkWidget *modest_toolkit_utils_create_vcaptioned_with_size_type    (GtkSizeGroup *size_group,
+                                                                    const gchar *title,
+                                                                    gboolean use_markup,
+                                                                    GtkWidget *control,
+                                                                    ModestToolkitSizeType size_type);
+
+void       modest_toolkit_utils_captioned_set_label (GtkWidget *captioned,
+                                                    const gchar *new_label,
+                                                    gboolean use_markup);
+
+GtkWidget *modest_toolkit_utils_captioned_get_label_widget (GtkWidget *captioned);
+
+void       modest_toolkit_utils_set_hbutton_layout (GtkSizeGroup *title_sizegroup, 
+                                                   GtkSizeGroup *value_sizegroup,
+                                                   const gchar *title, 
+                                                   GtkWidget *button);
+void       modest_toolkit_utils_set_vbutton_layout (GtkSizeGroup *sizegroup, 
+                                                   const gchar *title, 
+                                                   GtkWidget *button);
+
+GtkWidget *modest_toolkit_utils_create_group_box (const gchar *label, GtkWidget *contents);
+
+
+
+#endif /*__MODEST_TOOLKIT_UTILS_H__*/