re-adding .pngs as binary
[dia.git] / app / dialogs.c
blobb36ef16b44b1c05fd166ff1a65cdbc255e91d4a1
1 /* Dia -- a diagram creation/manipulation program
2 * Copyright (C) 1998 Alexander Larsson
4 * dialogs.c: helper routines for creating simple dialogs
5 * Copyright (C) 2002 Lars Clausen
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
26 #include "intl.h"
27 #include <gtk/gtk.h>
28 #include "geometry.h"
29 #include "dialogs.h"
31 /* Functions to create dialog widgets. These should, if used in other
32 dialogs, go into a separate file. They are intended for fairly small
33 transient dialogs such as parameters for exports. The functions are
34 meant to be transparent in that they don't make their own structures,
35 they're just collections of common actions.
37 /** Creates a new dialog with a title and Ok and Cancel buttons.
38 Default texts are supplied for Ok and Cancel buttons if NULL.
39 Returns the created dialog and sets the two widget pointers.
40 This function does not call gtk_widget_show(), do
41 gtk_widget_show_all() when all has been added.
43 GtkWidget *
44 dialog_make(char *title, char *okay_text, char *cancel_text,
45 GtkWidget **okay_button, GtkWidget **cancel_button) {
46 GtkWidget *dialog = gtk_dialog_new();
47 GtkWidget *label = gtk_label_new(title);
49 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label);
51 *okay_button = gtk_button_new_with_label((okay_text!=NULL?okay_text:_("Ok")));
52 *cancel_button = gtk_button_new_with_label((cancel_text!=NULL?cancel_text:_("Cancel")));
54 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area),
55 *okay_button);
56 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area),
57 *cancel_button);
59 return dialog;
62 /** Adds a spinbutton with an attached label to a dialog.
63 To get an integer spinbutton, give decimals as 0.
65 GtkSpinButton *
66 dialog_add_spinbutton(GtkWidget *dialog, char *title,
67 real min, real max, real decimals) {
68 GtkAdjustment *limits =
69 GTK_ADJUSTMENT(gtk_adjustment_new(10.0, min, max, 1.0, 10.0, 100.0));
70 GtkWidget *box = gtk_hbox_new(FALSE, 10);
71 GtkWidget *label = gtk_label_new(title);
72 GtkWidget *entry = gtk_spin_button_new(limits, 10.0, decimals);
74 gtk_box_pack_start_defaults(GTK_BOX(box), label);
75 gtk_box_pack_start_defaults(GTK_BOX(box), entry);
76 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), box);
78 return GTK_SPIN_BUTTON(entry);