]> saetta.ns0.it Git - solipa/libsolipa/commitdiff
Aggiunte le funzioni SolipaMessageDialog e SolipaInfoBar.
authorAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Tue, 21 Jun 2011 15:22:16 +0000 (17:22 +0200)
committerAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Tue, 21 Jun 2011 15:22:16 +0000 (17:22 +0200)
src/utils.c
src/utils.h

index 1790d344b4dc6a7cb7cf741f582f966e32936d21..330a730dea6e7fc7e8253e8eaf4d3bda8ba728a9 100644 (file)
@@ -1063,6 +1063,77 @@ solipa_load_window_position (const gchar *app_name, GtkWidget *widget, const gch
        g_key_file_free (kfile);
 }
 
+gint
+solipa_message_dialog (GtkWidget *transient,
+                       GtkMessageType type,
+                       GtkButtonsType buttons,
+                       const gchar *message_text)
+{
+       gint risp;
+       GtkWidget *dialog;
+
+       g_return_val_if_fail (GTK_IS_WINDOW (transient), GTK_RESPONSE_NONE);
+
+       dialog = gtk_message_dialog_new (GTK_WINDOW (transient),
+                                        GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+                                        type,
+                                        buttons,
+                                        message_text);
+       risp = gtk_dialog_run (GTK_DIALOG (dialog));
+       gtk_widget_destroy (dialog);
+
+       return risp;
+}
+
+GtkWidget
+*solipa_info_bar (GtkMessageType type, const gchar *message_text)
+{
+       GtkWidget *infobar;
+       GtkWidget *hbox;
+       GtkWidget *img;
+       GtkWidget *lbl;
+
+       gchar *stock;
+
+       hbox = gtk_hbox_new (FALSE, 5);
+       switch (type)
+               {
+                       case GTK_MESSAGE_INFO:
+                               stock = g_strdup ("gtk-dialog-info");
+                               break;
+
+                       case GTK_MESSAGE_WARNING:
+                               stock = g_strdup ("gtk-dialog-warning");
+                               break;
+
+                       case GTK_MESSAGE_QUESTION:
+                               stock = g_strdup ("gtk-dialog-question");
+                               break;
+
+                       case GTK_MESSAGE_ERROR:
+                               stock = g_strdup ("gtk-dialog-error");
+                               break;
+
+                       default:
+                               stock = g_strdup ("gtk-dialog-info");
+                               break;
+               }
+
+       img = gtk_image_new_from_stock (stock, GTK_ICON_SIZE_BUTTON);
+       gtk_box_pack_start (GTK_BOX (hbox), img, FALSE, FALSE, 0);
+       lbl = gtk_label_new (message_text);
+       gtk_box_pack_start (GTK_BOX (hbox), lbl, TRUE, TRUE, 0);
+       infobar = gtk_info_bar_new ();
+       gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (infobar))), hbox);
+       gtk_info_bar_set_message_type (GTK_INFO_BAR (infobar), type);
+
+       gtk_widget_show (hbox);
+       gtk_widget_show (img);
+       gtk_widget_show (lbl);
+
+       return infobar;
+}
+
 /**
  * This function is copied from
  * http://bugzilla.gnome.org/show_bug.cgi?id=524831.
index 6f16736208b9c8069d3e41a21cf092400e045fc7..fa07d6b29f194ef2227d9300fbae6926ebb90336 100644 (file)
@@ -70,6 +70,13 @@ gboolean solipa_chk_partita_iva (const gchar *partita_iva, gboolean empty_good);
 void solipa_save_window_position (const gchar *app_name, GtkWidget *widget, const gchar *widget_name);
 void solipa_load_window_position (const gchar *app_name, GtkWidget *widget, const gchar *widget_name);
 
+gint solipa_message_dialog (GtkWidget *transient,
+                            GtkMessageType type,
+                            GtkButtonsType buttons,
+                            const gchar *message_text);
+
+GtkWidget *solipa_info_bar (GtkMessageType type, const gchar *message_text);
+
 gchar *g_mkdtemp (gchar *tmpl);