GTK+: Various cleanups.

This commit is contained in:
Brandon Wright 2018-12-03 17:27:44 -06:00
parent c21539d269
commit 536c6708c3
6 changed files with 18 additions and 32 deletions

View File

@ -5,5 +5,4 @@ Type=Application
Categories=Game;Emulator; Categories=Game;Emulator;
MimeType=application/vnd.nintendo.snes.rom;application/x-snes-rom; MimeType=application/vnd.nintendo.snes.rom;application/x-snes-rom;
Exec=snes9x-gtk %F Exec=snes9x-gtk %F
TryExec=snes9x-gtk
Icon=snes9x Icon=snes9x

View File

@ -15,19 +15,19 @@
#include "gtk_display.h" #include "gtk_display.h"
#include "conffile.h" #include "conffile.h"
static int directory_exists (const char *directory) static bool directory_exists (std::string str)
{ {
DIR *dir; DIR *dir;
dir = opendir (directory); dir = opendir (str.c_str ());
if (dir) if (dir)
{ {
closedir (dir); closedir (dir);
return TRUE; return true;
} }
return FALSE; return false;
} }
std::string get_config_dir () std::string get_config_dir ()
@ -53,7 +53,7 @@ std::string get_config_dir ()
else else
config = std::string (env_xdg_config_home) + "/snes9x"; config = std::string (env_xdg_config_home) + "/snes9x";
if (directory_exists (legacy.c_str ()) && !directory_exists(config.c_str ())) if (directory_exists (legacy) && !directory_exists(config))
return legacy; return legacy;
return config; return config;
@ -721,11 +721,3 @@ void Snes9xConfig::rebind_keys ()
cmd = S9xGetPortCommandT ("{Mouse1 R,Superscope Cursor,Justifier1 Start}"); cmd = S9xGetPortCommandT ("{Mouse1 R,Superscope Cursor,Justifier1 Start}");
S9xMapButton (BINDING_MOUSE_BUTTON2, cmd, FALSE); S9xMapButton (BINDING_MOUSE_BUTTON2, cmd, FALSE);
} }
void Snes9xConfig::reconfigure ()
{
rebind_keys ();
}

View File

@ -46,7 +46,6 @@ class Snes9xConfig
int load_config_file (); int load_config_file ();
int save_config_file (); int save_config_file ();
int load_defaults (); int load_defaults ();
void reconfigure ();
void rebind_keys (); void rebind_keys ();
void flush_joysticks (); void flush_joysticks ();
void set_joystick_mode (int mode); void set_joystick_mode (int mode);

View File

@ -37,7 +37,7 @@ snes9x_preferences_open (GtkWidget *widget,
config->set_joystick_mode (JOY_MODE_INDIVIDUAL); config->set_joystick_mode (JOY_MODE_INDIVIDUAL);
config->reconfigure (); config->rebind_keys ();
window->update_accels (); window->update_accels ();
return TRUE; return TRUE;

View File

@ -25,7 +25,6 @@ static gboolean S9xScreenSaverCheckFunc (gpointer data);
Snes9xWindow *top_level; Snes9xWindow *top_level;
Snes9xConfig *gui_config; Snes9xConfig *gui_config;
StateManager state_manager; StateManager state_manager;
guint idle_func_id;
gint64 frame_clock = -1; gint64 frame_clock = -1;
gint64 pointer_timestamp = -1; gint64 pointer_timestamp = -1;
@ -40,6 +39,9 @@ int main (int argc, char *argv[])
gtk_init (&argc, &argv); gtk_init (&argc, &argv);
g_set_prgname ("snes9x");
g_set_application_name ("Snes9x");
bindtextdomain (GETTEXT_PACKAGE, SNES9XLOCALEDIR); bindtextdomain (GETTEXT_PACKAGE, SNES9XLOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE); textdomain (GETTEXT_PACKAGE);
@ -63,8 +65,6 @@ int main (int argc, char *argv[])
if (!Memory.Init () || !S9xInitAPU ()) if (!Memory.Init () || !S9xInitAPU ())
exit (3); exit (3);
g_set_application_name ("Snes9x");
top_level = new Snes9xWindow (gui_config); top_level = new Snes9xWindow (gui_config);
/* If we're going to fullscreen, do it before showing window to avoid flicker. */ /* If we're going to fullscreen, do it before showing window to avoid flicker. */
@ -105,7 +105,7 @@ int main (int argc, char *argv[])
top_level->set_menu_item_selected (device_type.c_str ()); top_level->set_menu_item_selected (device_type.c_str ());
} }
gui_config->reconfigure (); gui_config->rebind_keys ();
top_level->update_accels (); top_level->update_accels ();
Settings.Paused = TRUE; Settings.Paused = TRUE;
@ -276,7 +276,7 @@ static gboolean S9xPauseFunc (gpointer data)
} }
/* Resume high-performance callback */ /* Resume high-performance callback */
idle_func_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
S9xIdleFunc, S9xIdleFunc,
NULL, NULL,
NULL); NULL);

View File

@ -1420,10 +1420,8 @@ Snes9xWindow::configure_widgets ()
{ {
gtk_widget_show (get_widget ("menubar")); gtk_widget_show (get_widget ("menubar"));
if (config->statusbar_visible) gtk_widget_set_visible (get_widget ("statusbar"),
gtk_widget_show (get_widget ("statusbar")); config->statusbar_visible);
else
gtk_widget_hide (get_widget ("statusbar"));
} }
else else
{ {
@ -1442,10 +1440,8 @@ Snes9xWindow::configure_widgets ()
if (config->ui_visible) if (config->ui_visible)
{ {
gtk_widget_show (get_widget ("menubar")); gtk_widget_show (get_widget ("menubar"));
if (config->statusbar_visible) gtk_widget_set_visible (get_widget ("statusbar"),
gtk_widget_show (get_widget ("statusbar")); config->statusbar_visible);
else
gtk_widget_hide (get_widget ("statusbar"));
} }
else else
{ {