+ GtkWidget *dialog = gtk_dialog_new_with_buttons (title_text,
+ parent,
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_REJECT,
+ GTK_STOCK_OK,
+ GTK_RESPONSE_ACCEPT,
+ NULL);
+ gtk_dialog_set_default_response ( GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT );
+ GtkWidget *response_w = NULL;
+#if GTK_CHECK_VERSION (2, 20, 0)
+ response_w = gtk_dialog_get_widget_for_response ( GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT );
+#endif
+
+ GtkWidget *table, *spin, *label;
+ guint result = default_num;
+
+ table = gtk_table_new ( 2, 1, FALSE );
+ gtk_box_pack_start ( GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), table, TRUE, TRUE, 0 );
+
+ label = gtk_label_new (label_text);
+ spin = gtk_spin_button_new ( (GtkAdjustment *) gtk_adjustment_new ( default_num, min, max, step, 5, 0 ), 1, 0 );
+
+ gtk_table_attach_defaults ( GTK_TABLE(table), label, 0, 1, 0, 1 );
+ gtk_table_attach_defaults ( GTK_TABLE(table), spin, 0, 1, 1, 2 );
+
+ if ( response_w )
+ gtk_widget_grab_focus ( response_w );
+
+ gtk_widget_show_all ( table );
+
+ if ( gtk_dialog_run ( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT )
+ {
+ result = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(spin) );
+ gtk_widget_destroy ( dialog );
+ return result;
+ }
+
+ // Dialog cancelled
+ gtk_widget_destroy ( dialog );
+ return 0;
+}
+
+#if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION < 24)
+static void about_url_hook (GtkAboutDialog *about,
+ const gchar *link,
+ gpointer data)
+{
+ open_url (GTK_WINDOW(about), link);
+}
+
+static void about_email_hook (GtkAboutDialog *about,
+ const gchar *email,
+ gpointer data)
+{
+ new_email (GTK_WINDOW(about), email);
+}
+#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 );