File: dialogs.cc

package info (click to toggle)
gnomemm 1.2.2-6
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,936 kB
  • ctags: 902
  • sloc: sh: 8,854; cpp: 4,616; perl: 1,220; makefile: 622; ansic: 14
file content (133 lines) | stat: -rw-r--r-- 3,571 bytes parent folder | download | duplicates (3)
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/* dialogs.cc
 *
 * Copyright 2000 Karl Nelson
 *
 */


#include <gnome.h>
#include <gtk--/button.h>
#include <gtk--/frame.h>
#include <gtk--/table.h>
#include <gnome--/app.h>
#include <gnome--/main.h>

using SigC::slot;

class App : public Gnome::App
  {
    public:
      App();
      virtual ~App();
  
     static void make_ok();
     static void make_warning();
     static void make_error();
     static void make_ok_cancel();
     static void make_ok_cancel_m();
     static void make_question();
     static void make_question_m();
     static void make_request();
     static void make_request_h();

     static void reply(int i) { cout << "Reply "<<i <<endl;}
     static void stringcb(string i) { cout << "String "<<i <<endl;}

   protected:
     void init();

     //Override:
     gint delete_event_impl(GdkEventAny*);     
  };

App::App()
  : Gnome::App("GnomeDialogs", "Gnome Dialogs")
  {
    init();
  }

App::~App()
  {}

void App::init()
  {
    Gtk::Table *table=manage(new Gtk::Table(3,3));
    Gtk::Button *button;
    button=manage(new Gtk::Button("Ok"));
    button->clicked.connect(slot(&App::make_ok));
    table->attach(*button,0,1,0,1);

    button=manage(new Gtk::Button("Warning"));
    button->clicked.connect(slot(&App::make_warning));
    table->attach(*button,0,1,1,2);

    button=manage(new Gtk::Button("Error"));
    button->clicked.connect(slot(&App::make_error));
    table->attach(*button,0,1,2,3);

    button=manage(new Gtk::Button("Ok_Cancel"));
    button->clicked.connect(slot(&App::make_ok_cancel));
    table->attach(*button,1,2,0,1);

    button=manage(new Gtk::Button("Ok_Cancel(M)"));
    button->clicked.connect(slot(&App::make_ok_cancel_m));
    table->attach(*button,2,3,0,1);

    button=manage(new Gtk::Button("Question"));
    button->clicked.connect(slot(&App::make_question));
    table->attach(*button,1,2,1,2);

    button=manage(new Gtk::Button("Question(M)"));
    button->clicked.connect(slot(&App::make_question_m));
    table->attach(*button,2,3,1,2);

    button=manage(new Gtk::Button("Request"));
    button->clicked.connect(slot(&App::make_request));
    table->attach(*button,1,2,2,3);

    button=manage(new Gtk::Button("Request(H)"));
    button->clicked.connect(slot(&App::make_request_h));
    table->attach(*button,2,3,2,3);
    
    Gtk::Frame *frame=manage(new Gtk::Frame);
    frame->add(*table);
    frame->set_shadow_type(GTK_SHADOW_IN);

    set_contents(*frame);
    show_all();
  }

void App::make_ok() 
  { Gnome::Dialogs::ok("Everything is 5 by 5."); }
void App::make_warning() 
  { Gnome::Dialogs::warning("Danger! Danger!"); }
void App::make_error()  
  { Gnome::Dialogs::error("Ack! My heart!"); }
void App::make_ok_cancel() 
  { Gnome::Dialogs::ok_cancel("Format hardrive?",slot(&App::reply)); }
void App::make_ok_cancel_m() 
  { Gnome::Dialogs::ok_cancel_modal("Format hardrive?",slot(&App::reply)); } 
void App::make_question()
  { Gnome::Dialogs::question("Do you like green eggs and ham?",slot(&App::reply)); } 
void App::make_question_m()
  { Gnome::Dialogs::question_modal("Do you like green eggs and ham?",slot(&App::reply)); } 
void App::make_request()
  { Gnome::Dialogs::request(false, "What is your name?", "John Doe", 50, slot(&App::stringcb)); }
void App::make_request_h()
  { Gnome::Dialogs::request(true, "Password?", "", 50, slot(&App::stringcb)); }

gint App::delete_event_impl(GdkEventAny*)
{ 
  Gtk::Main::quit();
  return 0; 
}

int main(int argc, char* argv[])
{
  Gnome::Main kit("GnomeDialogs", "0.1", argc, argv );
  App myApp;
  kit.run();

  return 0;
}