Gtk2

 view release on metacpan or  search on metacpan

xs/GtkWindow.xs  view on Meta::CPAN

/*
 * Copyright (c) 2003-2006, 2009 by the gtk2-perl team (see the file AUTHORS)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the 
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
 * Boston, MA  02110-1301  USA.
 *
 * $Id$
 */

#include "gtk2perl.h"

MODULE = Gtk2::Window	PACKAGE = Gtk2::Window	PREFIX = gtk_window_

=for position DESCRIPTION

=head1 DESCRIPTION

A Gtk2::Window is a top-level window displayed on the root window and
interacting (or not) with the window manager.  It can be an
application's main window, a dialog, or a temporary such as a popup
splash window.

=head2 Delete Event and Destroy

The default action for a C<delete-event> (normally from the window
manager close button) is to destroy the window with
C<< $window->destroy >>.  In your main window you might want to exit
the main loop when that happens.

    $toplevel->signal_connect (destroy => sub { Gtk2->main_quit });

If you install a handler for C<delete-event> and return true, meaning
"don't propagate", you can do something other than destroy the window.
For example

    $toplevel->signal_connect (delete_event => sub {
       if (any_unsaved_documents()) {
         popup_ask_save_before_exit_dialog();
         return Gtk2::EVENT_STOP;  # don't go to default destroy
       } else {
         return Gtk2::EVENT_PROPAGATE;
       }
    });

In a dialog or secondary app window you might not want to destroy but
instead just hide ready for later re-use.

    $dialog->signal_connect
      (delete_event => \&Gtk2::Widget::hide_on_delete);

The choice between destroying or hiding is normally just a matter of
memory saved against the time to re-create, and how likely the dialog
might be needed again.  (However if you build windows with Glade it's
not particularly easy to re-create them there, so you'll mostly want
to just hide in that case.)

A hidden toplevel window is still in
C<< Gtk2::Window->list_toplevels >> and that's a good place to search
for an existing window of a desired type to C<< $window->present >>
again.

=cut

=for enum GtkWindowPosition
=cut

=for enum GtkWindowType
=cut

## GtkWidget* gtk_window_new (GtkWindowType type)
GtkWidget *
gtk_window_new (class, type=GTK_WINDOW_TOPLEVEL)
	GtkWindowType   type
    C_ARGS:
	type

## void gtk_window_set_title (GtkWindow *window, const gchar *title)
void
gtk_window_set_title (window, title=NULL)
	GtkWindow          * window
	const gchar_ornull * title

## void gtk_window_set_wmclass (GtkWindow *window, const gchar *wmclass_name, const gchar *wmclass_class)
void
gtk_window_set_wmclass (window, wmclass_name, wmclass_class)
	GtkWindow   * window
	const gchar * wmclass_name
	const gchar * wmclass_class

## void gtk_window_set_role (GtkWindow *window, const gchar *role)
void
gtk_window_set_role (window, role)
	GtkWindow   * window
	const gchar * role

##G_CONST_RETURN gchar* gtk_window_get_role   (GtkWindow *window)
const gchar *
gtk_window_get_role (window)



( run in 1.106 second using v1.01-cache-2.11-cpan-364913b4093 )