]> git.street.me.uk Git - andy/viking.git/commitdiff
Add a dialog to display several separate lines of text.
authorRob Norris <rw_norris@hotmail.com>
Thu, 22 Jan 2015 21:43:17 +0000 (21:43 +0000)
committerRob Norris <rw_norris@hotmail.com>
Tue, 27 Jan 2015 22:49:30 +0000 (22:49 +0000)
src/dialog.c
src/dialog.h

index cc1438ae827dc7c4a04570367dce435d2c7fb5f3..0bf58d061d3122774bfab7ee91951338bdd71a56 100644 (file)
@@ -591,6 +591,33 @@ static void about_email_hook (GtkAboutDialog *about,
 }
 #endif
 
+/**
+ *  Creates a dialog with list of text
+ *  Mostly useful for longer messages that have several lines of information.
+ */
+void a_dialog_list ( GtkWindow *parent, const gchar *title, GArray *array, gint padding )
+{
+  GtkWidget *dialog = gtk_dialog_new_with_buttons ( title,
+                                                    parent,
+                                                    GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                    GTK_STOCK_CLOSE,
+                                                    GTK_RESPONSE_CLOSE,
+                                                    NULL);
+
+  GtkBox *vbox = GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog)));
+  GtkWidget *label;
+
+  for ( int i = 0; i < array->len; i++ ) {
+    label = ui_label_new_selectable (NULL);
+    gtk_label_set_markup ( GTK_LABEL(label), g_array_index(array,gchar*,i) );
+    gtk_box_pack_start ( GTK_BOX(vbox), label, FALSE, TRUE, padding );
+  }
+
+  gtk_widget_show_all ( dialog );
+  gtk_dialog_run ( GTK_DIALOG(dialog) );
+  gtk_widget_destroy ( dialog );
+}
+
 void a_dialog_about ( GtkWindow *parent )
 {
   const gchar *program_name = PACKAGE_NAME;
index 851b4025a4dd68a536b39c55bcf2776cb07da1aa..59c4a9ccf5b2e917f78dd4369bd34e9cfa205ed5 100644 (file)
@@ -44,6 +44,8 @@ void a_dialog_msg ( GtkWindow *parent, gint type, const gchar *info, const gchar
 
 void a_dialog_response_accept ( GtkDialog *dialog );
 
+void a_dialog_list ( GtkWindow *parent, const gchar *title, GArray *array, gint padding );
+
 void a_dialog_about ( GtkWindow *parent );
 
 /* okay, everthing below here is an architechtural flaw. */