Some GTK+ 3 fixes.

This commit is contained in:
Brandon Wright 2017-12-06 20:30:27 -06:00
parent e2277ff55b
commit 886ea13daf
5 changed files with 48 additions and 32 deletions

View File

@ -431,8 +431,8 @@ S9xOpenROMDialog (void)
dialog = gtk_file_chooser_dialog_new ("Open SNES ROM Image", dialog = gtk_file_chooser_dialog_new ("Open SNES ROM Image",
top_level->get_window (), top_level->get_window (),
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, "gtk-cancel", GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, "gtk-open", GTK_RESPONSE_ACCEPT,
NULL); NULL);
filter = gtk_file_filter_new (); filter = gtk_file_filter_new ();

View File

@ -225,8 +225,8 @@ event_shader_select (GtkButton *widget, gpointer data)
dialog = gtk_file_chooser_dialog_new ("Select Shader File", dialog = gtk_file_chooser_dialog_new ("Select Shader File",
window->get_window (), window->get_window (),
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, "gtk-cancel", GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, "gtk-open", GTK_RESPONSE_ACCEPT,
NULL); NULL);
if (strcmp (gui_config->last_directory, "")) if (strcmp (gui_config->last_directory, ""))
@ -288,8 +288,8 @@ event_game_data_browse (GtkButton *widget, gpointer data)
dialog = gtk_file_chooser_dialog_new ("Select directory", dialog = gtk_file_chooser_dialog_new ("Select directory",
window->get_window (), window->get_window (),
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, "gtk-cancel", GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, "gtk-open", GTK_RESPONSE_ACCEPT,
NULL); NULL);
if (strcmp (gui_config->last_directory, "")) if (strcmp (gui_config->last_directory, ""))
@ -469,7 +469,6 @@ event_about_clicked (GtkButton *widget, gpointer data)
std::string version_string; std::string version_string;
GtkBuilderWindow *about_dialog = new GtkBuilderWindow ("about_dialog"); GtkBuilderWindow *about_dialog = new GtkBuilderWindow ("about_dialog");
Snes9xPreferences *preferences = (Snes9xPreferences *) data; Snes9xPreferences *preferences = (Snes9xPreferences *) data;
PangoFontDescription *monospace;
((version_string += _("Snes9x version: ")) += VERSION) += ", "; ((version_string += _("Snes9x version: ")) += VERSION) += ", ";
((version_string += _("GTK+ port version: ")) += SNES9X_GTK_VERSION) += "\n"; ((version_string += _("GTK+ port version: ")) += SNES9X_GTK_VERSION) += "\n";
@ -505,15 +504,31 @@ event_about_clicked (GtkButton *widget, gpointer data)
gtk_widget_hide (about_dialog->get_widget ("preferences_splash")); gtk_widget_hide (about_dialog->get_widget ("preferences_splash"));
monospace = pango_font_description_from_string ("Monospace 7");
#ifdef USE_GTK3 #ifdef USE_GTK3
gtk_widget_override_font (about_dialog->get_widget ("about_text_view"), GtkCssProvider *provider;
monospace); GtkStyleContext *context;
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider,
"textview {"
" font-family: \"monospace\";"
" font-size: 8pt;"
"}",
-1,
NULL);
context = gtk_widget_get_style_context (about_dialog->get_widget ("about_text_view"));
gtk_style_context_add_provider (context,
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
#else #else
PangoFontDescription *monospace;
monospace = pango_font_description_from_string ("Monospace 7");
gtk_widget_modify_font (about_dialog->get_widget ("about_text_view"), gtk_widget_modify_font (about_dialog->get_widget ("about_text_view"),
monospace); monospace);
#endif
pango_font_description_free (monospace); pango_font_description_free (monospace);
#endif
gtk_window_set_transient_for (about_dialog->get_window (), gtk_window_set_transient_for (about_dialog->get_window (),
preferences->get_window ()); preferences->get_window ());
@ -978,8 +993,8 @@ Snes9xPreferences::browse_folder_dialog (void)
dialog = gtk_file_chooser_dialog_new (_("Select Folder"), dialog = gtk_file_chooser_dialog_new (_("Select Folder"),
GTK_WINDOW (this->window), GTK_WINDOW (this->window),
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, "gtk-cancel", GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, "gtk-open", GTK_RESPONSE_ACCEPT,
NULL); NULL);
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog),

View File

@ -45,9 +45,6 @@ main (int argc, char *argv[])
{ {
struct sigaction sig_callback; struct sigaction sig_callback;
gdk_threads_init ();
gdk_threads_enter ();
gtk_init (&argc, &argv); gtk_init (&argc, &argv);
bindtextdomain (GETTEXT_PACKAGE, SNES9XLOCALEDIR); bindtextdomain (GETTEXT_PACKAGE, SNES9XLOCALEDIR);
@ -129,7 +126,6 @@ main (int argc, char *argv[])
gtk_window_present (top_level->get_window ()); gtk_window_present (top_level->get_window ());
gtk_main (); gtk_main ();
gdk_threads_leave ();
return 0; return 0;
} }

View File

@ -618,7 +618,9 @@ Snes9xWindow::Snes9xWindow (Snes9xConfig *config) :
} }
drawing_area = GTK_DRAWING_AREA (get_widget ("drawingarea")); drawing_area = GTK_DRAWING_AREA (get_widget ("drawingarea"));
#ifndef USE_GTK3
gtk_widget_set_double_buffered (GTK_WIDGET (drawing_area), FALSE); gtk_widget_set_double_buffered (GTK_WIDGET (drawing_area), FALSE);
#endif
gtk_widget_realize (window); gtk_widget_realize (window);
gtk_widget_realize (GTK_WIDGET (drawing_area)); gtk_widget_realize (GTK_WIDGET (drawing_area));
@ -646,9 +648,6 @@ Snes9xWindow::Snes9xWindow (Snes9xConfig *config) :
this, this,
NULL, NULL,
(GConnectFlags) 0); (GConnectFlags) 0);
gtk_window_set_has_resize_grip (GTK_WINDOW (window), FALSE);
#else #else
g_signal_connect_data (drawing_area, g_signal_connect_data (drawing_area,
"expose-event", "expose-event",
@ -665,7 +664,7 @@ Snes9xWindow::Snes9xWindow (Snes9xConfig *config) :
config->window_height = 224; config->window_height = 224;
} }
default_cursor = gdk_cursor_new (GDK_LEFT_PTR); default_cursor = gdk_cursor_new_for_display (gdk_display_get_default (),GDK_LEFT_PTR);
gdk_window_set_cursor (gtk_widget_get_window (window), default_cursor); gdk_window_set_cursor (gtk_widget_get_window (window), default_cursor);
resize (config->window_width, config->window_height); resize (config->window_width, config->window_height);
@ -831,8 +830,8 @@ Snes9xWindow::open_movie_dialog (bool readonly)
dialog = gtk_file_chooser_dialog_new (_("Open SNES Movie"), dialog = gtk_file_chooser_dialog_new (_("Open SNES Movie"),
GTK_WINDOW (this->window), GTK_WINDOW (this->window),
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, "gtk-cancel", GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, "gtk-open", GTK_RESPONSE_ACCEPT,
NULL); NULL);
} }
else else
@ -850,8 +849,8 @@ Snes9xWindow::open_movie_dialog (bool readonly)
dialog = gtk_file_chooser_dialog_new (_("New SNES Movie"), dialog = gtk_file_chooser_dialog_new (_("New SNES Movie"),
GTK_WINDOW (this->window), GTK_WINDOW (this->window),
GTK_FILE_CHOOSER_ACTION_SAVE, GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, "gtk-cancel", GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, "gtk-open", GTK_RESPONSE_ACCEPT,
NULL); NULL);
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog),
@ -994,8 +993,8 @@ Snes9xWindow::load_state_dialog ()
dialog = gtk_file_chooser_dialog_new (_("Load Saved State"), dialog = gtk_file_chooser_dialog_new (_("Load Saved State"),
GTK_WINDOW (this->window), GTK_WINDOW (this->window),
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, "gtk-cancel", GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, "gtk-open", GTK_RESPONSE_ACCEPT,
NULL); NULL);
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog),
@ -1116,8 +1115,8 @@ Snes9xWindow::save_state_dialog ()
dialog = gtk_file_chooser_dialog_new (_("Save State"), dialog = gtk_file_chooser_dialog_new (_("Save State"),
GTK_WINDOW (this->window), GTK_WINDOW (this->window),
GTK_FILE_CHOOSER_ACTION_SAVE, GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, "gtk-cancel", GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, "gtk-save", GTK_RESPONSE_ACCEPT,
NULL); NULL);
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog),
@ -1194,8 +1193,8 @@ Snes9xWindow::save_spc_dialog ()
dialog = gtk_file_chooser_dialog_new (_("Save SPC file..."), dialog = gtk_file_chooser_dialog_new (_("Save SPC file..."),
GTK_WINDOW (this->window), GTK_WINDOW (this->window),
GTK_FILE_CHOOSER_ACTION_SAVE, GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, "gtk-cancel", GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, "gtk-save", GTK_RESPONSE_ACCEPT,
NULL); NULL);
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog),
@ -1697,7 +1696,7 @@ Snes9xWindow::hide_mouse_cursor (void)
{ {
if (!empty_cursor) if (!empty_cursor)
{ {
empty_cursor = gdk_cursor_new (GDK_BLANK_CURSOR); empty_cursor = gdk_cursor_new_for_display (gdk_display_get_default (), GDK_BLANK_CURSOR);
} }
gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (drawing_area)), gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (drawing_area)),

View File

@ -3903,6 +3903,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="icon_name">video-display</property> <property name="icon_name">video-display</property>
<property name="pixel_size">24</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -4330,6 +4331,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="icon_name">audio-x-generic</property> <property name="icon_name">audio-x-generic</property>
<property name="pixel_size">24</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -4725,6 +4727,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="icon_name">utilities-terminal</property> <property name="icon_name">utilities-terminal</property>
<property name="pixel_size">24</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -5159,6 +5162,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="icon_name">folder</property> <property name="icon_name">folder</property>
<property name="pixel_size">24</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -6480,6 +6484,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="icon_name">input-gaming</property> <property name="icon_name">input-gaming</property>
<property name="pixel_size">24</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -8585,6 +8590,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="icon_name">input-keyboard</property> <property name="icon_name">input-keyboard</property>
<property name="pixel_size">24</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>