1 | /* rguserdialog.h |
---|
2 | * |
---|
3 | * Copyright (c) 2000, 2001 Conectiva S/A |
---|
4 | * 2003 Michael Vogt |
---|
5 | * |
---|
6 | * Author: Alfredo K. Kojima <kojima@conectiva.com.br> |
---|
7 | * Michael Vogt <mvo@debian.org> |
---|
8 | * |
---|
9 | * This program is free software; you can redistribute it and/or |
---|
10 | * modify it under the terms of the GNU General Public License as |
---|
11 | * published by the Free Software Foundation; either version 2 of the |
---|
12 | * License, or (at your option) any later version. |
---|
13 | * |
---|
14 | * This program is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this program; if not, write to the Free Software |
---|
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
---|
22 | * USA |
---|
23 | */ |
---|
24 | |
---|
25 | #ifndef RGUSERDIALOG_H |
---|
26 | #define RGUSERDIALOG_H |
---|
27 | |
---|
28 | #include <glade/glade.h> |
---|
29 | #include "ruserdialog.h" |
---|
30 | #include "rgwindow.h" |
---|
31 | |
---|
32 | class RGUserDialog : public RUserDialog |
---|
33 | { |
---|
34 | protected: |
---|
35 | |
---|
36 | GtkWidget *_parentWindow; |
---|
37 | |
---|
38 | public: |
---|
39 | |
---|
40 | RGUserDialog() : _parentWindow(0) {}; |
---|
41 | RGUserDialog(RGWindow *parent) : _parentWindow(parent->window()) {}; |
---|
42 | RGUserDialog(GtkWidget *parent) : _parentWindow(parent) {}; |
---|
43 | |
---|
44 | virtual bool showErrors(); |
---|
45 | |
---|
46 | virtual bool message(const char *msg, |
---|
47 | RUserDialog::DialogType dialog=RUserDialog::DialogInfo, |
---|
48 | RUserDialog::ButtonsType buttons=RUserDialog::ButtonsOk, |
---|
49 | bool defres=true); |
---|
50 | |
---|
51 | }; |
---|
52 | |
---|
53 | |
---|
54 | /* |
---|
55 | * A alternative interface for the ruserdialog, here is how it works: |
---|
56 | * the glade file must called "dialog_$NAME.glade" |
---|
57 | * the buttons must have valid RESPONSE_IDs attached |
---|
58 | * see gtk/dialog_quit.glade as an example |
---|
59 | * Example: |
---|
60 | RGGladeUserDialog dia(this); |
---|
61 | // return true is user clicked on a button with GTK_RESPONSE_OK |
---|
62 | if(dia->run("quit")) { |
---|
63 | do_response_ok_stuff(); |
---|
64 | } else { |
---|
65 | do_not_ok_stuff(); |
---|
66 | } |
---|
67 | * |
---|
68 | * |
---|
69 | * if you need more complex interaction, use the getGladeXML() call to ask |
---|
70 | * for specific widgets in the dialog (see gtk/dialog_upgrade.glade as example |
---|
71 | */ |
---|
72 | class RGGladeUserDialog : public RGUserDialog |
---|
73 | { |
---|
74 | protected: |
---|
75 | GtkWidget *_dialog; |
---|
76 | GtkResponseType res; |
---|
77 | GladeXML *gladeXML; |
---|
78 | bool init(const char *name); |
---|
79 | |
---|
80 | public: |
---|
81 | RGGladeUserDialog(RGWindow* parent) : gladeXML(0) {}; |
---|
82 | RGGladeUserDialog(RGWindow* parent, const char *name); |
---|
83 | virtual ~RGGladeUserDialog() { gtk_widget_destroy(_dialog); }; |
---|
84 | |
---|
85 | void setTitle(string title) { |
---|
86 | gtk_window_set_title(GTK_WINDOW(_dialog),title.c_str()); |
---|
87 | } |
---|
88 | |
---|
89 | int run(const char *name=NULL, bool return_gtk_response=false); |
---|
90 | GladeXML *getGladeXML() { return gladeXML; }; |
---|
91 | }; |
---|
92 | #endif |
---|
93 | |
---|
94 | // vim:sts=4:sw=4 |
---|