Search
lxdream.org :: lxdream/src/gui/main_win.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/main_win.c
changeset 486:9af294489aad
prev480:d28c2992f5ee
next497:cd6e10c2e96b
author nkeynes
date Fri Nov 02 08:22:33 2007 +0000 (12 years ago)
permissions -rw-r--r--
last change Implement (fairly naive) fullscreen mode
file annotate diff log raw
1.1 --- a/src/gui/main_win.c Wed Oct 31 11:53:35 2007 +0000
1.2 +++ b/src/gui/main_win.c Fri Nov 02 08:22:33 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: main_win.c,v 1.8 2007-10-31 11:53:35 nkeynes Exp $
1.6 + * $Id: main_win.c,v 1.9 2007-11-02 08:22:33 nkeynes Exp $
1.7 *
1.8 * Define the main (emu) GTK window, along with its menubars,
1.9 * toolbars, etc.
1.10 @@ -34,15 +34,26 @@
1.11 struct main_window_info {
1.12 GtkWidget *window;
1.13 GtkWidget *video;
1.14 + GtkWidget *menubar;
1.15 + GtkWidget *toolbar;
1.16 GtkWidget *statusbar;
1.17 GtkActionGroup *actions;
1.18 };
1.19
1.20 -gboolean on_main_window_deleted( GtkWidget *widget, GdkEvent event, gpointer user_data )
1.21 +static gboolean on_main_window_deleted( GtkWidget *widget, GdkEvent event, gpointer user_data )
1.22 {
1.23 exit(0);
1.24 }
1.25
1.26 +static void on_main_window_state_changed( GtkWidget *widget, GdkEventWindowState *state,
1.27 + gpointer userdata )
1.28 +{
1.29 + if( state->changed_mask & GDK_WINDOW_STATE_FULLSCREEN ) {
1.30 + gboolean fs = (state->new_window_state & GDK_WINDOW_STATE_FULLSCREEN);
1.31 + }
1.32 + return FALSE;
1.33 +}
1.34 +
1.35 main_window_t main_window_new( const gchar *title, GtkWidget *menubar, GtkWidget *toolbar,
1.36 GtkAccelGroup *accel_group )
1.37 {
1.38 @@ -51,6 +62,8 @@
1.39 main_window_t win = g_malloc0( sizeof(struct main_window_info) );
1.40
1.41 win->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1.42 + win->menubar = menubar;
1.43 + win->toolbar = toolbar;
1.44 gtk_window_set_title( GTK_WINDOW(win->window), title );
1.45 gtk_window_add_accel_group (GTK_WINDOW (win->window), accel_group);
1.46
1.47 @@ -77,6 +90,8 @@
1.48 gtk_statusbar_push( GTK_STATUSBAR(win->statusbar), 1, "Stopped" );
1.49 g_signal_connect( win->window, "delete_event",
1.50 G_CALLBACK(on_main_window_deleted), win );
1.51 + g_signal_connect( win->window, "window-state-event",
1.52 + G_CALLBACK(on_main_window_state_changed), win );
1.53 return win;
1.54 }
1.55
1.56 @@ -114,3 +129,27 @@
1.57 {
1.58 return GTK_WINDOW(win->window);
1.59 }
1.60 +
1.61 +void main_window_set_fullscreen( main_window_t win, gboolean fullscreen )
1.62 +{
1.63 + GtkWidget *frame = gtk_widget_get_parent(win->video);
1.64 + if( frame->style == NULL ) {
1.65 + gtk_widget_set_style( frame, gtk_style_new() );
1.66 + }
1.67 + if( fullscreen ) {
1.68 + gtk_window_fullscreen( GTK_WINDOW(win->window) );
1.69 + gtk_widget_hide( win->menubar );
1.70 + gtk_widget_hide( win->toolbar );
1.71 + gtk_widget_hide( win->statusbar );
1.72 +
1.73 + frame->style->xthickness = 0;
1.74 + frame->style->ythickness = 0;
1.75 + } else {
1.76 + gtk_window_unfullscreen( GTK_WINDOW(win->window) );
1.77 + frame->style->xthickness = 2;
1.78 + frame->style->ythickness = 2;
1.79 + gtk_widget_show( win->menubar );
1.80 + gtk_widget_show( win->toolbar );
1.81 + gtk_widget_show( win->statusbar );
1.82 + }
1.83 +}
.