Search
lxdream.org :: lxdream/src/gui/main_win.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/main_win.c
changeset 455:3080881d00d4
prev450:207461e79f21
next457:af605fd32c0b
author nkeynes
date Sun Oct 21 05:21:35 2007 +0000 (12 years ago)
permissions -rw-r--r--
last change More GUI WIP
view annotate diff log raw
     1 /**
     2  * $Id: main_win.c,v 1.6 2007-10-21 05:21:35 nkeynes Exp $
     3  *
     4  * Define the main (emu) GTK window, along with its menubars,
     5  * toolbars, etc.
     6  *
     7  * Copyright (c) 2005 Nathan Keynes.
     8  *
     9  * This program is free software; you can redistribute it and/or modify
    10  * it under the terms of the GNU General Public License as published by
    11  * the Free Software Foundation; either version 2 of the License, or
    12  * (at your option) any later version.
    13  *
    14  * This program is distributed in the hope that it will be useful,
    15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  * GNU General Public License for more details.
    18  */
    20 #include <assert.h>
    21 #include <sys/types.h>
    22 #include <sys/stat.h>
    23 #include <unistd.h>
    24 #include <string.h>
    25 #include <stdio.h>
    26 #include <stdlib.h>
    28 #include <gtk/gtk.h>
    30 #include "dream.h"
    31 #include "gui/gtkui.h"
    34 struct main_window_info {
    35     GtkWidget *window;
    36     GtkWidget *video;
    37     GtkWidget *statusbar;
    38     GtkActionGroup *actions;
    39 };
    41 main_window_t main_window_new( const gchar *title, GtkWidget *menubar, GtkWidget *toolbar,
    42 			       GtkAccelGroup *accel_group )
    43 {
    44     GtkWidget *vbox;
    45     GtkWidget *frame;
    46     main_window_t win = g_malloc0( sizeof(struct main_window_info) );
    48     win->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    49     gtk_window_set_title( GTK_WINDOW(win->window), title );
    50     gtk_window_add_accel_group (GTK_WINDOW (win->window), accel_group);
    52     gtk_toolbar_set_style( GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS );
    54     win->video = gtk_drawing_area_new();
    55     GTK_WIDGET_SET_FLAGS(win->video, GTK_CAN_FOCUS|GTK_CAN_DEFAULT);
    56     gtk_widget_set_size_request( win->video, 640, 480 ); 
    57     frame = gtk_frame_new(NULL);
    58     gtk_frame_set_shadow_type( GTK_FRAME(frame), GTK_SHADOW_IN );
    59     gtk_container_add( GTK_CONTAINER(frame), win->video );
    61     win->statusbar = gtk_statusbar_new();
    63     vbox = gtk_vbox_new(FALSE, 0);
    64     gtk_container_add( GTK_CONTAINER(win->window), vbox );
    65     gtk_box_pack_start( GTK_BOX(vbox), menubar, FALSE, FALSE, 0 );
    66     gtk_box_pack_start( GTK_BOX(vbox), toolbar, FALSE, FALSE, 0 );
    67     gtk_box_pack_start( GTK_BOX(vbox), frame, TRUE, TRUE, 0 );
    68     gtk_box_pack_start( GTK_BOX(vbox), win->statusbar, FALSE, FALSE, 0 );
    69     gtk_widget_show_all( win->window );
    70     gtk_widget_grab_focus( win->video );
    72     gtk_statusbar_push( GTK_STATUSBAR(win->statusbar), 1, "Stopped" );
    73     return win;
    74 }
    76 void main_window_set_running( main_window_t win, gboolean running )
    77 {
    78     gtk_gui_enable_action( "Pause", running );
    79     gtk_gui_enable_action( "Run", !running );
    80     gtk_statusbar_pop( GTK_STATUSBAR(win->statusbar), 1 );
    81     gtk_statusbar_push( GTK_STATUSBAR(win->statusbar), 1, running ? "Running" : "Stopped" );
    82 }
    84 void main_window_set_framerate( main_window_t win, float rate )
    85 {
    88 }
    90 void main_window_set_speed( main_window_t win, double speed )
    91 {
    92     char buf[32];
    94     snprintf( buf, 32, "Running (%2.4f%)", speed );
    95     gtk_statusbar_pop( GTK_STATUSBAR(win->statusbar), 1 );
    96     gtk_statusbar_push( GTK_STATUSBAR(win->statusbar), 1, buf );
    99 }
   101 GtkWidget *main_window_get_renderarea( main_window_t win )
   102 {
   103     return win->video;
   104 }
   106 GtkWindow *main_window_get_frame( main_window_t win )
   107 {
   108     return GTK_WINDOW(win->window);
   109 }
.