]> git.sur5r.net Git - glabels/commitdiff
Moved HIG inspired alert dialog to its own module (alert.[ch]).
authorJim Evins <evins@snaught.com>
Wed, 4 Sep 2002 00:58:10 +0000 (00:58 +0000)
committerJim Evins <evins@snaught.com>
Wed, 4 Sep 2002 00:58:10 +0000 (00:58 +0000)
git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@86 f5e0f49d-192f-0410-a22d-a8d8700d0965

glabels2/src/Makefile.am
glabels2/src/file.c
glabels2/src/mdi.c
glabels2/src/print.c
glabels2/src/util.c
glabels2/src/util.h

index b5557fa147dd3bb79ff159379a12afd498256a75..14bcc38801b7a97d3b4c46817259a44d2ca0e944 100644 (file)
@@ -12,10 +12,12 @@ INCLUDES = \
        -I$(top_builddir)                               \
        $(GLABELS_CFLAGS)                               \
        -I$(LIB_BARCODE_DIR)                            \
-       -DGNOME_ICONDIR=\""$(datadir)/pixmaps"\"        \
+       -DPREFIX=\""$(prefix)"\"                        \
+       -DSYSCONFDIR=\""$(sysconfdir)"\"                \
+       -DDATADIR=\""$(datadir)"\"                      \
+       -DLIBDIR=\""$(libdir)"\"                        \
        -DGLABELS_LOCALEDIR=\""$(datadir)/locale"\"     \
        -DGLABELS_UI_DIR=\""$(datadir)/glabels/ui/"\"   \
-       -DGLABELS_GLADEDIR=\""$(datadir)/glabels/glade/"\" \
        -DG_DISABLE_DEPRECATED                          \
        -DGDK_DISABLE_DEPRECATED                        \
        -DGTK_DISABLE_DEPRECATED                        \
@@ -65,6 +67,8 @@ glabels_SOURCES =                     \
        prefs.h                         \
        prefs-dialog.c                  \
        prefs-dialog.h                  \
+       alert.c                         \
+       alert.h                         \
        view.c                          \
        view.h                          \
        view-object.c                   \
index 6480906cb3c5dbb63f18ad7648fc43afc53feb32..bade80bc04c94d6c691510f357fc011144249d54 100644 (file)
@@ -30,6 +30,7 @@
 #include "file.h"
 #include "mdi.h"
 #include "recent.h"
+#include "alert.h"
 #include "util.h"
 #include "wdgt-media-select.h"
 #include "wdgt-rotate-label.h"
@@ -335,11 +336,11 @@ gl_file_open_real (const gchar     *filename,
                primary_msg = g_strdup_printf (_("Could not open file \"%s\""),
                                               filename);
 
-               dlg = gl_util_hig_dialog_new (GTK_WINDOW(win),
-                                             GTK_DIALOG_DESTROY_WITH_PARENT,
-                                             GTK_MESSAGE_ERROR,
-                                             GTK_BUTTONS_CLOSE,
-                                             primary_msg, "");
+               dlg = gl_alert_dialog_new (GTK_WINDOW(win),
+                                          GTK_DIALOG_DESTROY_WITH_PARENT,
+                                          GTK_MESSAGE_ERROR,
+                                          GTK_BUTTONS_CLOSE,
+                                          primary_msg, "");
 
                g_free (primary_msg);
 
@@ -432,11 +433,11 @@ gl_file_save (glMDIChild *child)
                primary_msg = g_strdup_printf (_("Could not save file \"%s\""),
                                               filename);
 
-               dialog = gl_util_hig_dialog_new (GTK_WINDOW(glabels_get_active_window()),
-                                                GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
-                                                GTK_MESSAGE_ERROR,
-                                                GTK_BUTTONS_CLOSE,
-                                                primary_msg, "");
+               dialog = gl_alert_dialog_new (GTK_WINDOW(glabels_get_active_window()),
+                                             GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+                                             GTK_MESSAGE_ERROR,
+                                             GTK_BUTTONS_CLOSE,
+                                             primary_msg, "");
 
                g_free (primary_msg);
 
@@ -556,11 +557,11 @@ save_as_ok_cb (GtkWidget * widget,
 
        if (!raw_filename || (raw_filename[strlen (raw_filename) - 1] == '/')) {
 
-               dlg = gl_util_hig_dialog_new (GTK_WINDOW(fsel),
-                                             GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
-                                             GTK_MESSAGE_WARNING,
-                                             GTK_BUTTONS_CLOSE,
-                                             _("Must supply file name"), "");
+               dlg = gl_alert_dialog_new (GTK_WINDOW(fsel),
+                                          GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+                                          GTK_MESSAGE_WARNING,
+                                          GTK_BUTTONS_CLOSE,
+                                          _("Must supply file name"), "");
 
                gtk_dialog_run (GTK_DIALOG (dlg));
                gtk_widget_destroy (dlg);
@@ -580,11 +581,11 @@ save_as_ok_cb (GtkWidget * widget,
                        primary_msg = g_strdup_printf (_("Could not save file \"%s\""),
                                                       filename);
 
-                       dlg = gl_util_hig_dialog_new (GTK_WINDOW(fsel),
-                                                     GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
-                                                     GTK_MESSAGE_ERROR,
-                                                     GTK_BUTTONS_CLOSE,
-                                                     primary_msg, "");
+                       dlg = gl_alert_dialog_new (GTK_WINDOW(fsel),
+                                                  GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                  GTK_MESSAGE_ERROR,
+                                                  GTK_BUTTONS_CLOSE,
+                                                  primary_msg, "");
 
                        g_free (primary_msg);
 
index 8d746a5dc0e9f8af61379d2638f0cc22c98ac7b0..4882f4f4c60a9c73000965d387925b3c82aff30e 100644 (file)
@@ -46,7 +46,7 @@
 #include "view.h"
 #include "debug.h"
 #include "gnome-recent-view.h"
-#include "util.h"
+#include "alert.h"
 
 #include <bonobo/bonobo-ui-util.h>
 #include <bonobo/bonobo-control.h>
@@ -576,7 +576,7 @@ gl_mdi_remove_child_cb (BonoboMDI *mdi, BonoboMDIChild *child)
                msg = g_strdup_printf (_("Save changes to document \"%s\" before closing?"),
                                        fname);
 
-               msgbox = gl_util_hig_dialog_new (GTK_WINDOW (bonobo_mdi_get_active_window (mdi)),
+               msgbox = gl_alert_dialog_new (GTK_WINDOW (bonobo_mdi_get_active_window (mdi)),
                                GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
                                GTK_MESSAGE_WARNING,
                                GTK_BUTTONS_NONE,
index 66a58dd2179ac702cc038183e6aba780b55ecd66..fae10c324d2c5c83f6f51f9a6363ecdf60099171 100644 (file)
@@ -526,7 +526,7 @@ draw_text_object (PrintInfo * pi,
        gl_debug (DEBUG_PRINT, "START");
 
        gl_label_object_get_position (GL_LABEL_OBJECT(object), &x0, &y0);
-       gl_label_object_get_size (object, &object_w, &object_h);
+       gl_label_object_get_size (GL_LABEL_OBJECT(object), &object_w, &object_h);
        lines = gl_label_text_get_lines (object);
        gl_label_text_get_props (object,
                                 &font_family, &font_size, &font_weight,
index bec67e033e81d243686c5a4b42ece27635a0e183..7e6172732f63780ef52f770868551102ca529405 100644 (file)
@@ -109,84 +109,6 @@ gl_util_fraction( gdouble x )
        }
 }
 
-/****************************************************************************/
-/* Create button w/ both text and stock image.                              */
-/****************************************************************************/
-GtkWidget* 
-gl_button_new_with_stock_image (const gchar* text, const gchar* stock_id)
-{
-       GtkWidget *button;
-       GtkStockItem item;
-       GtkWidget *label;
-       GtkWidget *image;
-       GtkWidget *hbox;
-       GtkWidget *align;
-
-       button = gtk_button_new ();
-
-       if (GTK_BIN (button)->child)
-               gtk_container_remove (GTK_CONTAINER (button),
-                                     GTK_BIN (button)->child);
-
-       if (gtk_stock_lookup (stock_id, &item))
-       {
-               label = gtk_label_new_with_mnemonic (text);
-
-               gtk_label_set_mnemonic_widget (GTK_LABEL (label), GTK_WIDGET (button));
-      
-               image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON);
-               hbox = gtk_hbox_new (FALSE, 2);
-
-               align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
-      
-               gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
-               gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0);
-      
-               gtk_container_add (GTK_CONTAINER (button), align);
-               gtk_container_add (GTK_CONTAINER (align), hbox);
-               gtk_widget_show_all (align);
-
-               return button;
-       }
-
-       label = gtk_label_new_with_mnemonic (text);
-       gtk_label_set_mnemonic_widget (GTK_LABEL (label), GTK_WIDGET (button));
-  
-       gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5);
-
-       gtk_widget_show (label);
-       gtk_container_add (GTK_CONTAINER (button), label);
-
-       return button;
-}
-
-/****************************************************************************/
-/* Add button to gtk_dialog w/ text and stock image.                        */
-/****************************************************************************/
-GtkWidget*
-gl_util_dialog_add_button (GtkDialog *dialog,
-                          const gchar* text,
-                          const gchar* stock_id,
-                          gint response_id)
-{
-       GtkWidget *button;
-       
-       g_return_val_if_fail (GTK_IS_DIALOG (dialog), NULL);
-       g_return_val_if_fail (text != NULL, NULL);
-       g_return_val_if_fail (stock_id != NULL, NULL);
-
-       button = gl_button_new_with_stock_image (text, stock_id);
-       g_return_val_if_fail (button != NULL, NULL);
-
-       GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
-
-       gtk_widget_show (button);
-
-       gtk_dialog_add_action_widget (dialog, button, response_id);     
-
-       return button;
-}
-
 /****************************************************************************/
 /* Utilities to deal with GTK_JUSTIFICATION types.                          */
 /****************************************************************************/
@@ -251,122 +173,3 @@ gl_util_string_to_weight (const gchar * string)
 
 }
 
-/****************************************************************************/
-/* Create a message dialog that attempts to be HIG compliant.               */
-/****************************************************************************/
-GtkWidget* gl_util_hig_dialog_new      (GtkWindow      *parent,
-                                        GtkDialogFlags  flags,
-                                        GtkMessageType  type,
-                                        GtkButtonsType  buttons,
-                                       const gchar    *primary_text,
-                                        const gchar    *secondary_text)
-{
-       GtkWidget *dialog, *hbox, *image, *label;
-       gchar *label_text;
-       const gchar *stock_id = NULL;
-       GtkStockItem item;
-  
-       /* Create bare dialog */
-       dialog = gtk_dialog_new_with_buttons ("", parent, flags, NULL);
-
-       /* Create HBOX */
-       hbox = gtk_hbox_new (FALSE, 12);
-       gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),
-                           hbox, FALSE, FALSE, 0);
-
-       /* Create image */
-       switch (type) {
-       case GTK_MESSAGE_INFO:
-               stock_id = GTK_STOCK_DIALOG_INFO;
-               break;
-       case GTK_MESSAGE_QUESTION:
-               stock_id = GTK_STOCK_DIALOG_QUESTION;
-               break;
-       case GTK_MESSAGE_WARNING:
-               stock_id = GTK_STOCK_DIALOG_WARNING;
-               break;
-       case GTK_MESSAGE_ERROR:
-               stock_id = GTK_STOCK_DIALOG_ERROR;
-               break;
-       default:
-               stock_id = GTK_STOCK_DIALOG_INFO;
-               g_warning ("Unknown GtkMessageType %d", type);
-               break;
-       }
-       if (gtk_stock_lookup (stock_id, &item)) {
-               image = gtk_image_new_from_stock (stock_id,
-                                                 GTK_ICON_SIZE_DIALOG);
-       } else {
-               image = gtk_image_new_from_stock (NULL,
-                                                 GTK_ICON_SIZE_DIALOG);
-               g_warning ("Stock dialog ID doesn't exist?");
-       }
-       gtk_box_pack_start (GTK_BOX(hbox), image, FALSE, FALSE, 0);
-
-       /* Create label containing primary and secondary text */
-       label_text = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
-                                     primary_text, secondary_text);
-       label = gtk_label_new (label_text);
-       g_free (label_text);
-       gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0);
-
-       /* Adjust dialog properties */
-       gtk_window_set_title (GTK_WINDOW(dialog), "");
-       gtk_container_set_border_width (GTK_CONTAINER(dialog), 6);
-       gtk_dialog_set_has_separator (GTK_DIALOG(dialog), FALSE);
-
-       /* Adjust VBOX properties */
-       gtk_box_set_spacing (GTK_BOX(GTK_DIALOG(dialog)->vbox), 12);
-
-       /* Adjust HBOX properties */
-       gtk_box_set_spacing (GTK_BOX(hbox), 12);
-       gtk_container_set_border_width (GTK_CONTAINER(hbox), 6);
-
-       /* Adjust IMAGE properties */
-       gtk_misc_set_alignment (GTK_MISC(image), 0.5, 0.0);
-
-       /* Adjust LABEL properties */
-       gtk_label_set_line_wrap (GTK_LABEL(label), TRUE);
-       gtk_label_set_use_markup (GTK_LABEL(label), TRUE);
-       gtk_misc_set_alignment (GTK_MISC(image), 0.5, 0.0);
-
-       /* Add buttons */
-       switch (buttons) {
-       case GTK_BUTTONS_NONE:
-               /* nothing */
-               break;
-       case GTK_BUTTONS_OK:
-               gtk_dialog_add_button (GTK_DIALOG(dialog),
-                                      GTK_STOCK_OK, GTK_RESPONSE_OK);
-               break;
-       case GTK_BUTTONS_CLOSE:
-               gtk_dialog_add_button (GTK_DIALOG(dialog),
-                                      GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
-               break;
-       case GTK_BUTTONS_CANCEL:
-               gtk_dialog_add_button (GTK_DIALOG(dialog),
-                                      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
-               break;
-       case GTK_BUTTONS_YES_NO:
-               gtk_dialog_add_button (GTK_DIALOG(dialog),
-                                      GTK_STOCK_NO, GTK_RESPONSE_NO);
-               gtk_dialog_add_button (GTK_DIALOG(dialog),
-                                      GTK_STOCK_YES, GTK_RESPONSE_YES);
-               break;
-       case GTK_BUTTONS_OK_CANCEL:
-               gtk_dialog_add_button (GTK_DIALOG(dialog),
-                                      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
-               gtk_dialog_add_button (GTK_DIALOG(dialog),
-                                      GTK_STOCK_OK, GTK_RESPONSE_OK);
-               break;
-       default:
-               g_warning ("Unknown GtkButtonsType");
-               break;
-       }
-
-       /* Show dialog widgets */
-       gtk_widget_show_all (hbox);
-
-       return dialog;
-}
-
index 159754e7430d339a52f81a1fa9c7ef7d77df7475..2b3961a0c1f4fa11508561ba76f201511fb73041 100644 (file)
@@ -32,25 +32,10 @@ extern gchar *gl_util_make_absolute (const gchar * filename);
 
 extern gchar *gl_util_fraction( gdouble x );
 
-extern GtkWidget* gl_util_button_new_with_stock_image (const gchar* text,
-                                                      const gchar* stock_id);
-
-extern GtkWidget* gl_util_dialog_add_button (GtkDialog *dialog, 
-                                            const gchar* text, 
-                                            const gchar* stock_id, 
-                                            gint response_id);
-
 extern const gchar *gl_util_just_to_string (GtkJustification just);
 extern GtkJustification gl_util_string_to_just (const gchar * string);
 
 extern const gchar *gl_util_weight_to_string (GnomeFontWeight weight);
 extern GnomeFontWeight gl_util_string_to_weight (const gchar * string);
 
-GtkWidget* gl_util_hig_dialog_new      (GtkWindow      *parent,
-                                        GtkDialogFlags  flags,
-                                        GtkMessageType  type,
-                                        GtkButtonsType  buttons,
-                                       const gchar    *primary_text,
-                                        const gchar    *secondary_text);
-
 #endif                         /* __UTIL_H__ */