]> git.sur5r.net Git - glabels/blobdiff - src/new-label-dialog.c
Added translation context for "Select Product" (Bug #763003).
[glabels] / src / new-label-dialog.c
index b6a92596e42b67271554dbb5e3168b21bcef3934..07807ae6a417a4f636c84cb316f57e7b89188c1a 100644 (file)
@@ -50,20 +50,20 @@ struct _glNewLabelDialogPrivate {
 
         GtkBuilder *builder;
 
-       GtkWidget  *template_page_vbox;
+        GtkWidget  *template_page_vbox;
         GtkWidget  *combo_hbox;
         GtkWidget  *combo;
 
-       GtkWidget  *rotate_page_vbox;
+        GtkWidget  *rotate_page_vbox;
         GtkWidget  *normal_radio;
-       GtkWidget  *rotated_radio;
+        GtkWidget  *rotated_radio;
         GtkWidget  *normal_preview_hbox;
-       GtkWidget  *rotated_preview_hbox;
+        GtkWidget  *rotated_preview_hbox;
         GtkWidget  *normal_preview;
-       GtkWidget  *rotated_preview;
+        GtkWidget  *rotated_preview;
 
-       GtkWidget  *confirm_page_vbox;
-       GtkWidget  *preview_vbox;
+        GtkWidget  *confirm_page_vbox;
+        GtkWidget  *preview_vbox;
         GtkWidget  *preview;
         GtkWidget  *desc_label;
         GtkWidget  *page_size_label;
@@ -110,8 +110,6 @@ static gint       forward_page_function               (gint               curren
 static void       combo_changed_cb                    (glNewLabelDialog  *this);
 static void       rotate_toggled_cb                   (glNewLabelDialog  *this);
 
-static gchar     *get_default_name                    (void);
-
 static void       set_info                            (glNewLabelDialog  *this,
                                                        const gchar       *name);
 
@@ -119,7 +117,7 @@ static void       set_info                            (glNewLabelDialog  *this,
 /*****************************************************************************/
 /* Boilerplate object stuff.                                                 */
 /*****************************************************************************/
-G_DEFINE_TYPE (glNewLabelDialog, gl_new_label_dialog, GTK_TYPE_ASSISTANT);
+G_DEFINE_TYPE (glNewLabelDialog, gl_new_label_dialog, GTK_TYPE_ASSISTANT)
 
 
 /*****************************************************************************/
@@ -128,13 +126,13 @@ G_DEFINE_TYPE (glNewLabelDialog, gl_new_label_dialog, GTK_TYPE_ASSISTANT);
 static void
 gl_new_label_dialog_class_init (glNewLabelDialogClass *class)
 {
-       GObjectClass *object_class = G_OBJECT_CLASS (class);
+        GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+        gl_debug (DEBUG_FILE, "");
 
-       gl_debug (DEBUG_FILE, "");
-       
-       gl_new_label_dialog_parent_class = g_type_class_peek_parent (class);
+        gl_new_label_dialog_parent_class = g_type_class_peek_parent (class);
 
-       object_class->finalize = gl_new_label_dialog_finalize;
+        object_class->finalize = gl_new_label_dialog_finalize;
 
         signals[COMPLETE] =
             g_signal_new ("complete",
@@ -154,7 +152,9 @@ gl_new_label_dialog_class_init (glNewLabelDialogClass *class)
 static void
 gl_new_label_dialog_init (glNewLabelDialog *this)
 {
-       GtkWidget    *vbox;
+        GdkRGBA       banner_color = { 0, 0.5, 1.0, 1.0 };
+        GtkWidget    *page_1_banner_eventbox, *page_2_banner_eventbox, *page_3_banner_eventbox;
+        GtkWidget    *page_1_image, *page_2_image, *page_3_image;
         gchar        *logo_filename;
         GdkPixbuf    *logo;
         GtkBuilder   *builder;
@@ -164,29 +164,30 @@ gl_new_label_dialog_init (glNewLabelDialog *this)
                                        "confirm_page_vbox",
                                        NULL };
         GError       *error = NULL;
-        GtkWidget    *new_label_dialog_hbox;
 
-       gl_debug (DEBUG_FILE, "START");
+        gl_debug (DEBUG_FILE, "START");
 
-       g_return_if_fail (GL_IS_NEW_LABEL_DIALOG (this));
+        g_return_if_fail (GL_IS_NEW_LABEL_DIALOG (this));
 
-       this->priv = g_new0 (glNewLabelDialogPrivate, 1);
-
-        logo_filename = g_build_filename (GLABELS_ICON_DIR, GLABELS_ICON, NULL);
-       logo = gdk_pixbuf_new_from_file (logo_filename, NULL);
-        g_free (logo_filename);
+        this->priv = g_new0 (glNewLabelDialogPrivate, 1);
 
         builder = gtk_builder_new ();
-        builder_filename = g_build_filename (GLABELS_DATA_DIR, "builder", "new-label-dialog.builder", NULL);
+        builder_filename = g_build_filename (GLABELS_DATA_DIR, "ui", "new-label-dialog.ui", NULL);
         gtk_builder_add_objects_from_file (builder, builder_filename, object_ids, &error);
         g_free (builder_filename);
-       if (error) {
-               g_critical ("%s\n\ngLabels may not be installed correctly!", error->message);
+        if (error) {
+                g_critical ("%s\n\ngLabels may not be installed correctly!", error->message);
                 g_error_free (error);
-               return;
-       }
+                return;
+        }
 
         gl_builder_util_get_widgets (builder,
+                                     "page_1_banner_eventbox", &page_1_banner_eventbox,
+                                     "page_2_banner_eventbox", &page_2_banner_eventbox,
+                                     "page_3_banner_eventbox", &page_3_banner_eventbox,
+                                     "page_1_image",           &page_1_image,
+                                     "page_2_image",           &page_2_image,
+                                     "page_3_image",           &page_3_image,
                                      "template_page_vbox",     &this->priv->template_page_vbox,
                                      "combo_hbox",             &this->priv->combo_hbox,
                                      "rotate_page_vbox",       &this->priv->rotate_page_vbox,
@@ -208,17 +209,29 @@ gl_new_label_dialog_init (glNewLabelDialog *this)
         this->priv->builder = builder;
 
         gtk_assistant_append_page (GTK_ASSISTANT (this), this->priv->template_page_vbox);
-        gtk_assistant_set_page_title (GTK_ASSISTANT (this), this->priv->template_page_vbox, _("Select Product"));
-        gtk_assistant_set_page_header_image (GTK_ASSISTANT (this), this->priv->template_page_vbox, logo);
+        gtk_assistant_set_page_title (GTK_ASSISTANT (this), this->priv->template_page_vbox,
+                                      C_("Title of dialog page to select a stationary product",
+                                         "Select Product"));
         gtk_assistant_set_page_type (GTK_ASSISTANT (this), this->priv->template_page_vbox, GTK_ASSISTANT_PAGE_INTRO);
+        gtk_widget_override_background_color (page_1_banner_eventbox, GTK_STATE_NORMAL, &banner_color);
+        logo_filename = g_build_filename (GLABELS_DATA_DIR, "pixmaps", "new-select.png", NULL);
+        logo = gdk_pixbuf_new_from_file (logo_filename, NULL);
+        gtk_image_set_from_pixbuf (GTK_IMAGE (page_1_image), logo);
+        g_free (logo_filename);
+        g_object_unref (logo);
 
         this->priv->combo = gl_media_select_new ();
         gtk_container_add (GTK_CONTAINER (this->priv->combo_hbox), this->priv->combo);
 
         gtk_assistant_append_page (GTK_ASSISTANT (this), this->priv->rotate_page_vbox);
         gtk_assistant_set_page_title (GTK_ASSISTANT (this), this->priv->rotate_page_vbox, _("Choose Orientation"));
-        gtk_assistant_set_page_header_image (GTK_ASSISTANT (this), this->priv->rotate_page_vbox, logo);
         gtk_assistant_set_page_complete (GTK_ASSISTANT (this), this->priv->rotate_page_vbox, TRUE);
+        gtk_widget_override_background_color (page_2_banner_eventbox, GTK_STATE_NORMAL, &banner_color);
+        logo_filename = g_build_filename (GLABELS_DATA_DIR, "pixmaps", "new-rotate.png", NULL);
+        logo = gdk_pixbuf_new_from_file (logo_filename, NULL);
+        gtk_image_set_from_pixbuf (GTK_IMAGE (page_2_image), logo);
+        g_free (logo_filename);
+        g_object_unref (logo);
 
         this->priv->normal_preview = gl_mini_label_preview_new (LABEL_PREVIEW_WIDTH, LABEL_PREVIEW_HEIGHT);
         gtk_container_add (GTK_CONTAINER (this->priv->normal_preview_hbox), this->priv->normal_preview);
@@ -227,9 +240,14 @@ gl_new_label_dialog_init (glNewLabelDialog *this)
 
         gtk_assistant_append_page (GTK_ASSISTANT (this), this->priv->confirm_page_vbox);
         gtk_assistant_set_page_title (GTK_ASSISTANT (this), this->priv->confirm_page_vbox, _("Review"));
-        gtk_assistant_set_page_header_image (GTK_ASSISTANT (this), this->priv->confirm_page_vbox, logo);
         gtk_assistant_set_page_type (GTK_ASSISTANT (this), this->priv->confirm_page_vbox, GTK_ASSISTANT_PAGE_CONFIRM);
         gtk_assistant_set_page_complete (GTK_ASSISTANT (this), this->priv->confirm_page_vbox, TRUE);
+        gtk_widget_override_background_color (page_3_banner_eventbox, GTK_STATE_NORMAL, &banner_color);
+        logo_filename = g_build_filename (GLABELS_DATA_DIR, "pixmaps", "new-confirm.png", NULL);
+        logo = gdk_pixbuf_new_from_file (logo_filename, NULL);
+        gtk_image_set_from_pixbuf (GTK_IMAGE (page_3_image), logo);
+        g_free (logo_filename);
+        g_object_unref (logo);
 
         this->priv->preview = gl_mini_preview_new (MINI_PREVIEW_MIN_HEIGHT, MINI_PREVIEW_MIN_WIDTH);
         gl_mini_preview_set_draw_arrow (GL_MINI_PREVIEW (this->priv->preview), TRUE);
@@ -238,17 +256,17 @@ gl_new_label_dialog_init (glNewLabelDialog *this)
 
         gtk_assistant_set_forward_page_func (GTK_ASSISTANT (this), (GtkAssistantPageFunc)forward_page_function, this, NULL);
 
-       g_signal_connect_swapped (G_OBJECT(this), "cancel", G_CALLBACK(cancel_cb), this);
-       g_signal_connect_swapped (G_OBJECT(this), "apply",  G_CALLBACK(apply_cb),  this);
-       g_signal_connect_swapped (G_OBJECT(this), "close",  G_CALLBACK(close_cb),  this);
+        g_signal_connect_swapped (G_OBJECT(this), "cancel", G_CALLBACK(cancel_cb), this);
+        g_signal_connect_swapped (G_OBJECT(this), "apply",  G_CALLBACK(apply_cb),  this);
+        g_signal_connect_swapped (G_OBJECT(this), "close",  G_CALLBACK(close_cb),  this);
 
-       g_signal_connect_swapped (G_OBJECT (this->priv->combo),         "changed", G_CALLBACK (combo_changed_cb),  this);
-       g_signal_connect_swapped (G_OBJECT (this->priv->normal_radio),  "toggled", G_CALLBACK (rotate_toggled_cb), this);
-       g_signal_connect_swapped (G_OBJECT (this->priv->rotated_radio), "toggled", G_CALLBACK (rotate_toggled_cb), this);
+        g_signal_connect_swapped (G_OBJECT (this->priv->combo),         "changed", G_CALLBACK (combo_changed_cb),  this);
+        g_signal_connect_swapped (G_OBJECT (this->priv->normal_radio),  "toggled", G_CALLBACK (rotate_toggled_cb), this);
+        g_signal_connect_swapped (G_OBJECT (this->priv->rotated_radio), "toggled", G_CALLBACK (rotate_toggled_cb), this);
 
         combo_changed_cb (this);
 
-       gl_debug (DEBUG_FILE, "END");
+        gl_debug (DEBUG_FILE, "END");
 }
 
 
@@ -258,20 +276,20 @@ gl_new_label_dialog_init (glNewLabelDialog *this)
 static void 
 gl_new_label_dialog_finalize (GObject *object)
 {
-       glNewLabelDialog* this = GL_NEW_LABEL_DIALOG (object);;
-       
-       gl_debug (DEBUG_FILE, "START");
+        glNewLabelDialog* this = GL_NEW_LABEL_DIALOG (object);;
+
+        gl_debug (DEBUG_FILE, "START");
 
-       g_return_if_fail (object != NULL);
-       g_return_if_fail (GL_IS_NEW_LABEL_DIALOG (this));
-       g_return_if_fail (this->priv != NULL);
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GL_IS_NEW_LABEL_DIALOG (this));
+        g_return_if_fail (this->priv != NULL);
 
         g_object_unref (G_OBJECT (this->priv->builder));
-       g_free (this->priv);
+        g_free (this->priv);
 
-       G_OBJECT_CLASS (gl_new_label_dialog_parent_class)->finalize (object);
+        G_OBJECT_CLASS (gl_new_label_dialog_parent_class)->finalize (object);
 
-       gl_debug (DEBUG_FILE, "END");
+        gl_debug (DEBUG_FILE, "END");
 
 }
 
@@ -282,15 +300,15 @@ gl_new_label_dialog_finalize (GObject *object)
 GtkWidget *
 gl_new_label_dialog_new (GtkWindow    *win)
 {
-       GtkWidget *this;
+        GtkWidget *this;
 
-       gl_debug (DEBUG_FILE, "");
+        gl_debug (DEBUG_FILE, "");
 
-       this = GTK_WIDGET (g_object_new (GL_TYPE_NEW_LABEL_DIALOG, NULL));
+        this = GTK_WIDGET (g_object_new (GL_TYPE_NEW_LABEL_DIALOG, NULL));
 
-       gtk_window_set_transient_for (GTK_WINDOW (this), win);
+        gtk_window_set_transient_for (GTK_WINDOW (this), win);
 
-       return this;
+        return this;
 }
 
 
@@ -343,7 +361,7 @@ static void
 cancel_cb (glNewLabelDialog *this)
 {
                                                                                
-       gtk_widget_destroy (GTK_WIDGET(this));
+        gtk_widget_destroy (GTK_WIDGET(this));
 
 }
 
@@ -367,7 +385,7 @@ static void
 close_cb (glNewLabelDialog *this)
 {
                                                                                
-       gtk_widget_destroy (GTK_WIDGET(this));
+        gtk_widget_destroy (GTK_WIDGET(this));
 
 }
 
@@ -378,24 +396,24 @@ close_cb (glNewLabelDialog *this)
 static void
 combo_changed_cb (glNewLabelDialog  *this)
 {
-       gchar             *name;
+        gchar             *name;
 
-       gl_debug (DEBUG_FILE, "START");
+        gl_debug (DEBUG_FILE, "START");
 
-       name = gl_media_select_get_name (GL_MEDIA_SELECT (this->priv->combo));
+        name = gl_media_select_get_name (GL_MEDIA_SELECT (this->priv->combo));
 
         gl_mini_label_preview_set_by_name (GL_MINI_LABEL_PREVIEW (this->priv->normal_preview),  name, FALSE);
         gl_mini_label_preview_set_by_name (GL_MINI_LABEL_PREVIEW (this->priv->rotated_preview), name, TRUE);
         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (this->priv->normal_radio), TRUE);
 
-       gl_mini_preview_set_by_name (GL_MINI_PREVIEW (this->priv->preview), name);
+        gl_mini_preview_set_by_name (GL_MINI_PREVIEW (this->priv->preview), name);
         set_info (this, name);
 
         gtk_assistant_set_page_complete (GTK_ASSISTANT (this), this->priv->template_page_vbox, (name != NULL));
 
-       g_free (name);
+        g_free (name);
 
-       gl_debug (DEBUG_FILE, "END");
+        gl_debug (DEBUG_FILE, "END");
 }
 
 
@@ -407,12 +425,12 @@ rotate_toggled_cb (glNewLabelDialog  *this)
 {
         gboolean state;
 
-       gl_debug (DEBUG_FILE, "START");
+        gl_debug (DEBUG_FILE, "START");
 
         state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (this->priv->rotated_radio));
         gl_mini_preview_set_rotate (GL_MINI_PREVIEW (this->priv->preview), state);
 
-       gl_debug (DEBUG_FILE, "END");
+        gl_debug (DEBUG_FILE, "END");
 }
 
 
@@ -456,6 +474,7 @@ set_info (glNewLabelDialog  *this,
                 escaped_url = g_markup_escape_text (vendor->url, -1);
                 markup = g_strdup_printf ("<a href='%s'>%s</a>", escaped_url, vendor->name);
                 gtk_label_set_markup (GTK_LABEL (this->priv->vendor_label), markup);
+                gtk_widget_set_tooltip_text (this->priv->vendor_label, escaped_url);
                 g_free (escaped_url);
                 g_free (markup);
         }
@@ -463,6 +482,7 @@ set_info (glNewLabelDialog  *this,
         {
                 /* FIXME: Using set_markup instead of set_text to clear out previous link. */
                 gtk_label_set_markup (GTK_LABEL (this->priv->vendor_label), template->brand);
+                gtk_widget_set_has_tooltip (this->priv->vendor_label, FALSE);
         }
 
         if ( template->product_url )
@@ -473,6 +493,7 @@ set_info (glNewLabelDialog  *this,
                 escaped_url = g_markup_escape_text (template->product_url, -1);
                 markup = g_strdup_printf ("<a href='%s'>%s</a>", escaped_url, template->part);
                 gtk_label_set_markup (GTK_LABEL (this->priv->part_label), markup);
+                gtk_widget_set_tooltip_text (this->priv->part_label, escaped_url);
                 g_free (escaped_url);
                 g_free (markup);
         }
@@ -480,6 +501,7 @@ set_info (glNewLabelDialog  *this,
         {
                 /* FIXME: Using set_markup instead of set_text to clear out previous link. */
                 gtk_label_set_markup (GTK_LABEL (this->priv->part_label), template->part);
+                gtk_widget_set_has_tooltip (this->priv->part_label, FALSE);
         }
 
         list = lgl_db_get_similar_template_name_list (name);
@@ -509,11 +531,11 @@ set_info (glNewLabelDialog  *this,
 gchar *
 gl_new_label_dialog_get_template_name (glNewLabelDialog *this)
 {
-       gchar *name;
+        gchar *name;
 
-       name = gl_media_select_get_name (GL_MEDIA_SELECT (this->priv->combo));
+        name = gl_media_select_get_name (GL_MEDIA_SELECT (this->priv->combo));
 
-       return name;
+        return name;
 }
 
 
@@ -522,10 +544,10 @@ gl_new_label_dialog_get_template_name (glNewLabelDialog *this)
 /*****************************************************************************/
 void
 gl_new_label_dialog_set_template_name (glNewLabelDialog *this,
-                                      gchar            *name)
+                                       gchar            *name)
 {
-       gl_mini_preview_set_by_name (GL_MINI_PREVIEW (this->priv->preview), name);
-       gl_media_select_set_name (GL_MEDIA_SELECT (this->priv->combo), name);
+        gl_mini_preview_set_by_name (GL_MINI_PREVIEW (this->priv->preview), name);
+        gl_media_select_set_name (GL_MEDIA_SELECT (this->priv->combo), name);
         set_info (this, name);
 }
 
@@ -535,8 +557,8 @@ gl_new_label_dialog_set_template_name (glNewLabelDialog *this,
 /*****************************************************************************/
 void
 gl_new_label_dialog_get_filter_parameters (glNewLabelDialog  *this,
-                                          gchar            **page_size_id,
-                                          gchar            **category_id)
+                                           gchar            **page_size_id,
+                                           gchar            **category_id)
 {
 }
 
@@ -546,8 +568,8 @@ gl_new_label_dialog_get_filter_parameters (glNewLabelDialog  *this,
 /*****************************************************************************/
 void
 gl_new_label_dialog_set_filter_parameters (glNewLabelDialog *this,
-                                          const gchar      *page_size_id,
-                                          const gchar      *category_id)
+                                           const gchar      *page_size_id,
+                                           const gchar      *category_id)
 {
 }
 
@@ -558,7 +580,7 @@ gl_new_label_dialog_set_filter_parameters (glNewLabelDialog *this,
 gboolean
 gl_new_label_dialog_get_rotate_state (glNewLabelDialog *this)
 {
-       return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (this->priv->rotated_radio));
+        return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (this->priv->rotated_radio));
 }
 
 
@@ -567,7 +589,7 @@ gl_new_label_dialog_get_rotate_state (glNewLabelDialog *this)
 /*****************************************************************************/
 void
 gl_new_label_dialog_set_rotate_state (glNewLabelDialog *this,
-                                     gboolean          state)
+                                      gboolean          state)
 {
         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (this->priv->rotated_radio), state);
         gl_mini_preview_set_rotate (GL_MINI_PREVIEW (this->priv->preview), state);