[dia/zbrown/gtk2-fixes] Fix splash screen loading Set a default icon for all windows



commit adfe7170a64abde0e2b2611b526614952df1347f
Author: Zander Brown <zbrown gnome org>
Date:   Mon Jan 28 17:13:10 2019 +0000

    Fix splash screen loading
    Set a default icon for all windows

 .gitignore      |  4 ++++
 app/app_procs.c | 14 ++++++++++++++
 app/interface.c | 28 ----------------------------
 app/splash.c    | 11 +++++------
 lib/dia_dirs.c  |  9 +++++++--
 5 files changed, 30 insertions(+), 36 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 8836c4fb..bea019c2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,3 +42,7 @@ doc/*/graphics/*.eps
 doc/*/.epsfigures
 doc/*/dia_html
 /build/win32/Thumbs.db
+compile
+.vscode/settings.json
+tests/sizeof
+tests/testsvg
diff --git a/app/app_procs.c b/app/app_procs.c
index dfd84e9c..71dcd2d5 100644
--- a/app/app_procs.c
+++ b/app/app_procs.c
@@ -72,6 +72,8 @@
 #include "dialib.h"
 #include "diaerror.h"
 
+#include "dia-app-icons.h"
+
 static gboolean
 handle_initial_diagram(const char *input_file_name, 
                       const char *export_file_name,
@@ -752,10 +754,22 @@ app_init (int argc, char **argv)
   }
 
   if (argv && dia_is_interactive) {
+    GdkPixbuf *pixbuf;
+
 #  if defined(G_THREADS_ENABLED) && !GLIB_CHECK_VERSION(2,32,0)
     g_thread_init (NULL);
 #  endif
+    g_set_application_name (_("Dia Diagram Editor"));
     gtk_init(&argc, &argv);
+
+    /* Set the icon for Dia windows & dialogs */
+    /* MESON: Use GResource */
+    /* GTK3: Use icon-name with GResource fallback */
+    pixbuf = gdk_pixbuf_new_from_inline (-1, dia_app_icon, FALSE, NULL);
+    if (pixbuf) {
+      gtk_window_set_default_icon (pixbuf);
+      g_object_unref (pixbuf);
+    }
   }
   else {
 #if defined(G_THREADS_ENABLED) && !GLIB_CHECK_VERSION(2,32,0)
diff --git a/app/interface.c b/app/interface.c
index 4bf12676..3bb12fde 100644
--- a/app/interface.c
+++ b/app/interface.c
@@ -681,17 +681,7 @@ create_display_shell(DDisplay *ddisp,
   ddisp->shell = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_window_set_title (GTK_WINDOW (ddisp->shell), title);
   gtk_window_set_role (GTK_WINDOW (ddisp->shell), "diagram_window");
-  gtk_window_set_icon_name (GTK_WINDOW (ddisp->shell), "dia");
   gtk_window_set_default_size(GTK_WINDOW (ddisp->shell), width, height);
-  /* set_icon_name needs registered theme icons, not always available: provide fallback */
-  if (!gtk_window_get_icon (GTK_WINDOW (ddisp->shell))) {
-    static GdkPixbuf *pixbuf = NULL;
-
-    if (!pixbuf)
-      pixbuf = gdk_pixbuf_new_from_inline(-1, dia_diagram_icon, FALSE, NULL);
-    if (pixbuf)
-      gtk_window_set_icon (GTK_WINDOW (ddisp->shell), pixbuf);
-  }
 
   g_object_set_data (G_OBJECT (ddisp->shell), "user_data", (gpointer) ddisp);
 
@@ -892,19 +882,6 @@ toolbox_delete (GtkWidget *widget, GdkEvent *event, gpointer data)
   return (!app_exit());
 }
 
-static void
-app_set_icon (GtkWindow *window)
-{
-  gtk_window_set_icon_name (window, "dia");
-  if (!gtk_window_get_icon (window)) {
-    GdkPixbuf *pixbuf = gdk_pixbuf_new_from_inline (-1, dia_app_icon, FALSE, NULL);
-    if (pixbuf) {
-      gtk_window_set_icon (window, pixbuf);
-      g_object_unref (pixbuf);
-    }
-  }
-}
-
 #ifdef HAVE_MAC_INTEGRATION
 static gboolean
 _osx_app_exit (GtkosxApplication *app,
@@ -991,8 +968,6 @@ create_integrated_ui (void)
   
   gtk_window_set_default_size (GTK_WINDOW (window), 146, 349);
  
-  app_set_icon (GTK_WINDOW (window));
-
   g_signal_connect (G_OBJECT (window), "delete_event",
                    G_CALLBACK (toolbox_delete),
                      window);
@@ -1091,9 +1066,6 @@ create_toolbox ()
   gtk_window_set_title (GTK_WINDOW (window), "Dia v" VERSION);
   gtk_window_set_role (GTK_WINDOW (window), "toolbox_window");
   gtk_window_set_default_size(GTK_WINDOW(window), 146, 349);
-
-  app_set_icon (GTK_WINDOW (window));
-
   g_signal_connect (G_OBJECT (window), "delete_event",
                    G_CALLBACK (toolbox_delete), window);
   g_signal_connect (G_OBJECT (window), "destroy",
diff --git a/app/splash.c b/app/splash.c
index fecf445f..ae586eb9 100644
--- a/app/splash.c
+++ b/app/splash.c
@@ -12,12 +12,11 @@ get_logo_pixmap (void)
 {
   GdkPixbuf *logo = NULL;
   GtkWidget* gpixmap = NULL;
-  gchar str[512];
-
-  gchar* datadir = dia_get_data_directory(""); 
-  g_snprintf(str, sizeof(str), "%s/dia-splash.png", datadir);
-  logo = gdk_pixbuf_new_from_file(str, NULL);
-  g_free(datadir);
+  gchar *path = g_build_filename (dia_get_data_directory(""),
+                                  "dia-splash.png",
+                                  NULL);
+  logo = gdk_pixbuf_new_from_file (path, NULL);
+  g_free(path);
 
   if (logo) {
     gpixmap = gtk_image_new_from_pixbuf (logo);
diff --git a/lib/dia_dirs.c b/lib/dia_dirs.c
index 99e8590c..5ad9f106 100644
--- a/lib/dia_dirs.c
+++ b/lib/dia_dirs.c
@@ -103,10 +103,15 @@ dia_get_data_directory(const gchar* subdir)
   g_free (sLoc);
   return returnPath;
 #else
+  gchar *base = DATADIR;
+  if (g_getenv ("DIA_BASE_PATH") != NULL) {
+    /* a small hack cause the final destination and the local path differ */
+    base = g_build_filename (g_getenv ("DIA_BASE_PATH"), "data", NULL);
+  }
   if (strlen (subdir) == 0)
-    return g_strconcat (DATADIR, NULL);
+    return g_strconcat (base, NULL);
   else
-    return g_strconcat (DATADIR, G_DIR_SEPARATOR_S, subdir, NULL);
+    return g_strconcat (base, G_DIR_SEPARATOR_S, subdir, NULL);
 #endif
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]