[280] | 1 | /* rgwindow.cc |
---|
| 2 | * |
---|
| 3 | * Copyright (c) 2000, 2001 Conectiva S/A |
---|
| 4 | * |
---|
| 5 | * Author: Alfredo K. Kojima <kojima@conectiva.com.br> |
---|
| 6 | * |
---|
| 7 | * This program is free software; you can redistribute it and/or |
---|
| 8 | * modify it under the terms of the GNU General Public License as |
---|
| 9 | * published by the Free Software Foundation; either version 2 of the |
---|
| 10 | * License, or (at your option) any later version. |
---|
| 11 | * |
---|
| 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. |
---|
| 16 | * |
---|
| 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 |
---|
| 20 | * USA |
---|
| 21 | */ |
---|
| 22 | |
---|
| 23 | |
---|
| 24 | #include <apt-pkg/fileutl.h> |
---|
| 25 | #include "config.h" |
---|
| 26 | #include "i18n.h" |
---|
| 27 | #include "rgwindow.h" |
---|
| 28 | |
---|
| 29 | |
---|
| 30 | bool RGWindow::windowCloseCallback(GtkWidget *window, GdkEvent * event) |
---|
| 31 | { |
---|
| 32 | //cout << "windowCloseCallback" << endl; |
---|
| 33 | RGWindow *rwin = (RGWindow *) gtk_object_get_data(GTK_OBJECT(window), "me"); |
---|
| 34 | |
---|
| 35 | return rwin->close(); |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | RGWindow::RGWindow(string name, bool makeBox) |
---|
| 39 | { |
---|
| 40 | //std::cout << "RGWindow::RGWindow(string name, bool makeBox)" << endl; |
---|
| 41 | _win = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
---|
| 42 | gtk_window_set_title(GTK_WINDOW(_win), (char *)name.c_str()); |
---|
| 43 | |
---|
| 44 | gtk_object_set_data(GTK_OBJECT(_win), "me", this); |
---|
| 45 | gtk_signal_connect(GTK_OBJECT(_win), "delete-event", |
---|
| 46 | (GtkSignalFunc) windowCloseCallback, this); |
---|
| 47 | |
---|
| 48 | if (makeBox) { |
---|
| 49 | _topBox = gtk_vbox_new(FALSE, 0); |
---|
| 50 | gtk_container_add(GTK_CONTAINER(_win), _topBox); |
---|
| 51 | gtk_widget_show(_topBox); |
---|
| 52 | gtk_container_set_border_width(GTK_CONTAINER(_topBox), 5); |
---|
| 53 | } else { |
---|
| 54 | _topBox = NULL; |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | //gtk_widget_realize(_win); |
---|
| 58 | //gtk_widget_show_all(_win); |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | |
---|
| 62 | RGWindow::RGWindow(RGWindow *parent, string name, bool makeBox, bool closable) |
---|
| 63 | { |
---|
| 64 | //std::cout |
---|
| 65 | //<< "RGWindow::RGWindow(RGWindow *parent, string name, bool makeBox, bool closable)" |
---|
| 66 | //<< endl; |
---|
| 67 | _win = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
---|
| 68 | gtk_window_set_title(GTK_WINDOW(_win), (char *)name.c_str()); |
---|
| 69 | |
---|
| 70 | gtk_object_set_data(GTK_OBJECT(_win), "me", this); |
---|
| 71 | |
---|
| 72 | gtk_signal_connect(GTK_OBJECT(_win), "delete-event", |
---|
| 73 | (GtkSignalFunc) windowCloseCallback, this); |
---|
| 74 | |
---|
| 75 | if (makeBox) { |
---|
| 76 | _topBox = gtk_vbox_new(FALSE, 0); |
---|
| 77 | gtk_container_add(GTK_CONTAINER(_win), _topBox); |
---|
| 78 | gtk_widget_show(_topBox); |
---|
| 79 | gtk_container_set_border_width(GTK_CONTAINER(_topBox), 5); |
---|
| 80 | } else { |
---|
| 81 | _topBox = NULL; |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | //gtk_widget_realize(_win); |
---|
| 85 | |
---|
| 86 | gtk_window_set_transient_for(GTK_WINDOW(_win), |
---|
| 87 | GTK_WINDOW(parent->window())); |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | |
---|
| 91 | RGWindow::~RGWindow() |
---|
| 92 | { |
---|
| 93 | //cout << "~RGWindow"<<endl; |
---|
| 94 | gtk_widget_destroy(_win); |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | |
---|
| 98 | void RGWindow::setTitle(string title) |
---|
| 99 | { |
---|
| 100 | gtk_window_set_title(GTK_WINDOW(_win), (char *)title.c_str()); |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | bool RGWindow::close() |
---|
| 104 | { |
---|
| 105 | //cout << "RGWindow::close()" << endl; |
---|
| 106 | hide(); |
---|
| 107 | return true; |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | // vim:ts=3:sw=3:et |
---|