Search
lxdream.org :: lxdream :: r486:9af294489aad
lxdream 0.9.1
released Jun 29
Download Now
changeset486:9af294489aad
parent485:dfa6bd020c11
child487:b34abd796f5e
authornkeynes
dateFri Nov 02 08:22:33 2007 +0000 (12 years ago)
Implement (fairly naive) fullscreen mode
src/gui/gtkcb.c
src/gui/gtkui.c
src/gui/gtkui.h
src/gui/main_win.c
1.1 --- a/src/gui/gtkcb.c Wed Oct 31 12:43:51 2007 +0000
1.2 +++ b/src/gui/gtkcb.c Fri Nov 02 08:22:33 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: gtkcb.c,v 1.7 2007-10-31 11:53:35 nkeynes Exp $
1.6 + * $Id: gtkcb.c,v 1.8 2007-11-02 08:22:32 nkeynes Exp $
1.7 *
1.8 * Action callbacks from the main window
1.9 *
1.10 @@ -205,6 +205,7 @@
1.11
1.12 void fullscreen_toggle_callback( GtkToggleAction *action, gpointer user_data)
1.13 {
1.14 + main_window_set_fullscreen(gtk_gui_get_main(), gtk_toggle_action_get_active(action));
1.15 }
1.16
1.17 void debugger_action_callback( GtkAction *action, gpointer user_data)
2.1 --- a/src/gui/gtkui.c Wed Oct 31 12:43:51 2007 +0000
2.2 +++ b/src/gui/gtkui.c Fri Nov 02 08:22:33 2007 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: gtkui.c,v 1.10 2007-10-31 11:53:35 nkeynes Exp $
2.6 + * $Id: gtkui.c,v 1.11 2007-11-02 08:22:32 nkeynes Exp $
2.7 *
2.8 * Core GTK-based user interface
2.9 *
2.10 @@ -198,7 +198,6 @@
2.11 gtk_gui_enable_action("AudioSettings", FALSE);
2.12 gtk_gui_enable_action("NetworkSettings", FALSE);
2.13 gtk_gui_enable_action("VideoSettings", FALSE);
2.14 - gtk_gui_enable_action("FullScreen", FALSE);
2.15
2.16 global_ui_manager = gtk_ui_manager_new();
2.17 gtk_ui_manager_set_add_tearoffs(global_ui_manager, TRUE);
3.1 --- a/src/gui/gtkui.h Wed Oct 31 12:43:51 2007 +0000
3.2 +++ b/src/gui/gtkui.h Fri Nov 02 08:22:33 2007 +0000
3.3 @@ -1,5 +1,5 @@
3.4 /**
3.5 - * $Id: gtkui.h,v 1.10 2007-10-31 11:53:35 nkeynes Exp $
3.6 + * $Id: gtkui.h,v 1.11 2007-11-02 08:22:32 nkeynes Exp $
3.7 *
3.8 * Core GTK-based user interface
3.9 *
3.10 @@ -42,6 +42,7 @@
3.11 void main_window_set_running( main_window_t win, gboolean running );
3.12 void main_window_set_framerate( main_window_t win, float rate );
3.13 void main_window_set_speed( main_window_t win, double speed );
3.14 +void main_window_set_fullscreen( main_window_t win, gboolean fullscreen );
3.15
3.16 debug_window_t debug_window_new( const gchar *title, GtkWidget *menubar,
3.17 GtkWidget *toolbar, GtkAccelGroup *accel );
4.1 --- a/src/gui/main_win.c Wed Oct 31 12:43:51 2007 +0000
4.2 +++ b/src/gui/main_win.c Fri Nov 02 08:22:33 2007 +0000
4.3 @@ -1,5 +1,5 @@
4.4 /**
4.5 - * $Id: main_win.c,v 1.8 2007-10-31 11:53:35 nkeynes Exp $
4.6 + * $Id: main_win.c,v 1.9 2007-11-02 08:22:33 nkeynes Exp $
4.7 *
4.8 * Define the main (emu) GTK window, along with its menubars,
4.9 * toolbars, etc.
4.10 @@ -34,15 +34,26 @@
4.11 struct main_window_info {
4.12 GtkWidget *window;
4.13 GtkWidget *video;
4.14 + GtkWidget *menubar;
4.15 + GtkWidget *toolbar;
4.16 GtkWidget *statusbar;
4.17 GtkActionGroup *actions;
4.18 };
4.19
4.20 -gboolean on_main_window_deleted( GtkWidget *widget, GdkEvent event, gpointer user_data )
4.21 +static gboolean on_main_window_deleted( GtkWidget *widget, GdkEvent event, gpointer user_data )
4.22 {
4.23 exit(0);
4.24 }
4.25
4.26 +static void on_main_window_state_changed( GtkWidget *widget, GdkEventWindowState *state,
4.27 + gpointer userdata )
4.28 +{
4.29 + if( state->changed_mask & GDK_WINDOW_STATE_FULLSCREEN ) {
4.30 + gboolean fs = (state->new_window_state & GDK_WINDOW_STATE_FULLSCREEN);
4.31 + }
4.32 + return FALSE;
4.33 +}
4.34 +
4.35 main_window_t main_window_new( const gchar *title, GtkWidget *menubar, GtkWidget *toolbar,
4.36 GtkAccelGroup *accel_group )
4.37 {
4.38 @@ -51,6 +62,8 @@
4.39 main_window_t win = g_malloc0( sizeof(struct main_window_info) );
4.40
4.41 win->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
4.42 + win->menubar = menubar;
4.43 + win->toolbar = toolbar;
4.44 gtk_window_set_title( GTK_WINDOW(win->window), title );
4.45 gtk_window_add_accel_group (GTK_WINDOW (win->window), accel_group);
4.46
4.47 @@ -77,6 +90,8 @@
4.48 gtk_statusbar_push( GTK_STATUSBAR(win->statusbar), 1, "Stopped" );
4.49 g_signal_connect( win->window, "delete_event",
4.50 G_CALLBACK(on_main_window_deleted), win );
4.51 + g_signal_connect( win->window, "window-state-event",
4.52 + G_CALLBACK(on_main_window_state_changed), win );
4.53 return win;
4.54 }
4.55
4.56 @@ -114,3 +129,27 @@
4.57 {
4.58 return GTK_WINDOW(win->window);
4.59 }
4.60 +
4.61 +void main_window_set_fullscreen( main_window_t win, gboolean fullscreen )
4.62 +{
4.63 + GtkWidget *frame = gtk_widget_get_parent(win->video);
4.64 + if( frame->style == NULL ) {
4.65 + gtk_widget_set_style( frame, gtk_style_new() );
4.66 + }
4.67 + if( fullscreen ) {
4.68 + gtk_window_fullscreen( GTK_WINDOW(win->window) );
4.69 + gtk_widget_hide( win->menubar );
4.70 + gtk_widget_hide( win->toolbar );
4.71 + gtk_widget_hide( win->statusbar );
4.72 +
4.73 + frame->style->xthickness = 0;
4.74 + frame->style->ythickness = 0;
4.75 + } else {
4.76 + gtk_window_unfullscreen( GTK_WINDOW(win->window) );
4.77 + frame->style->xthickness = 2;
4.78 + frame->style->ythickness = 2;
4.79 + gtk_widget_show( win->menubar );
4.80 + gtk_widget_show( win->toolbar );
4.81 + gtk_widget_show( win->statusbar );
4.82 + }
4.83 +}
.