2
* This file is part of libslab.
4
* Copyright (c) 2006 Novell, Inc.
6
* Libslab is free software; you can redistribute it and/or modify it under the
7
* terms of the GNU Lesser General Public License as published by the Free
8
* Software Foundation; either version 2 of the License, or (at your option)
11
* Libslab is distributed in the hope that it will be useful, but WITHOUT ANY
12
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with libslab; if not, write to the Free Software Foundation, Inc., 51
18
* Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
#include "shell-window.h"
23
#include <gtk/gtkhbox.h>
24
#include <gtk/gtkalignment.h>
25
#include <gtk/gtkbin.h>
26
#include <gtk/gtkframe.h>
27
#include <gtk/gtklayout.h>
28
#include <gtk/gtkscrolledwindow.h>
30
#include "app-resizer.h"
32
static GtkWindowClass *parent_class = NULL;
34
static void shell_window_class_init (ShellWindowClass *);
35
static void shell_window_init (ShellWindow *);
36
static void shell_window_destroy (GtkObject *);
37
static void shell_window_handle_size_request (GtkWidget * widget, GtkRequisition * requisition,
40
gboolean shell_window_paint_window (GtkWidget * widget, GdkEventExpose * event, gpointer data);
42
#define SHELL_WINDOW_BORDER_WIDTH 6
45
shell_window_get_type (void)
47
static GType object_type = 0;
51
static const GTypeInfo object_info = {
52
sizeof (ShellWindowClass),
55
(GClassInitFunc) shell_window_class_init,
60
(GInstanceInitFunc) shell_window_init
63
object_type = g_type_register_static (
64
GTK_TYPE_FRAME, "ShellWindow", &object_info, 0);
71
shell_window_class_init (ShellWindowClass * klass)
73
parent_class = g_type_class_peek_parent (klass);
75
((GtkObjectClass *) klass)->destroy = shell_window_destroy;
79
shell_window_init (ShellWindow * window)
82
window->_left_pane = NULL;
83
window->_right_pane = NULL;
87
shell_window_new (AppShellData * app_data)
89
ShellWindow *window = g_object_new (SHELL_WINDOW_TYPE, NULL);
91
gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
92
gtk_frame_set_shadow_type(GTK_FRAME(window), GTK_SHADOW_NONE);
94
window->_hbox = GTK_BOX (gtk_hbox_new (FALSE, 0));
95
gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (window->_hbox));
97
g_signal_connect (G_OBJECT (window), "expose-event", G_CALLBACK (shell_window_paint_window),
99
window->resize_handler_id =
100
g_signal_connect (G_OBJECT (window), "size-request",
101
G_CALLBACK (shell_window_handle_size_request), app_data);
103
return GTK_WIDGET (window);
107
shell_window_destroy (GtkObject * obj)
112
shell_window_clear_resize_handler (ShellWindow * win)
114
if (win->resize_handler_id)
116
g_signal_handler_disconnect (win, win->resize_handler_id);
117
win->resize_handler_id = 0;
121
/* We want the window to come up with proper runtime calculated width ( ie taking into account font size, locale, ...) so
122
we can't hard code a size. But since ScrolledWindow returns basically zero for it's size request we need to
123
grab the "real" desired width. Once it's shown though we want to allow the user to size down if they want too, so
124
we unhook this function
127
shell_window_handle_size_request (GtkWidget * widget, GtkRequisition * requisition,
128
AppShellData * app_data)
133
Fixme - counting on this being called after the real size request is done.
134
seems to be that way but I don't know why. I would think I would need to explictly call it here first
135
printf("Enter - shell_window_handle_size_request\n");
136
printf("passed in width:%d, height:%d\n", requisition->width, requisition->height);
137
printf("left side width:%d\n", SHELL_WINDOW(widget)->_left_pane->requisition.width);
138
printf("right side width:%d\n", GTK_WIDGET(APP_RESIZER(app_data->category_layout)->child)->requisition.width);
141
requisition->width +=
142
GTK_WIDGET (APP_RESIZER (app_data->category_layout)->child)->requisition.width;
144
/* use the left side as a minimum height, if the right side is taller,
145
use it up to SIZING_HEIGHT_PERCENT of the screen height
148
GTK_WIDGET (APP_RESIZER (app_data->category_layout)->child)->requisition.height +
150
if (height > requisition->height)
152
requisition->height =
153
MIN (((gfloat) gdk_screen_height () * SIZING_HEIGHT_PERCENT), height);
158
shell_window_set_contents (ShellWindow * shell, GtkWidget * left_pane, GtkWidget * right_pane)
160
shell->_left_pane = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
161
shell->_right_pane = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
163
gtk_alignment_set_padding (GTK_ALIGNMENT (shell->_left_pane), 15, 15, 15, 15);
164
gtk_alignment_set_padding (GTK_ALIGNMENT (shell->_right_pane), 0, 0, 0, 0); /* space for vertical line */
166
gtk_box_pack_start (shell->_hbox, shell->_left_pane, FALSE, FALSE, 0);
167
gtk_box_pack_start (shell->_hbox, shell->_right_pane, TRUE, TRUE, 0); /* this one takes any extra space */
169
gtk_container_add (GTK_CONTAINER (shell->_left_pane), left_pane);
170
gtk_container_add (GTK_CONTAINER (shell->_right_pane), right_pane);
174
shell_window_paint_window (GtkWidget * widget, GdkEventExpose * event, gpointer data)
176
GtkWidget *left_pane, *right_pane;
178
left_pane = SHELL_WINDOW (widget)->_left_pane;
179
right_pane = SHELL_WINDOW (widget)->_right_pane;
181
/* draw left pane background */
182
gtk_paint_flat_box (widget->style, widget->window, widget->state, GTK_SHADOW_NONE, NULL, widget, "",
183
left_pane->allocation.x, left_pane->allocation.y, left_pane->allocation.width,
184
left_pane->allocation.height);