Exemplo n.º 1
0
int main(int argc, char* argv[])
{	
	gtk_init (&argc, &argv);
		
	MainWindow* main_window = main_window_new();
	
	// Declaring Level and cpSpace structures
    Level* l;
    cpSpace* physics_world;
    
	// function that returns a filename depending on the level number selected
	char* file_name = level_file_name(main_window->level_number);
	
	// These functions allocate space and initializes the Level structure
	// and passes the structure to the World for the world to be initialized
    l = level_new(file_name);
    physics_world = world_physics_new(l);
	
	World* world = game_view_get_world(main_window_get_game_view(main_window));
	
	world_physics_add_box(physics_world, .5, .5, .1, .1, 0);
		
	world_load_space(world, physics_world);
		
	main_window_begin(main_window);
    
	// This function frees memory allocated for the Level structure and the sub-structures
	// contained within it
    level_destroy(l);
	
	return EXIT_SUCCESS;

}
Exemplo n.º 2
0
static void
application_activate (GApplication *app)
{
    MainWindow *win;
    
    win = main_window_new (APPLICATION (app));
    gtk_window_present (GTK_WINDOW (win));
}
Exemplo n.º 3
0
void direction_select_cb(GtkWidget *w, gpointer *data)
{
  motorway *mway = (motorway*)data;
  gint direction = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w), "direction"));
  GHashTable *table = g_object_get_data(G_OBJECT(w), "mwayTable");
  GtkWidget *mainWindow = main_window_new(table, mway, direction);
  gtk_widget_show_all(mainWindow);

  GtkWidget *window = gtk_widget_get_toplevel(w);
  gtk_widget_destroy(window);
}
Exemplo n.º 4
0
static void
application_open (GApplication  *app,
              GFile        **files,
              gint           n_files,
              const gchar   *hint)
{
    GList *windows;
    MainWindow *win;
    int i;
    
    windows = gtk_application_get_windows (GTK_APPLICATION (app));
    if (windows)
        win = MAIN_WINDOW (windows->data);
    else
        win = main_window_new (APPLICATION (app));

    for (i = 0; i < n_files; i++)
        main_window_open (win, files[i]);
    
    gtk_window_present (GTK_WINDOW (win));
}
Exemplo n.º 5
0
gboolean gui_init( gboolean withDebug, gboolean withFullscreen )
{
    if( gtk_gui_init_ok ) {
        int i;
        GError *error = NULL;
        dreamcast_register_module( &gtk_gui_module );
        gtk_gui_alloc_resources();

        global_action_group = gtk_action_group_new("MenuActions");
        gtk_action_group_set_translation_domain( global_action_group, NULL );
        gtk_action_group_add_actions( global_action_group, ui_actions, G_N_ELEMENTS(ui_actions), NULL );
        gtk_action_group_add_toggle_actions( global_action_group, ui_toggle_actions, G_N_ELEMENTS(ui_toggle_actions), NULL );

        for( i=0; i<=MAX_QUICK_STATE; i++ ) {
            ui_radio_actions[i].name = g_strdup_printf("QuickState%d", i);
            ui_radio_actions[i].stock_id = NULL;
            ui_radio_actions[i].label = g_strdup_printf(_("State _%d"), i );
            ui_radio_actions[i].accelerator = NULL;
            ui_radio_actions[i].tooltip = g_strdup_printf(_("Use quick save state %d"),i);
            ui_radio_actions[i].value = i;
        }
        gtk_action_group_add_radio_actions( global_action_group, ui_radio_actions, G_N_ELEMENTS(ui_radio_actions), 
                                            dreamcast_get_quick_state(), G_CALLBACK(quick_state_action_callback), NULL );
        gtk_gui_enable_action("AudioSettings", FALSE);
        gtk_gui_enable_action("NetworkSettings", FALSE);
        gtk_gui_enable_action("VideoSettings", FALSE);

        global_ui_manager = gtk_ui_manager_new();
        gtk_ui_manager_set_add_tearoffs(global_ui_manager, TRUE);
        gtk_ui_manager_insert_action_group( global_ui_manager, global_action_group, 0 );

        if (!gtk_ui_manager_add_ui_from_string (global_ui_manager, ui_description, -1, &error)) {
            g_message ("building menus failed: %s", error->message);
            g_error_free (error);
            exit(1);
        }
        GtkAccelGroup *accel_group = gtk_ui_manager_get_accel_group (global_ui_manager);
        GtkWidget *menubar = gtk_ui_manager_get_widget(global_ui_manager, "/MainMenu");
        GtkWidget *toolbar = gtk_ui_manager_get_widget(global_ui_manager, "/MainToolbar");

        GtkWidget *gdrommenuitem = gtk_ui_manager_get_widget(global_ui_manager, "/MainMenu/FileMenu/GdromSettings");
        GtkWidget *gdrommenu = gdrom_menu_new();
        gtk_menu_item_set_submenu( GTK_MENU_ITEM(gdrommenuitem), gdrommenu );
        main_win = main_window_new( lxdream_package_name, menubar, toolbar, accel_group  );
        if( withDebug ) {
            gtk_gui_show_debugger();
        }
        
        if (withFullscreen) {
            main_window_set_fullscreen(main_win, TRUE);
            //manually call full-screen state code for non-compliant window managers
            main_window_show_gui(main_win, TRUE);
        }
        
        register_gdrom_disc_change_hook( gtk_gui_disc_changed, NULL );

        return TRUE;
    } else {
        return FALSE;
    }
}
Exemplo n.º 6
0
static void app_startup_handler(GApplication *app, gpointer data)
{
	gmpv_handle *ctx = data;
	const gchar *vid_area_style = ".gmpv-vid-area{background-color: black}";
	GSettingsBackend *config_backend;
	GtkCssProvider *style_provider;
	gboolean css_loaded;
	gboolean use_opengl;
	gboolean config_migrated;
	gboolean mpvinput_enable;
	gboolean csd_enable;
	gboolean dark_theme_enable;
	gchar *config_file;
	gchar *mpvinput;

	setlocale(LC_NUMERIC, "C");
	g_set_application_name(_("GNOME MPV"));
	gtk_window_set_default_icon_name(ICON_NAME);

	bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALEDIR);
	bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
	textdomain(GETTEXT_PACKAGE);

	config_file = get_config_file_path();

	config_backend = g_keyfile_settings_backend_new
				(	config_file,
					CONFIG_ROOT_PATH,
					CONFIG_ROOT_GROUP );

	use_opengl = get_use_opengl();

	ctx->mpv_ctx = mpv_create();
	ctx->files = NULL;
	ctx->opengl_ctx = NULL;
	ctx->opengl_ready = FALSE;
	ctx->paused = TRUE;
	ctx->loaded = FALSE;
	ctx->new_file = TRUE;
	ctx->sub_visible = TRUE;
	ctx->init_load = TRUE;
	ctx->playlist_move_dest = -1;
	ctx->log_level_list = NULL;
	ctx->keybind_list = NULL;
	ctx->config = g_settings_new_with_backend(APP_ID, config_backend);
	ctx->app = GTK_APPLICATION(app);
	ctx->gui = MAIN_WINDOW(main_window_new(ctx->app, use_opengl));
	ctx->fs_control = NULL;
	ctx->playlist_store = PLAYLIST_WIDGET(ctx->gui->playlist)->list_store;

	config_migrated = migrate_config(ctx);
	style_provider = gtk_css_provider_new();

	css_loaded = gtk_css_provider_load_from_data
			(style_provider, vid_area_style, -1, NULL);

	if(!css_loaded)
	{
		g_warning ("Failed to apply background color css");
	}

	gtk_style_context_add_provider_for_screen
		(	gtk_window_get_screen(GTK_WINDOW(ctx->gui)),
			GTK_STYLE_PROVIDER(style_provider),
			GTK_STYLE_PROVIDER_PRIORITY_APPLICATION );

	g_object_unref(style_provider);

	csd_enable = g_settings_get_boolean
				(ctx->config, "csd-enable");

	dark_theme_enable = g_settings_get_boolean
				(ctx->config, "dark-theme-enable");

	mpvinput_enable = g_settings_get_boolean
				(ctx->config, "mpv-input-config-enable");

	mpvinput = g_settings_get_string
				(ctx->config, "mpv-input-config-file");

	if(csd_enable)
	{
		gtk_application_set_app_menu
			(ctx->app, G_MENU_MODEL(build_app_menu()));

		main_window_enable_csd(ctx->gui);
	}
	else
	{
		gtk_application_set_app_menu
			(ctx->app, NULL);

		gtk_application_set_menubar
			(ctx->app, G_MENU_MODEL(build_full_menu()));
	}

	gtk_widget_show_all(GTK_WIDGET(ctx->gui));

	if(csd_enable)
	{
		control_box_set_fullscreen_btn_visible
			(CONTROL_BOX(ctx->gui->control_box), FALSE);
	}

	control_box_set_chapter_enabled
		(CONTROL_BOX(ctx->gui->control_box), FALSE);

	if(!main_window_get_use_opengl(ctx->gui))
	{
		ctx->vid_area_wid = get_xid(ctx->gui->vid_area);
	}

	g_assert(	main_window_get_use_opengl(ctx->gui) ||
			ctx->vid_area_wid != -1 );

	main_window_load_state(ctx->gui);
	setup_accelerators(ctx);
	setup_dnd_targets(ctx);
	actionctl_map_actions(ctx);
	connect_signals(ctx);
	load_keybind(ctx, mpvinput_enable?mpvinput:NULL, FALSE);
	mpris_init(ctx);
	media_keys_init(ctx);

	g_object_set(	ctx->gui->settings,
			"gtk-application-prefer-dark-theme",
			dark_theme_enable,
			NULL );

	g_timeout_add(	SEEK_BAR_UPDATE_INTERVAL,
			(GSourceFunc)update_seek_bar,
			ctx );

	if(config_migrated)
	{
		GtkWidget *dialog
			= gtk_message_dialog_new
				(	GTK_WINDOW(ctx->gui),
					GTK_DIALOG_DESTROY_WITH_PARENT,
					GTK_MESSAGE_INFO,
					GTK_BUTTONS_OK,
					_("Your configuration file has been "
					"moved to the new location at %s."),
					config_file );

		gtk_dialog_run(GTK_DIALOG(dialog));
		gtk_widget_destroy(dialog);
	}

	g_free(config_file);
	g_free(mpvinput);
}