From f684562ab96876da07388da7d96063b5c22bdb4d Mon Sep 17 00:00:00 2001 From: randomguy3 Date: Sun, 8 Jan 2012 23:20:48 +0000 Subject: GTK: all icons are now stored in the executable git-svn-id: https://tikzit.svn.sourceforge.net/svnroot/tikzit/trunk@360 7c02a99a-9b00-45e3-bf44-6f3dd7fddb64 --- Makefile.am | 8 +------ share/Makefile.am | 3 +++ src/Makefile.am | 31 +++++++++++++++++++++++++- src/linux/Menu.m | 33 ++++++++++++++++++---------- src/linux/logo.h | 32 +++++++++++++++++++++++++++ src/linux/logo.m | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/linux/main.m | 15 +++++++++++++ 7 files changed, 167 insertions(+), 20 deletions(-) create mode 100644 src/linux/logo.h create mode 100644 src/linux/logo.m diff --git a/Makefile.am b/Makefile.am index 194e716..0c7cb93 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,12 +1,6 @@ SUBDIRS = src share appdir = $(datarootdir)/tikzit -nobase_dist_app_DATA = \ - draw-ellipse.png \ - draw-path.png \ - select-rectangular.png \ - transform-crop-and-resize.png \ - transform-move.png \ - shapes/*.tikz +nobase_dist_app_DATA = shapes/*.tikz if WINDOWS else diff --git a/share/Makefile.am b/share/Makefile.am index 36f7987..d3b6a9d 100644 --- a/share/Makefile.am +++ b/share/Makefile.am @@ -1,6 +1,9 @@ +if WINDOWS +else sharedir = $(datarootdir) nobase_dist_share_DATA = \ applications/tikzit.desktop \ icons/hicolor/*/apps/*.png \ icons/hicolor/scalable/apps/*.svg +endif diff --git a/src/Makefile.am b/src/Makefile.am index d2d558f..37e1914 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,10 +1,16 @@ +if WINDOWS +sharedir = ../ +else +sharedir = @datarootdir@/tikzit +endif + AM_OBJCFLAGS = @GNUSTEPOBJCFLAGS@ \ @GTK_CFLAGS@ \ @GDK_PIXBUF_CFLAGS@ \ @POPPLER_CFLAGS@ \ -I common \ -I linux \ - -DTIKZITSHAREDIR=\"@datarootdir@/tikzit\" \ + -DTIKZITSHAREDIR=\"$(sharedir)\" \ -std=c99 \ -D_GNU_SOURCE LIBS = @GNUSTEPLIBS@ \ @@ -48,6 +54,7 @@ tikzit_SOURCES = linux/CairoRenderContext.m \ linux/cairo_helpers.m \ linux/clipboard.m \ linux/gtkhelpers.m \ + linux/logo.m \ linux/mkdtemp.m \ linux/main.m \ common/BasicMapTable.m \ @@ -92,6 +99,7 @@ tikzit.res: tikzit.rc $(AM_V_GEN)windres $^ -O coff -o $@ tikzit_LDADD = tikzit.res +CLEANFILES = tikzit.res endif common/tikzlexer.m: common/tikzlexer.lm @@ -102,5 +110,26 @@ common/tikzparser.m: common/tikzparser.ym common/tikzparser.h: common/tikzparser.m +linux/icondata.m: ../draw-ellipse.png ../draw-path.png ../select-rectangular.png ../transform-crop-and-resize.png ../transform-move.png + $(AM_V_GEN)gdk-pixbuf-csource --struct --static --raw --build-list \ + draw_ellipse ../draw-ellipse.png \ + draw_path ../draw-path.png \ + select_rectangular ../select-rectangular.png \ + transform_crop_and_resize ../transform-crop-and-resize.png \ + transform_move ../transform-move.png \ + > $@ + +linux/logodata.m: ../share/icons/hicolor/16x16/apps/tikzit.png ../share/icons/hicolor/24x24/apps/tikzit.png ../share/icons/hicolor/48x48/apps/tikzit.png ../share/icons/hicolor/64x64/apps/tikzit.png ../share/icons/hicolor/128x128/apps/tikzit.png + $(AM_V_GEN)gdk-pixbuf-csource --struct --static --raw --build-list \ + logo16 ../share/icons/hicolor/16x16/apps/tikzit.png \ + logo24 ../share/icons/hicolor/24x24/apps/tikzit.png \ + logo48 ../share/icons/hicolor/48x48/apps/tikzit.png \ + logo64 ../share/icons/hicolor/64x64/apps/tikzit.png \ + logo128 ../share/icons/hicolor/128x128/apps/tikzit.png \ + > $@ + +linux/Menu.m: linux/icondata.m +linux/logo.m: linux/logodata.m + EXTRA_DIST = linux/*.h common/*.h $(PARSERFILES) common/tikzlexer.lm common/tikzparser.ym MAINTAINERCLEANFILES = $(PARSERFILES) diff --git a/src/linux/Menu.m b/src/linux/Menu.m index f8c49a2..c7eb16d 100644 --- a/src/linux/Menu.m +++ b/src/linux/Menu.m @@ -41,6 +41,13 @@ #define ACTION_GROUP_DOCUMENT "TZDocument" #define ACTION_GROUP_DOCUMENTS_LIST_MENU "TZDocumentsList" +#import "logo.h" +#include +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpointer-sign" +#import "icondata.m" +#pragma GCC diagnostic pop + // {{{ Callbacks @@ -122,9 +129,10 @@ static void about_cb (GtkAction *action, MainWindow *window) { static const gchar copyright[] = "Copyright \xc2\xa9 2010-2011 Aleks Kissinger, Chris Heunen and Alex Merry."; + GdkPixbuf *logo = get_logo (LOGO_SIZE_128); gtk_show_about_dialog (GTK_WINDOW ([window gtkWindow]), - "name", g_get_application_name (), - "logo-icon-name", "tikzit", + "program-name", PACKAGE_NAME, + "logo", logo, "authors", authors, "translator-credits", _("translator-credits"), "comments", _("A graph manipulation program for pgf/tikz graphs"), @@ -134,6 +142,7 @@ static void about_cb (GtkAction *action, MainWindow *window) { "version", PACKAGE_VERSION, "website", "http://tikzit.sourceforge.net", NULL); + g_object_unref (logo); } static void undo_cb (GtkAction *action, MainWindow *window) { @@ -568,14 +577,14 @@ static guint n_toolbar_style_entries = G_N_ELEMENTS (toolbar_style_entries); static void -set_tool_button_image (GtkToolButton *button, const gchar *image_file) +set_tool_button_image (GtkToolButton *button, const GdkPixdata *image_data) { GtkWidget *image = NULL; - if (image_file) { - gchar *image_path = g_build_filename (TIKZITSHAREDIR, image_file, NULL); - image = gtk_image_new_from_file (image_path); - g_free (image_path); + if (image_data) { + GdkPixbuf *buf = gdk_pixbuf_from_pixdata (image_data, FALSE, NULL); + image = gtk_image_new_from_pixbuf (buf); + g_object_unref (buf); } gtk_tool_button_set_icon_widget (button, image); @@ -670,11 +679,11 @@ create_recent_chooser_menu () } /* Set custom images for tool mode buttons */ - set_tool_button_image (GTK_TOOL_BUTTON (gtk_ui_manager_get_widget (ui, "/ToolBar/SelectMode")), "select-rectangular.png"); - set_tool_button_image (GTK_TOOL_BUTTON (gtk_ui_manager_get_widget (ui, "/ToolBar/CreateNodeMode")), "draw-ellipse.png"); - set_tool_button_image (GTK_TOOL_BUTTON (gtk_ui_manager_get_widget (ui, "/ToolBar/DrawEdgeMode")), "draw-path.png"); - set_tool_button_image (GTK_TOOL_BUTTON (gtk_ui_manager_get_widget (ui, "/ToolBar/BoundingBoxMode")), "transform-crop-and-resize.png"); - set_tool_button_image (GTK_TOOL_BUTTON (gtk_ui_manager_get_widget (ui, "/ToolBar/HandMode")), "transform-move.png"); + set_tool_button_image (GTK_TOOL_BUTTON (gtk_ui_manager_get_widget (ui, "/ToolBar/SelectMode")), &select_rectangular); + set_tool_button_image (GTK_TOOL_BUTTON (gtk_ui_manager_get_widget (ui, "/ToolBar/CreateNodeMode")), &draw_ellipse); + set_tool_button_image (GTK_TOOL_BUTTON (gtk_ui_manager_get_widget (ui, "/ToolBar/DrawEdgeMode")), &draw_path); + set_tool_button_image (GTK_TOOL_BUTTON (gtk_ui_manager_get_widget (ui, "/ToolBar/BoundingBoxMode")), &transform_crop_and_resize); + set_tool_button_image (GTK_TOOL_BUTTON (gtk_ui_manager_get_widget (ui, "/ToolBar/HandMode")), &transform_move); /* Save the undo and redo actions so they can be updated */ undoAction = gtk_action_group_get_action (documentActions, "Undo"); diff --git a/src/linux/logo.h b/src/linux/logo.h new file mode 100644 index 0000000..48a70ba --- /dev/null +++ b/src/linux/logo.h @@ -0,0 +1,32 @@ +/* + * Copyright 2012 Alex Merry + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include + +typedef enum { + LOGO_SIZE_16, + LOGO_SIZE_24, + //LOGO_SIZE_32, + LOGO_SIZE_48, + LOGO_SIZE_64, + LOGO_SIZE_128, + LOGO_SIZE_COUNT +} LogoSize; + +GdkPixbuf *get_logo (LogoSize size); + +// vim:ft=objc:ts=8:et:sts=4:sw=4 diff --git a/src/linux/logo.m b/src/linux/logo.m new file mode 100644 index 0000000..1bf006d --- /dev/null +++ b/src/linux/logo.m @@ -0,0 +1,65 @@ +/* + * Copyright 2012 Alex Merry + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#import "logo.h" +#include + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpointer-sign" +#import "logodata.m" +#pragma GCC diagnostic pop + +static GdkPixbuf *pixbufCache[LOGO_SIZE_COUNT]; + +GdkPixbuf *get_logo (LogoSize size) { + const GdkPixdata *data = NULL; + switch (size) { + case LOGO_SIZE_16: + data = &logo16; + break; + case LOGO_SIZE_24: + data = &logo24; + break; +/* case LOGO_SIZE_32: + data = &logo32; + break; +*/ + case LOGO_SIZE_48: + data = &logo48; + break; + case LOGO_SIZE_64: + data = &logo64; + break; + case LOGO_SIZE_128: + data = &logo128; + break; + default: + return NULL; + }; + if (pixbufCache[size]) { + g_object_ref (pixbufCache[size]); + return pixbufCache[size]; + } else { + GdkPixbuf *buf = gdk_pixbuf_from_pixdata (data, FALSE, NULL); + pixbufCache[size] = buf; + g_object_add_weak_pointer (G_OBJECT (buf), (void**)(&(pixbufCache[size]))); + return buf; + } +} + +// vim:ft=objc:ts=8:et:sts=4:sw=4 + diff --git a/src/linux/main.m b/src/linux/main.m index 7047e7f..9e39f27 100644 --- a/src/linux/main.m +++ b/src/linux/main.m @@ -24,6 +24,7 @@ #import "TZFoundation.h" #import #import "clipboard.h" +#import "logo.h" #import "MainWindow.h" #import "TikzGraphAssembler.h" @@ -42,6 +43,20 @@ int main (int argc, char *argv[]) { NSAutoreleasePool *initPool = [[NSAutoreleasePool alloc] init]; + GList *icon_list = NULL; + g_list_prepend (icon_list, get_logo(LOGO_SIZE_128)); + g_list_prepend (icon_list, get_logo(LOGO_SIZE_64)); + g_list_prepend (icon_list, get_logo(LOGO_SIZE_48)); + //g_list_prepend (icon_list, get_logo(LOGO_SIZE_32)); + g_list_prepend (icon_list, get_logo(LOGO_SIZE_24)); + g_list_prepend (icon_list, get_logo(LOGO_SIZE_16)); + gtk_window_set_default_icon_list (icon_list); + GList *list_head = icon_list; + while (list_head) { + g_object_unref ((GObject*)list_head->data); + list_head = list_head->next; + } + clipboard_init(); [TikzGraphAssembler setup]; MainWindow *window = [[MainWindow alloc] init]; -- cgit v1.2.3