[dia/zbrown/gresource-icons: 2/12] Fix splash screen loading Set a default icon for all windows



commit b91632d7d2debaf23ad75a77a74b73abd1a1e957
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

 app/app_procs.c | 14 ++++++++++++++
 app/interface.c | 28 ----------------------------
 app/splash.c    | 11 +++++------
 lib/dia_dirs.c  | 15 ++++++++++-----
 4 files changed, 29 insertions(+), 39 deletions(-)
---
diff --git a/app/app_procs.c b/app/app_procs.c
index aab2a590..a92c85af 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 fdddc286..1ccd65ca 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 = PKGDATADIR;
+  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 (PKGDATADIR, NULL);
+    return g_strconcat (base, NULL);
   else
-    return g_strconcat (PKGDATADIR, G_DIR_SEPARATOR_S, subdir, NULL);
+    return g_strconcat (base, G_DIR_SEPARATOR_S, subdir, NULL);
 #endif
 }
 
@@ -252,7 +257,7 @@ dia_get_canonical_path(const gchar *path)
       if (strlen(list[i]) > 0) {
 
         /* win32 filenames usually don't start with a dir separator but
-         * with <drive>:\ 
+         * with <drive>:\
          */
        if (i != 0 || list[i][1] != ':')
           g_string_append (str, G_DIR_SEPARATOR_S);
@@ -346,11 +351,11 @@ dia_relativize_filename (const gchar *master, const gchar *slave)
                          + (g_str_has_suffix (bp1, G_DIR_SEPARATOR_S) ? 0 : 1));
     /* flip backslashes */
     for (p = rel; *p != '\0'; p++)
-      if (*p == '\\') *p = '/';    
+      if (*p == '\\') *p = '/';
   }
   g_free (bp1);
   g_free (bp2);
-  
+
   return rel;
 }
 


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