[dia] tool_get_pixbuf: create a GdkPixbuf* from tool icon



commit 0093e54927eba3c403e91ad8a3a6b04177fcb2b0
Author: Hans Breuer <hans breuer org>
Date:   Sat Jan 29 19:40:35 2011 +0100

    tool_get_pixbuf: create a GdkPixbuf* from tool icon

 app/interface.c |   27 +++++++++++++++++++++++++++
 app/interface.h |    2 ++
 2 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/app/interface.c b/app/interface.c
index 0e81663..b7c6421 100644
--- a/app/interface.c
+++ b/app/interface.c
@@ -1087,6 +1087,33 @@ tool_select_callback(GtkWidget *widget, gpointer data) {
 }
 */
 
+GdkPixbuf *
+tool_get_pixbuf (ToolButton *tb)
+{
+  GdkPixbuf *pixbuf;
+  gchar **icon_data;
+
+  if (tb->icon_data==NULL) {
+    DiaObjectType *type;
+    
+    type = object_get_type((char *)tb->callback_data.extra_data);
+    if (type == NULL)
+      icon_data = tool_data[0].icon_data;
+    else
+      icon_data = type->pixmap;
+  } else {
+    icon_data = tb->icon_data;
+  }
+  
+  if (strncmp((char*)icon_data, "GdkP", 4) == 0) {
+    pixbuf = gdk_pixbuf_new_from_inline(-1, (guint8*)icon_data, TRUE, NULL);
+  } else {
+    char **pixmap_data = icon_data;
+    pixbuf = gdk_pixbuf_new_from_xpm_data (pixmap_data);
+  }
+  return pixbuf;
+}
+
 /*
  * Don't look too deep into this function. It is doing bad things
  * with casts to conform to the historically interface. We know
diff --git a/app/interface.h b/app/interface.h
index 2017e5b..a09fbc1 100644
--- a/app/interface.h
+++ b/app/interface.h
@@ -99,4 +99,6 @@ void fill_sheet_menu(void);
 
 void close_notebook_page_callback (GtkButton *button, gpointer user_data);
 
+GdkPixbuf *tool_get_pixbuf (ToolButton *tb);
+
 #endif /* INTERFACE_H */



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