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"
25
#include "app-resizer.h"
27
static void shell_window_class_init (ShellWindowClass *);
28
static void shell_window_init (ShellWindow *);
29
static void shell_window_handle_size_request (GtkWidget * widget, GtkRequisition * requisition,
32
#if GTK_CHECK_VERSION (3, 0, 0)
33
gboolean shell_window_paint_window (GtkWidget * widget, cairo_t * cr, gpointer data);
35
gboolean shell_window_paint_window (GtkWidget * widget, GdkEventExpose * event, gpointer data);
38
#define SHELL_WINDOW_BORDER_WIDTH 6
40
G_DEFINE_TYPE (ShellWindow, shell_window, GTK_TYPE_FRAME);
43
shell_window_class_init (ShellWindowClass * klass)
48
shell_window_init (ShellWindow * window)
51
window->_left_pane = NULL;
52
window->_right_pane = NULL;
56
shell_window_new (AppShellData * app_data)
58
ShellWindow *window = g_object_new (SHELL_WINDOW_TYPE, NULL);
60
gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
61
gtk_frame_set_shadow_type(GTK_FRAME(window), GTK_SHADOW_NONE);
63
window->_hbox = GTK_BOX (gtk_hbox_new (FALSE, 0));
64
gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (window->_hbox));
66
#if GTK_CHECK_VERSION (3, 0, 0)
67
g_signal_connect (G_OBJECT (window), "draw", G_CALLBACK (shell_window_paint_window),
69
g_signal_connect (G_OBJECT (window), "expose-event", G_CALLBACK (shell_window_paint_window),
72
#if GTK_CHECK_VERSION (3, 0, 0)
75
window->resize_handler_id =
76
g_signal_connect (G_OBJECT (window), "size-request",
77
G_CALLBACK (shell_window_handle_size_request), app_data);
80
return GTK_WIDGET (window);
84
shell_window_clear_resize_handler (ShellWindow * win)
86
if (win->resize_handler_id)
88
g_signal_handler_disconnect (win, win->resize_handler_id);
89
win->resize_handler_id = 0;
93
/* We want the window to come up with proper runtime calculated width ( ie taking into account font size, locale, ...) so
94
we can't hard code a size. But since ScrolledWindow returns basically zero for it's size request we need to
95
grab the "real" desired width. Once it's shown though we want to allow the user to size down if they want too, so
96
we unhook this function
99
shell_window_handle_size_request (GtkWidget * widget, GtkRequisition * requisition,
100
AppShellData * app_data)
103
GtkRequisition child_requisiton;
105
#if GTK_CHECK_VERSION (3, 0, 0)
106
gtk_widget_get_preferred_size (GTK_WIDGET (APP_RESIZER (app_data->category_layout)->child), &child_requisiton, NULL);
108
child_requisiton = GTK_WIDGET (APP_RESIZER (app_data->category_layout)->child)->requisition;
112
Fixme - counting on this being called after the real size request is done.
113
seems to be that way but I don't know why. I would think I would need to explictly call it here first
114
printf("Enter - shell_window_handle_size_request\n");
115
printf("passed in width:%d, height:%d\n", requisition->width, requisition->height);
116
printf("left side width:%d\n", SHELL_WINDOW(widget)->_left_pane->requisition.width);
117
printf("right side width:%d\n", GTK_WIDGET(APP_RESIZER(app_data->category_layout)->child)->requisition.width);
120
requisition->width += child_requisiton.width;
122
/* use the left side as a minimum height, if the right side is taller,
123
use it up to SIZING_HEIGHT_PERCENT of the screen height
125
height = child_requisiton.height + 10;
126
if (height > requisition->height)
128
requisition->height =
129
MIN (((gfloat) gdk_screen_height () * SIZING_HEIGHT_PERCENT), height);
134
shell_window_set_contents (ShellWindow * shell, GtkWidget * left_pane, GtkWidget * right_pane)
136
shell->_left_pane = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
137
shell->_right_pane = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
139
gtk_alignment_set_padding (GTK_ALIGNMENT (shell->_left_pane), 15, 15, 15, 15);
140
gtk_alignment_set_padding (GTK_ALIGNMENT (shell->_right_pane), 0, 0, 0, 0); /* space for vertical line */
142
gtk_box_pack_start (shell->_hbox, shell->_left_pane, FALSE, FALSE, 0);
143
gtk_box_pack_start (shell->_hbox, shell->_right_pane, TRUE, TRUE, 0); /* this one takes any extra space */
145
gtk_container_add (GTK_CONTAINER (shell->_left_pane), left_pane);
146
gtk_container_add (GTK_CONTAINER (shell->_right_pane), right_pane);
150
#if GTK_CHECK_VERSION (3, 0, 0)
151
shell_window_paint_window (GtkWidget * widget, cairo_t * cr, gpointer data)
153
shell_window_paint_window (GtkWidget * widget, GdkEventExpose * event, gpointer data)
156
GtkWidget *left_pane, *right_pane;
157
GtkAllocation allocation;
159
left_pane = SHELL_WINDOW (widget)->_left_pane;
160
right_pane = SHELL_WINDOW (widget)->_right_pane;
162
gtk_widget_get_allocation (left_pane, &allocation);
164
/* draw left pane background */
166
gtk_widget_get_style (widget),
167
#if GTK_CHECK_VERSION (3, 0, 0)
170
gtk_widget_get_window (widget),
172
gtk_widget_get_state (widget),
174
#if !GTK_CHECK_VERSION (3, 0, 0)