File: rguserdialog.h

package info (click to toggle)
synaptic 0.81.2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 20,184 kB
  • ctags: 2,538
  • sloc: cpp: 24,326; xml: 7,938; ansic: 2,084; makefile: 578; sh: 438; sed: 93; python: 82
file content (94 lines) | stat: -rw-r--r-- 2,775 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* rguserdialog.h
 *
 * Copyright (c) 2000, 2001 Conectiva S/A
 *               2003 Michael Vogt
 *
 * Author: Alfredo K. Kojima <kojima@conectiva.com.br>
 *         Michael Vogt <mvo@debian.org>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */

#ifndef RGUSERDIALOG_H
#define RGUSERDIALOG_H

#include "ruserdialog.h"
#include "rgwindow.h"

class RGUserDialog : public RUserDialog
{
protected:

    GtkWidget *_parentWindow;

public:

    RGUserDialog() : _parentWindow(0) {};
    RGUserDialog(RGWindow *parent) : _parentWindow(parent->window()) {};
    RGUserDialog(GtkWidget *parent) : _parentWindow(parent) {};
    
    virtual bool showErrors();

    virtual bool message(const char *msg,
	    RUserDialog::DialogType dialog=RUserDialog::DialogInfo,
	    RUserDialog::ButtonsType buttons=RUserDialog::ButtonsOk,
	    bool defres=true);

};


/*
 * A alternative interface for the ruserdialog, here is how it works:
 * the gtkbuilder file must called "dialog_$NAME.ui"
 * the buttons must have valid RESPONSE_IDs attached
 * see gtkbuilder/dialog_quit.ui as an example
 * Example:
  	RGGtkBuilderUserDialog dia(this);
	// return true is user clicked on a button with GTK_RESPONSE_OK
	if(dia->run("quit")) {
	    do_response_ok_stuff();
	} else {
            do_not_ok_stuff();
        }
 *
 * 
 * if you need more complex interaction, use the getGtkBuilder() call to ask
 * for specific widgets in the dialog (see gtkbuilder/dialog_upgrade.ui as
 * example.
*/
class RGGtkBuilderUserDialog : public RGUserDialog
{
 protected:
    GtkWidget *_dialog;
    GtkResponseType res;
    GtkBuilder *builder;
    bool init(const char *name);

 public:
    RGGtkBuilderUserDialog(RGWindow* parent) : builder(0) {};
    RGGtkBuilderUserDialog(RGWindow* parent, const char *name);
    virtual ~RGGtkBuilderUserDialog()  { gtk_widget_destroy(_dialog); };

    void setTitle(string title) { 
       gtk_window_set_title(GTK_WINDOW(_dialog),title.c_str());
    }

    int run(const char *name=NULL, bool return_gtk_response=false);
    GtkBuilder *getGtkBuilder() { return builder; };
};
#endif

// vim:sts=4:sw=4