From 9f2243b68fc01975b9c96f71dfc61310cd154a82 Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Mon, 24 Aug 2009 03:15:44 +0200 Subject: [PATCH] new settings menu in gui --- gui/Makefile | 4 +++- gui/controls.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ gui/plugin.c | 27 ++++++++++++++++++++++----- gui/plugin.h | 3 +++ 4 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 gui/controls.c diff --git a/gui/Makefile b/gui/Makefile index 3ee6eca..9ab946f 100644 --- a/gui/Makefile +++ b/gui/Makefile @@ -18,12 +18,14 @@ M4DEFS:= -DGAME_VERSION=$(GAME_VERSION) -DGAME_PLUGIN_PATH=$(GAME_PLUGIN_PATH) M4DEFS+= -DGAME_CONF_PATH=$(GAME_CONF_PATH) -DGAME_BIN_PATH=$(GAME_BIN_PATH) M4DEFS+= -DGAME_GAME_PATH=$(GAME_GAME_PATH) -DGAME_BANNER_PATH=$(GAME_BANNER_PATH) +OBJS := plugin.o state.o save.o controls.o + DATA_FILES:=drnoksnes.conf drnoksnes.desktop drnoksnes.game DATA_FILES+=drnoksnes.service drnoksnes.startup.service all: drnoksnes_plugin.so data -drnoksnes_plugin.so: plugin.o state.o save.o +drnoksnes_plugin.so: $(OBJS) $(CC) $(LDFLAGS) $^ $(LDLIBS)-o $@ clean: diff --git a/gui/controls.c b/gui/controls.c new file mode 100644 index 0000000..8b35091 --- /dev/null +++ b/gui/controls.c @@ -0,0 +1,54 @@ +/* +* This file is part of DrNokSnes +* +* Copyright (C) 2009 Javier S. Pedro +* +* This software is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public License +* as published by the Free Software Foundation; either version 2.1 of +* the License, or (at your option) any later version. +* +* This software is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this software; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA +* +*/ + +#include +#include +#include + +#include "../platform/hgw.h" +#include "plugin.h" + +static GtkDialog* dialog; +static GtkTreeView* list; + +static void cb_dialog_response(GtkWidget * button, gpointer data) +{ + gtk_widget_destroy(GTK_WIDGET(dialog)); +} + +void controls_dialog(GtkWindow* parent) +{ + dialog = GTK_DIALOG(gtk_dialog_new_with_buttons("Controls", + parent, GTK_DIALOG_MODAL, + GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL)); + + list = GTK_TREE_VIEW(gtk_tree_view_new()); + + gtk_box_pack_start_defaults(GTK_BOX(dialog->vbox), GTK_WIDGET(list)); + + g_signal_connect(G_OBJECT(dialog), "response", + G_CALLBACK (cb_dialog_response), NULL); + + gtk_window_resize(GTK_WINDOW(dialog), 600, 300); + gtk_widget_show_all(GTK_WIDGET(dialog)); +} + diff --git a/gui/plugin.c b/gui/plugin.c index 2837d49..db71e58 100644 --- a/gui/plugin.c +++ b/gui/plugin.c @@ -41,9 +41,9 @@ static GtkWidget ** load_menu(guint *); static void update_menu(void); static void plugin_callback(GtkWidget * menu_item, gpointer data); -GConfClient *gcc = NULL; +GConfClient * gcc = NULL; static GameStartupInfo gs; -GtkWidget *menu_items[2]; +static GtkWidget * menu_items[1]; static StartupPluginInfo plugin_info = { load_plugin, @@ -116,6 +116,11 @@ static void select_rom_callback(GtkWidget * button, gpointer data) } } +static void controls_item_callback(GtkWidget * button, gpointer data) +{ + controls_dialog(get_parent_window()); +} + static void auto_framerate_callback(GtkWidget * button, gpointer data) { if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(auto_framerate_check))) { @@ -255,14 +260,26 @@ static void write_config(void) static GtkWidget **load_menu(guint *nitems) { - *nitems = 0; + menu_items[0] = gtk_menu_item_new_with_label("Settings"); + *nitems = 1; + + GtkMenu* settings_menu = GTK_MENU(gtk_menu_new()); + GtkMenuItem* controls_item = + GTK_MENU_ITEM(gtk_menu_item_new_with_label("Controls...")); - return NULL; + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_items[0]), + GTK_WIDGET(settings_menu)); + gtk_menu_append(GTK_MENU(settings_menu), GTK_WIDGET(controls_item)); + + g_signal_connect(G_OBJECT(controls_item), "activate", + G_CALLBACK(controls_item_callback), NULL); + + return menu_items; } static void update_menu(void) { - + // Nothing to update in the current menu } static void plugin_callback(GtkWidget * menu_item, gpointer data) diff --git a/gui/plugin.h b/gui/plugin.h index 8ba0df3..548899b 100644 --- a/gui/plugin.h +++ b/gui/plugin.h @@ -19,4 +19,7 @@ void save_load(GtkWindow* parent); void save_save(GtkWindow* parent); void save_save_as(GtkWindow* parent); +/* controls.c */ +void controls_dialog(GtkWindow* parent); + #endif -- 1.7.9.5