changeset 3965:aea8b763b134

Work around the issues with broken Gtk-Qt-Engine and Modern skins with inline GTK.
author William Pitcock <nenolod@atheme.org>
date Sat, 17 Nov 2007 06:21:00 -0600
parents d5426e967f03
children ecda04452d14
files src/audacious/main.c src/audacious/main.h src/audacious/skin.c src/audacious/ui_main.c src/audacious/ui_main.h
diffstat 5 files changed, 88 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/main.c	Sat Nov 17 03:35:43 2007 -0600
+++ b/src/audacious/main.c	Sat Nov 17 06:21:00 2007 -0600
@@ -226,6 +226,8 @@
     TRUE,           /* close jtf dialog on jump */
     TRUE,           /* use back and forth scroll */
     FALSE,          /* use software volume control */
+    .warn_about_broken_gtk_engines = TRUE,           /* warn about broken gtk themes */
+    FALSE,          /* disable inline themes */
 };
 
 typedef struct bmp_cfg_boolent_t {
@@ -334,6 +336,7 @@
     {"close_jtf_dialog", &cfg.close_jtf_dialog, TRUE},
     {"twoway_scroll", &cfg.twoway_scroll, TRUE},
     {"software_volume_control", &cfg.software_volume_control, TRUE},
+    {"warn_about_broken_gtk_engines", &cfg.warn_about_broken_gtk_engines, TRUE},
 };
 
 static gint ncfgbent = G_N_ELEMENTS(bmp_boolents);
@@ -1463,6 +1466,8 @@
 
     if (options.headless != 1)
     {
+      ui_main_check_theme_engine();
+
       /* UIManager
          NOTE: this needs to be called before plugin init, cause
          plugin init functions may want to add custom menu entries */ 
--- a/src/audacious/main.h	Sat Nov 17 03:35:43 2007 -0600
+++ b/src/audacious/main.h	Sat Nov 17 06:21:00 2007 -0600
@@ -131,6 +131,8 @@
     gboolean close_jtf_dialog;
     gboolean twoway_scroll;
     gboolean software_volume_control;
+    gboolean warn_about_broken_gtk_engines;
+    gboolean disable_inline_gtk;
 };
 
 typedef struct _BmpConfig BmpConfig;
--- a/src/audacious/skin.c	Sat Nov 17 03:35:43 2007 -0600
+++ b/src/audacious/skin.c	Sat Nov 17 06:21:00 2007 -0600
@@ -1528,10 +1528,12 @@
         skin_load_cursor(skin, path);
 
 #ifndef _WIN32
-        gtkrcpath = find_path_recursively(skin->path, "gtkrc");
-        if (gtkrcpath != NULL)
-            skin_set_gtk_theme(settings, skin);
-        g_free(gtkrcpath);
+        if (!cfg.disable_inline_gtk) {
+            gtkrcpath = find_path_recursively(skin->path, "gtkrc");
+            if (gtkrcpath != NULL)
+                skin_set_gtk_theme(settings, skin);
+            g_free(gtkrcpath);
+        }
 #endif
 
         return TRUE;
@@ -1555,10 +1557,12 @@
     skin_load_cursor(skin, cpath);
 
 #ifndef _WIN32
-    gtkrcpath = find_path_recursively(skin->path, "gtkrc");
-    if (gtkrcpath != NULL)
-        skin_set_gtk_theme(settings, skin);
-    g_free(gtkrcpath);
+    if (!cfg.disable_inline_gtk) {
+        gtkrcpath = find_path_recursively(skin->path, "gtkrc");
+        if (gtkrcpath != NULL)
+            skin_set_gtk_theme(settings, skin);
+        g_free(gtkrcpath);
+    }
 #endif
 
     del_directory(cpath);
--- a/src/audacious/ui_main.c	Sat Nov 17 03:35:43 2007 -0600
+++ b/src/audacious/ui_main.c	Sat Nov 17 06:21:00 2007 -0600
@@ -1244,6 +1244,73 @@
     }
 }
 
+static void
+on_broken_gtk_engine_warning_toggle(GtkToggleButton *tbt, gpointer unused)
+{
+    cfg.warn_about_broken_gtk_engines = !gtk_toggle_button_get_active(tbt);
+}
+
+void
+ui_main_check_theme_engine(void)
+{
+    GtkSettings *settings;
+    GtkWidget *widget;
+    gchar *theme = NULL;
+
+    widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+    gtk_widget_ensure_style(widget);
+
+    settings = gtk_settings_get_default();
+    g_object_get(G_OBJECT(settings), "gtk-theme-name", &theme, NULL);
+    gtk_widget_destroy(widget);
+
+    if (theme == NULL)
+        return;
+
+    if (g_ascii_strcasecmp(theme, "Qt"))
+    {
+        g_free(theme);
+        return;
+    }
+
+    if (cfg.warn_about_broken_gtk_engines)
+    {
+        gchar *msg;
+        GtkWidget *label, *checkbt, *vbox;
+        GtkWidget *warning_dlg = gtk_dialog_new_with_buttons( _("Audacious - broken GTK engine usage warning") ,
+            GTK_WINDOW(mainwin) , GTK_DIALOG_DESTROY_WITH_PARENT ,
+            _("Close"), GTK_RESPONSE_OK, NULL );
+        vbox = gtk_vbox_new( FALSE , 4 );
+        gtk_container_set_border_width( GTK_CONTAINER(vbox) , 4 );
+        gtk_box_pack_start( GTK_BOX(GTK_DIALOG(warning_dlg)->vbox) , vbox , TRUE , TRUE , 0 );
+
+        msg = g_strdup_printf(_("<big><b>Broken GTK engine in use</b></big>\n\n"
+				 "Audacious has detected that you are using a broken GTK engine.\n\n"
+                                 "The theme engine you are using, <i>%s</i> is incompatible with some of the features "
+                                 "used by modern skins. The incompatible features have been disabled for this session.\n\n"
+                                 "To use these features, please consider using a different GTK theme engine."), theme);
+        label = gtk_label_new(msg);
+        gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
+        g_free(msg);
+
+        gtk_label_set_line_wrap( GTK_LABEL(label) , TRUE );
+        gtk_misc_set_alignment( GTK_MISC(label) , 0.0 , 0.0 );
+        checkbt = gtk_check_button_new_with_label( _("Do not display this warning again") );
+        gtk_box_pack_start( GTK_BOX(vbox) , label , TRUE , TRUE , 0 );
+        gtk_box_pack_start( GTK_BOX(vbox) , checkbt , TRUE , TRUE , 0 );
+        g_signal_connect( G_OBJECT(checkbt) , "toggled" ,
+            G_CALLBACK(on_broken_gtk_engine_warning_toggle) , NULL );
+        g_signal_connect( G_OBJECT(warning_dlg) , "response" ,
+            G_CALLBACK(gtk_widget_destroy) , NULL );        
+        gtk_widget_show_all(warning_dlg);
+        gtk_window_stick(GTK_WINDOW(warning_dlg));
+    }
+
+    cfg.disable_inline_gtk = TRUE;
+
+    g_free(theme);
+}
+
 void
 mainwin_show_add_url_window(void)
 {
--- a/src/audacious/ui_main.h	Sat Nov 17 03:35:43 2007 -0600
+++ b/src/audacious/ui_main.h	Sat Nov 17 06:21:00 2007 -0600
@@ -189,4 +189,6 @@
                                 gint * frequency,
                                 gint * numchannels);
 
+void ui_main_check_theme_engine(void);
+
 #endif