Blame marco_add-pixbuf-inline-icons.patch

raveit65 07f8e97
diff -upr marco-1.7.0-orig/src/Makefile.am marco-1.7.0/src/Makefile.am
raveit65 07f8e97
--- marco-1.7.0-orig/src/Makefile.am	2014-01-25 11:38:54.000000000 +0100
raveit65 07f8e97
+++ marco-1.7.0/src/Makefile.am	2014-02-10 19:16:21.430872812 +0100
raveit65 07f8e97
@@ -191,14 +191,27 @@ xml_in_files = \
raveit65 3243dae
 	50-marco-global-key.xml.in
raveit65 3243dae
 xml_DATA = $(xml_in_files:.xml.in=.xml)
raveit65 3243dae
 
raveit65 3243dae
-BUILT_SOURCES =
raveit65 3243dae
+@INTLTOOL_SCHEMAS_RULE@
raveit65 3243dae
+
raveit65 3243dae
+IMAGES=stock_maximize.png stock_minimize.png stock_delete.png window.png mini-window.png
raveit65 3243dae
+VARIABLES=stock_maximize_data $(srcdir)/stock_maximize.png \
raveit65 3243dae
+          stock_minimize_data $(srcdir)/stock_minimize.png \
raveit65 3243dae
+          stock_delete_data $(srcdir)/stock_delete.png \
raveit65 3243dae
+          mini_window_data $(srcdir)/mini-window.png \
raveit65 3243dae
+          window_data $(srcdir)/window.png
raveit65 3243dae
+
raveit65 3243dae
+BUILT_SOURCES = inlinepixbufs.h
raveit65 3243dae
 CLEANFILES = \
raveit65 3243dae
+	inlinepixbufs.h \
raveit65 3243dae
 	marco.desktop \
raveit65 3243dae
 	marco-wm.desktop \
raveit65 3243dae
 	50-marco-desktop-key.xml \
raveit65 3243dae
 	50-marco-global-key.xml \
raveit65 3243dae
 	50-marco-window-key.xml
raveit65 3243dae
 
raveit65 3243dae
+inlinepixbufs.h: $(IMAGES)
raveit65 3243dae
+	$(AM_V_GEN)$(GDK_PIXBUF_CSOURCE) --raw --build-list $(VARIABLES) >$(srcdir)/inlinepixbufs.h
raveit65 3243dae
+
raveit65 3243dae
 pkgconfigdir = $(libdir)/pkgconfig
raveit65 3243dae
 
raveit65 3243dae
 pkgconfig_DATA = libmarco-private.pc
raveit65 07f8e97
diff -upr marco-1.7.0-orig/src/ui/ui.c marco-1.7.0/src/ui/ui.c
raveit65 07f8e97
--- marco-1.7.0-orig/src/ui/ui.c	2014-01-25 11:38:54.000000000 +0100
raveit65 07f8e97
+++ marco-1.7.0/src/ui/ui.c	2014-02-10 19:30:19.805185197 +0100
raveit65 07f8e97
@@ -28,6 +28,8 @@
raveit65 3243dae
 #include "core.h"
raveit65 3243dae
 #include "theme.h"
raveit65 3243dae
 
raveit65 3243dae
+#include "inlinepixbufs.h"
raveit65 3243dae
+
raveit65 3243dae
 #include <string.h>
raveit65 3243dae
 #include <stdlib.h>
raveit65 3243dae
 
raveit65 07f8e97
@@ -35,6 +37,7 @@
raveit65 07f8e97
 #include <cairo-xlib.h>
raveit65 07f8e97
 #endif
raveit65 07f8e97
 
raveit65 3243dae
+static void meta_stock_icons_init (void);
raveit65 3243dae
 static void meta_ui_accelerator_parse(const char* accel, guint* keysym, guint* keycode, GdkModifierType* keymask);
raveit65 3243dae
 
raveit65 3243dae
 struct _MetaUI {
raveit65 07f8e97
@@ -55,6 +58,7 @@ void meta_ui_init(int* argc, char*** arg
raveit65 3243dae
 	if (!gtk_init_check (argc, argv))
raveit65 3243dae
 	{
raveit65 3243dae
 		meta_fatal ("Unable to open X display %s\n", XDisplayName (NULL));
raveit65 3243dae
+		meta_stock_icons_init ();
raveit65 3243dae
 	}
raveit65 3243dae
 }
raveit65 3243dae
 
raveit65 07f8e97
@@ -626,6 +630,7 @@ meta_image_window_set (MetaImageWindow *
raveit65 3243dae
                        int              x,
raveit65 3243dae
                        int              y)
raveit65 3243dae
 {
raveit65 3243dae
+  GdkWindow *window;
raveit65 07f8e97
 #if GTK_CHECK_VERSION (3, 0, 0)
raveit65 3243dae
   cairo_t *cr;
raveit65 07f8e97
 #endif
raveit65 07f8e97
@@ -652,7 +657,8 @@ meta_image_window_set (MetaImageWindow *
raveit65 3243dae
   cairo_destroy (cr);
raveit65 07f8e97
 #endif
raveit65 3243dae
 
raveit65 07f8e97
-  gdk_window_set_back_pixmap (gtk_widget_get_window (iw->window),
raveit65 3243dae
+  window = gtk_widget_get_window (iw->window);
raveit65 3243dae
+  gdk_window_set_back_pixmap (window,
raveit65 3243dae
                               iw->pixmap,
raveit65 3243dae
                               FALSE);
raveit65 3243dae
 
raveit65 07f8e97
@@ -845,11 +851,9 @@ meta_ui_get_default_window_icon (MetaUI
raveit65 3243dae
                                                    0,
raveit65 3243dae
                                                    NULL);
raveit65 3243dae
       else
raveit65 3243dae
-          default_icon = gtk_icon_theme_load_icon (theme,
raveit65 3243dae
-                                                   "gtk-missing-image",
raveit65 3243dae
-                                                   META_ICON_WIDTH,
raveit65 3243dae
-                                                   0,
raveit65 3243dae
-                                                   NULL);
raveit65 3243dae
+          default_icon = gdk_pixbuf_new_from_inline (-1, window_data,
raveit65 3243dae
+                                                     FALSE,
raveit65 3243dae
+                                                     NULL);
raveit65 3243dae
 
raveit65 3243dae
       g_assert (default_icon);
raveit65 3243dae
     }
raveit65 07f8e97
@@ -880,11 +884,9 @@ meta_ui_get_default_mini_icon (MetaUI *u
raveit65 3243dae
                                                    0,
raveit65 3243dae
                                                    NULL);
raveit65 3243dae
       else
raveit65 3243dae
-          default_icon = gtk_icon_theme_load_icon (theme,
raveit65 3243dae
-                                                   "gtk-missing-image",
raveit65 3243dae
-                                                   META_MINI_ICON_WIDTH,
raveit65 3243dae
-                                                   0,
raveit65 3243dae
-                                                   NULL);
raveit65 3243dae
+          default_icon = gdk_pixbuf_new_from_inline (-1, window_data,
raveit65 3243dae
+                                                     FALSE,
raveit65 3243dae
+                                                     NULL);
raveit65 3243dae
 
raveit65 3243dae
       g_assert (default_icon);
raveit65 3243dae
     }
raveit65 07f8e97
@@ -1194,6 +1196,41 @@ typedef struct {
raveit65 3243dae
 	const guint8* icon_data;
raveit65 3243dae
 } MetaStockIcon;
raveit65 3243dae
 
raveit65 3243dae
+static void
raveit65 3243dae
+meta_stock_icons_init (void)
raveit65 3243dae
+{
raveit65 3243dae
+  GtkIconFactory *factory;
raveit65 3243dae
+  int i;
raveit65 3243dae
+
raveit65 3243dae
+  MetaStockIcon items[] =
raveit65 3243dae
+  {
raveit65 3243dae
+    { MARCO_STOCK_DELETE,   stock_delete_data   },
raveit65 3243dae
+    { MARCO_STOCK_MINIMIZE, stock_minimize_data },
raveit65 3243dae
+    { MARCO_STOCK_MAXIMIZE, stock_maximize_data }
raveit65 3243dae
+  };
raveit65 3243dae
+
raveit65 3243dae
+  factory = gtk_icon_factory_new ();
raveit65 3243dae
+  gtk_icon_factory_add_default (factory);
raveit65 3243dae
+
raveit65 3243dae
+  for (i = 0; i < (gint) G_N_ELEMENTS (items); i++)
raveit65 3243dae
+    {
raveit65 3243dae
+      GtkIconSet *icon_set;
raveit65 3243dae
+      GdkPixbuf *pixbuf;
raveit65 3243dae
+
raveit65 3243dae
+      pixbuf = gdk_pixbuf_new_from_inline (-1, items[i].icon_data,
raveit65 3243dae
+					   FALSE,
raveit65 3243dae
+					   NULL);
raveit65 3243dae
+
raveit65 3243dae
+      icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
raveit65 3243dae
+      gtk_icon_factory_add (factory, items[i].stock_id, icon_set);
raveit65 3243dae
+      gtk_icon_set_unref (icon_set);
raveit65 3243dae
+      
raveit65 3243dae
+      g_object_unref (G_OBJECT (pixbuf));
raveit65 3243dae
+    }
raveit65 3243dae
+
raveit65 3243dae
+  g_object_unref (G_OBJECT (factory));
raveit65 3243dae
+}
raveit65 3243dae
+
raveit65 3243dae
 int meta_ui_get_drag_threshold(MetaUI* ui)
raveit65 3243dae
 {
raveit65 3243dae
 	int threshold = 8;