Commit c0f251b3 authored by Havoc Pennington's avatar Havoc Pennington Committed by Havoc Pennington
Browse files

add a toplevel window widget that snaps to desktop size and sets the right

1999-12-02  Havoc Pennington  <hp@pobox.com>

* src/explorer/desktop-window.h, src/explorer/desktop-window.c:
add a toplevel window widget that snaps to desktop size and sets
the right layer hints
parent 2f1064ff
/* -*- Mode: C; c-set-style: linux; indent-tabs-mode: nil; c-basic-offset: 8 -*-
* Desktop component of GNOME file manager
*
* Copyright (C) 1999 Red Hat Inc., Free Software Foundation
* (based on Midnight Commander code by Federico Mena Quintero and Miguel de Icaza)
*
* 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
*/
#include <config.h>
#include "desktopwindow.h"
#include <libgnomeui/gnome-winhints.h>
static void desktop_window_class_init (DesktopWindowClass *class);
static void desktop_window_init (DesktopWindow *dwindow);
static void desktop_window_realize (GtkWidget *widget);
static GtkWindowClass *parent_class;
/**
* desktop_window_get_type
*
* Returns the Gtk type assigned to the DesktopWindow class.
*/
GtkType
desktop_window_get_type (void)
{
static GtkType desktop_window_type = 0;
if (!desktop_window_type) {
GtkTypeInfo desktop_window_info = {
"DesktopWindow",
sizeof (DesktopWindow),
sizeof (DesktopWindowClass),
(GtkClassInitFunc) desktop_window_class_init,
(GtkObjectInitFunc) desktop_window_init,
NULL, /* reserved_1 */
NULL, /* reserved_2 */
(GtkClassInitFunc) NULL
};
desktop_window_type = gtk_type_unique (gtk_window_get_type (), &desktop_window_info);
}
return desktop_window_type;
}
static void
desktop_window_class_init (DesktopWindowClass *class)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = (GtkObjectClass *) class;
widget_class = (GtkWidgetClass *) class;
parent_class = gtk_type_class (gtk_window_get_type ());
widget_class->realize = desktop_window_realize;
}
static void
desktop_window_init (DesktopWindow *dwindow)
{
/* Should never resize this thing */
gtk_window_set_policy(GTK_WINDOW(dwindow),
FALSE, FALSE, FALSE);
/* Match the screen size */
gtk_widget_set_usize(GTK_WIDGET(dwindow),
gdk_screen_width(),
gdk_screen_height());
}
static void
desktop_window_realize (GtkWidget *widget)
{
DesktopWindow *dwindow;
g_return_if_fail (widget != NULL);
g_return_if_fail (IS_DESKTOP_WINDOW (widget));
dwindow = DESKTOP_WINDOW (widget);
if (GTK_WIDGET_CLASS (parent_class)->realize)
(* GTK_WIDGET_CLASS (parent_class)->realize) (widget);
/* Turn off all decorations and window manipulation functions */
gdk_window_set_decorations(widget->window, 0);
gdk_window_set_functions(widget->window, 0);
/* Set the proper GNOME hints */
gnome_win_hints_init ();
if (gnome_win_hints_wm_exists ()) {
gnome_win_hints_set_layer (widget, WIN_LAYER_DESKTOP);
gnome_win_hints_set_state (widget,
WIN_STATE_FIXED_POSITION
| WIN_STATE_ARRANGE_IGNORE
| WIN_STATE_STICKY);
gnome_win_hints_set_hints (widget,
WIN_HINTS_SKIP_FOCUS
| WIN_HINTS_SKIP_WINLIST
| WIN_HINTS_SKIP_TASKBAR);
} else {
g_warning("window manager doesn't like us");
}
}
GtkWidget*
desktop_window_new (void)
{
DesktopWindow *dwindow;
dwindow = gtk_type_new(desktop_window_get_type());
return GTK_WIDGET(dwindow);
}
/* -*- Mode: C; c-set-style: linux; indent-tabs-mode: nil; c-basic-offset: 8 -*-
* Desktop component of GNOME file manager
*
* Copyright (C) 1999 Red Hat Inc., Free Software Foundation
* (based on Midnight Commander code by Federico Mena Quintero and Miguel de Icaza)
*
* 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 GD_DESKTOP_WINDOW_H
#define GD_DESKTOP_WINDOW_H
#include <libgnome/gnome-defs.h>
#include <gtk/gtkwindow.h>
BEGIN_GNOME_DECLS
#define TYPE_DESKTOP_WINDOW (desktop_window_get_type ())
#define DESKTOP_WINDOW(obj) (GTK_CHECK_CAST ((obj), TYPE_DESKTOP_WINDOW, DesktopWindow))
#define DESKTOP_WINDOW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), TYPE_DESKTOP_WINDOW, DesktopWindowClass))
#define IS_DESKTOP_WINDOW(obj) (GTK_CHECK_TYPE ((obj), TYPE_DESKTOP_WINDOW))
#define IS_DESKTOP_WINDOW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), TYPE_DESKTOP_WINDOW))
typedef struct _DesktopWindow DesktopWindow;
typedef struct _DesktopWindowClass DesktopWindowClass;
struct _DesktopWindow {
GtkWindow window;
};
struct _DesktopWindowClass {
GtkWindowClass parent_class;
};
/* Standard Gtk function */
GtkType desktop_window_get_type (void);
GtkWidget *desktop_window_new (void);
END_GNOME_DECLS
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment