View fullscreen patch



Hi all,

Here's a patch that add a ViewFullscreen command to gIDE. (View menu,
Full Screen menuitem). The code is mostly copied from galeon, but
changed a bit so it works with gIDE.

Jeroen
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gIDE/ChangeLog,v
retrieving revision 1.135
diff -u -r1.135 ChangeLog
--- ChangeLog	2001/08/26 09:38:58	1.135
+++ ChangeLog	2001/08/26 21:51:21
@@ -1,3 +1,9 @@
+2001-08-26  Jeroen Zwartepoorte <jeroen xs4all nl>
+
+	* src/gide.xml: Added ViewFullscreen command
+	
+	* src/gIwindow.c: Implemented ViewFullscreen command
+
 2001-08-26  JP Rosevear  <jpr ximian com>
 
 	* src/gide.xml: edit menu placeholder names
Index: src/gI_window.c
===================================================================
RCS file: /cvs/gnome/gIDE/src/gI_window.c,v
retrieving revision 1.38
diff -u -r1.38 gI_window.c
--- src/gI_window.c	2001/08/08 20:11:03	1.38
+++ src/gI_window.c	2001/08/26 21:51:27
@@ -70,6 +70,57 @@
 		gdk_window_raise (GTK_WIDGET (about)->window);
 }
 
+static void
+view_fullscreen_cmd (BonoboUIComponent           *component,
+		     const char                  *path,
+		     Bonobo_UIComponent_EventType type,
+		     const char                  *state,
+		     GideWindow                  *window)
+{
+	GdkWindow *gdk_window = GTK_WIDGET (window)->window;
+	gint client_x, client_y, root_x, root_y;
+	gint width, height;
+	gboolean fullscreen = atoi (state);
+	GtkAllocation *alloc;
+
+	if (fullscreen) /* Get to the top */		
+		gnome_win_hints_set_layer (GTK_WIDGET (window), 
+					   WIN_LAYER_ABOVE_DOCK);
+	else /* Down boy! */		
+		gnome_win_hints_set_layer (GTK_WIDGET (window), 
+					   WIN_LAYER_NORMAL);
+
+	/* Make sure it's raised */
+	gdk_window_raise (gdk_window);
+	
+	/* Window possize & position data */
+	alloc = gtk_object_get_data (GTK_OBJECT (window), "windowpos");
+	if (!alloc) {
+		alloc = g_new0 (GtkAllocation, 1);
+		gtk_object_set_data (GTK_OBJECT (window), "windowpos", alloc);
+	}
+	
+	if (fullscreen) { /* Go to fullscreen */
+		gdk_window_get_origin (gdk_window, &root_x, &root_y);
+		gdk_window_get_geometry (gdk_window, &client_x, &client_y,
+					 &width, &height, NULL);
+
+		gdk_window_move_resize (gdk_window, -client_x, -client_y,
+					gdk_screen_width () + 1,
+					gdk_screen_height () + 1);
+		
+		alloc->x = root_x - client_x;
+		alloc->y = root_y - client_y;
+		alloc->width = width;
+		alloc->height = height;
+	} else { /* Restore window size & position */
+		gdk_window_move_resize (gdk_window, 
+					alloc->x, alloc->y,
+					alloc->width, 
+					alloc->height);
+	}
+}
+
 /* Menu verbs */
 static BonoboUIVerb verbs [] = {
 	BONOBO_UI_UNSAFE_VERB ("FileExit", tmp_exit),
@@ -182,6 +233,9 @@
 
 	bonobo_ui_util_set_ui (window->uic, GNOME_DATADIR, "gide.xml", "gide");
 	
+	bonobo_ui_component_add_listener (window->uic, "ViewFullscreen", 
+					  view_fullscreen_cmd, window);
+	
 	window->ui_container = ui_container;
 
 	for (i = 0; i < GIDE_WINDOW_LOC_LAST; i++) {
@@ -396,8 +450,12 @@
 gI_window_destroy (GtkWidget *widget, gpointer data)
 {
 	GideWindow *window;
+	GtkAllocation *alloc;
 
 	g_assert (IS_GIDE_WINDOW (widget));
 
 	window = GIDE_WINDOW (widget);
+	
+	alloc = gtk_object_get_data (GTK_OBJECT (window), "windowpos");
+	g_free (alloc);
 }
Index: src/gide.xml
===================================================================
RCS file: /cvs/gnome/gIDE/src/gide.xml,v
retrieving revision 1.6
diff -u -r1.6 gide.xml
--- src/gide.xml	2001/08/26 09:38:59	1.6
+++ src/gide.xml	2001/08/26 21:51:28
@@ -5,6 +5,9 @@
 		<cmd name="FileExit" _label="Exit" _tip="Exit the program"
 		pixtype="stock" pixname="Quit" accel="*Control*q"/>
 
+		<cmd name="ViewFullscreen" type="toggle" id="ViewFullscreen" 
+		_label="_Full screen" _tip="View the IDE in fullscreen mode"/>
+
 		<cmd name="SettingsSettings" _label="_Settings..."
                 _tip="Set application preferences" pixtype="stock" pixname="Preferences"/>
 
@@ -43,6 +46,14 @@
 
 			<placeholder/>
 
+		</submenu>
+
+		<submenu name="View" _label="_View">
+		
+			<menuitem name="ViewFullscreen" verb=""/>
+			
+			<placeholder/>
+		
 		</submenu>
 
                 <placeholder/>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]