File: dialogwait.cpp

package info (click to toggle)
bibledit-gtk 4.6-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 31,668 kB
  • ctags: 11,053
  • sloc: xml: 289,607; sql: 160,978; cpp: 86,450; sh: 3,316; makefile: 609; ansic: 398; perl: 143; python: 36
file content (79 lines) | stat: -rw-r--r-- 2,283 bytes parent folder | download
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
/*
** Copyright (©) 2003-2012 Teus Benschop.
**  
** 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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
**  
*/


#include "libraries.h"
#include <gtk/gtk.h>
#include "dialogwait.h"


WaitDialog::WaitDialog(int milliseconds, int width, int height)
{
  waitdialog = gtk_dialog_new();
  gtk_window_set_title(GTK_WINDOW(waitdialog), "Please wait ...");
  gtk_window_set_position(GTK_WINDOW(waitdialog), GTK_WIN_POS_CENTER_ON_PARENT);
  gtk_window_set_modal(GTK_WINDOW(waitdialog), TRUE);
  if (width && height)
    gtk_window_set_default_size(GTK_WINDOW(waitdialog), width, height);

  dialog_vbox1 = GTK_DIALOG(waitdialog)->vbox;
  gtk_widget_show(dialog_vbox1);

  vbox1 = gtk_vbox_new(FALSE, 0);
  gtk_widget_show(vbox1);
  gtk_box_pack_start(GTK_BOX(dialog_vbox1), vbox1, TRUE, TRUE, 0);

  label1 = gtk_label_new("Please hold on ... processing data");
  gtk_widget_show(label1);
  gtk_box_pack_start(GTK_BOX(vbox1), label1, FALSE, FALSE, 0);

  dialog_action_area1 = GTK_DIALOG(waitdialog)->action_area;
  gtk_widget_show(dialog_action_area1);
  gtk_button_box_set_layout(GTK_BUTTON_BOX(dialog_action_area1), GTK_BUTTONBOX_END);

  g_timeout_add(milliseconds, GSourceFunc(static_on_timeout), gpointer(this));
}


WaitDialog::~WaitDialog()
{
  gtk_widget_destroy(waitdialog);
}


int WaitDialog::run()
{
  return gtk_dialog_run(GTK_DIALOG(waitdialog));
}


gboolean WaitDialog::static_on_timeout(gpointer data)
{
  return ((WaitDialog *) data)->on_timeout();
}


bool WaitDialog::on_timeout()
{
  gtk_widget_hide_all(waitdialog);
  gtk_dialog_response(GTK_DIALOG(waitdialog), GTK_RESPONSE_OK);
  return false;
}