mirror of https://github.com/snes9xgit/snes9x.git
GTK+: Add support for header bar.
This commit is contained in:
parent
c5038bc9fe
commit
b5b7c4390c
|
@ -157,6 +157,7 @@ int Snes9xConfig::load_defaults ()
|
||||||
netplay_last_host [0] = '\0';
|
netplay_last_host [0] = '\0';
|
||||||
netplay_last_port = 6096;
|
netplay_last_port = 6096;
|
||||||
modal_dialogs = 1;
|
modal_dialogs = 1;
|
||||||
|
use_headerbar = 0;
|
||||||
S9xCheatsEnable ();
|
S9xCheatsEnable ();
|
||||||
|
|
||||||
rewind_granularity = 5;
|
rewind_granularity = 5;
|
||||||
|
@ -335,6 +336,7 @@ int Snes9xConfig::save_config_file ()
|
||||||
cf.SetInt (z"PreferencesHeight", preferences_height);
|
cf.SetInt (z"PreferencesHeight", preferences_height);
|
||||||
outbool (cf, z"UIVisible", ui_visible);
|
outbool (cf, z"UIVisible", ui_visible);
|
||||||
outbool (cf, z"StatusBarVisible", statusbar_visible);
|
outbool (cf, z"StatusBarVisible", statusbar_visible);
|
||||||
|
outbool (cf, z"UseHeaderBar", use_headerbar);
|
||||||
if (default_esc_behavior != ESC_TOGGLE_MENUBAR)
|
if (default_esc_behavior != ESC_TOGGLE_MENUBAR)
|
||||||
outbool (cf, z"Fullscreen", 0);
|
outbool (cf, z"Fullscreen", 0);
|
||||||
else
|
else
|
||||||
|
@ -539,6 +541,7 @@ int Snes9xConfig::load_config_file ()
|
||||||
inbool (z"UIVisible", ui_visible);
|
inbool (z"UIVisible", ui_visible);
|
||||||
inbool (z"StatusBarVisible", statusbar_visible);
|
inbool (z"StatusBarVisible", statusbar_visible);
|
||||||
inbool (z"Fullscreen", fullscreen);
|
inbool (z"Fullscreen", fullscreen);
|
||||||
|
inbool (z"UseHeaderBar", use_headerbar);
|
||||||
|
|
||||||
#undef z
|
#undef z
|
||||||
#define z "Netplay::"
|
#define z "Netplay::"
|
||||||
|
|
|
@ -127,6 +127,7 @@ class Snes9xConfig
|
||||||
int num_threads;
|
int num_threads;
|
||||||
unsigned char screensaver_needs_reset;
|
unsigned char screensaver_needs_reset;
|
||||||
int modal_dialogs;
|
int modal_dialogs;
|
||||||
|
unsigned char use_headerbar;
|
||||||
|
|
||||||
int pointer_is_visible;
|
int pointer_is_visible;
|
||||||
gint64 pointer_timestamp;
|
gint64 pointer_timestamp;
|
||||||
|
|
|
@ -625,6 +625,9 @@ Snes9xWindow::Snes9xWindow (Snes9xConfig *config) :
|
||||||
gtk_widget_set_app_paintable (GTK_WIDGET (drawing_area), TRUE);
|
gtk_widget_set_app_paintable (GTK_WIDGET (drawing_area), TRUE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (config->use_headerbar)
|
||||||
|
become_monster ();
|
||||||
|
|
||||||
gtk_widget_realize (window);
|
gtk_widget_realize (window);
|
||||||
gtk_widget_realize (GTK_WIDGET (drawing_area));
|
gtk_widget_realize (GTK_WIDGET (drawing_area));
|
||||||
#if GTK_MAJOR_VERSION < 3
|
#if GTK_MAJOR_VERSION < 3
|
||||||
|
@ -680,6 +683,69 @@ Snes9xWindow::Snes9xWindow (Snes9xConfig *config) :
|
||||||
resize (config->window_width, config->window_height);
|
resize (config->window_width, config->window_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Snes9xWindow::become_monster ()
|
||||||
|
{
|
||||||
|
#if GTK_MAJOR_VERSION >= 3
|
||||||
|
|
||||||
|
if (!config->use_headerbar)
|
||||||
|
return;
|
||||||
|
|
||||||
|
config->default_esc_behavior = ESC_EXIT_FULLSCREEN;
|
||||||
|
|
||||||
|
GtkCssProvider *headerbar_provider;
|
||||||
|
GtkCssProvider *menubar_provider;
|
||||||
|
GtkStyleContext *context;
|
||||||
|
GtkWidget *headerbar;
|
||||||
|
GtkWidget *menubar;
|
||||||
|
|
||||||
|
headerbar_provider = gtk_css_provider_new ();
|
||||||
|
menubar_provider = gtk_css_provider_new ();
|
||||||
|
gtk_css_provider_load_from_data (headerbar_provider,
|
||||||
|
"headerbar {"
|
||||||
|
" min-height: 0px;"
|
||||||
|
" padding-top: 0px;"
|
||||||
|
" padding-bottom: 0px;"
|
||||||
|
" margin: 0px;"
|
||||||
|
"}",
|
||||||
|
-1,
|
||||||
|
NULL);
|
||||||
|
gtk_css_provider_load_from_data (menubar_provider,
|
||||||
|
"menubar, menubar.* {"
|
||||||
|
" margin-top: 2px;"
|
||||||
|
" margin-bottom: 2px;"
|
||||||
|
" box-shadow: none;"
|
||||||
|
" border: 0px;"
|
||||||
|
" background-image: none;"
|
||||||
|
" background-color: transparent;"
|
||||||
|
"}",
|
||||||
|
-1,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
headerbar = gtk_header_bar_new ();
|
||||||
|
context = gtk_widget_get_style_context (headerbar);
|
||||||
|
gtk_style_context_add_provider (context,
|
||||||
|
GTK_STYLE_PROVIDER (headerbar_provider),
|
||||||
|
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||||
|
gtk_header_bar_set_has_subtitle(GTK_HEADER_BAR (headerbar), FALSE);
|
||||||
|
gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (headerbar), TRUE);
|
||||||
|
gtk_window_set_titlebar (GTK_WINDOW (window), headerbar);
|
||||||
|
|
||||||
|
menubar = get_widget ("menubar");
|
||||||
|
g_object_ref ((gpointer) menubar);
|
||||||
|
context = gtk_widget_get_style_context (menubar);
|
||||||
|
gtk_style_context_add_provider (context,
|
||||||
|
GTK_STYLE_PROVIDER (menubar_provider),
|
||||||
|
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||||
|
gtk_container_remove (GTK_CONTAINER (get_widget ("vbox1")), menubar);
|
||||||
|
|
||||||
|
gtk_header_bar_pack_start (GTK_HEADER_BAR (headerbar), menubar);
|
||||||
|
gtk_widget_show_all (headerbar);
|
||||||
|
#else
|
||||||
|
config->use_headerbar = 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
extern const gtk_splash_t gtk_splash;
|
extern const gtk_splash_t gtk_splash;
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1768,9 +1834,12 @@ Snes9xWindow::toggle_statusbar ()
|
||||||
int width = 0;
|
int width = 0;
|
||||||
int height = 0;
|
int height = 0;
|
||||||
|
|
||||||
item = get_widget ("menubar");
|
if (!config->use_headerbar)
|
||||||
gtk_widget_get_allocation (item, &allocation);
|
{
|
||||||
height += gtk_widget_get_visible (item) ? allocation.height : 0;
|
item = get_widget ("menubar");
|
||||||
|
gtk_widget_get_allocation (item, &allocation);
|
||||||
|
height += gtk_widget_get_visible (item) ? allocation.height : 0;
|
||||||
|
}
|
||||||
|
|
||||||
item = get_widget ("drawingarea");
|
item = get_widget ("drawingarea");
|
||||||
gtk_widget_get_allocation (item, &allocation);
|
gtk_widget_get_allocation (item, &allocation);
|
||||||
|
@ -1794,9 +1863,12 @@ Snes9xWindow::resize_viewport (int width, int height)
|
||||||
GtkAllocation allocation;
|
GtkAllocation allocation;
|
||||||
int y_padding = 0;
|
int y_padding = 0;
|
||||||
|
|
||||||
item = get_widget ("menubar");
|
if (!config->use_headerbar)
|
||||||
gtk_widget_get_allocation (item, &allocation);
|
{
|
||||||
y_padding += gtk_widget_get_visible (item) ? allocation.height : 0;
|
item = get_widget ("menubar");
|
||||||
|
gtk_widget_get_allocation (item, &allocation);
|
||||||
|
y_padding += gtk_widget_get_visible (item) ? allocation.height : 0;
|
||||||
|
}
|
||||||
|
|
||||||
item = get_widget ("statusbar");
|
item = get_widget ("statusbar");
|
||||||
gtk_widget_get_allocation (item, &allocation);
|
gtk_widget_get_allocation (item, &allocation);
|
||||||
|
|
|
@ -60,6 +60,7 @@ class Snes9xWindow : public GtkBuilderWindow
|
||||||
void expose ();
|
void expose ();
|
||||||
double get_refresh_rate ();
|
double get_refresh_rate ();
|
||||||
int get_auto_input_rate ();
|
int get_auto_input_rate ();
|
||||||
|
void become_monster ();
|
||||||
|
|
||||||
cairo_t *get_cairo ();
|
cairo_t *get_cairo ();
|
||||||
void release_cairo ();
|
void release_cairo ();
|
||||||
|
|
Loading…
Reference in New Issue