diff options
author | randomguy3 <randomguy3@7c02a99a-9b00-45e3-bf44-6f3dd7fddb64> | 2012-01-08 23:20:48 +0000 |
---|---|---|
committer | randomguy3 <randomguy3@7c02a99a-9b00-45e3-bf44-6f3dd7fddb64> | 2012-01-08 23:20:48 +0000 |
commit | f684562ab96876da07388da7d96063b5c22bdb4d (patch) | |
tree | d77e6766f2ac93507bf966f58288e2f46f455af0 /src/linux | |
parent | e9b614e436b5720c1b2c51a07c5c063197cbf1e1 (diff) |
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
Diffstat (limited to 'src/linux')
-rw-r--r-- | src/linux/Menu.m | 33 | ||||
-rw-r--r-- | src/linux/logo.h | 32 | ||||
-rw-r--r-- | src/linux/logo.m | 65 | ||||
-rw-r--r-- | src/linux/main.m | 15 |
4 files changed, 133 insertions, 12 deletions
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 <gdk-pixbuf/gdk-pixdata.h> +#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 <alex.merry@kdemail.net> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#include <gdk-pixbuf/gdk-pixbuf.h> + +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 <alex.merry@kdemail.net> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#import "logo.h" +#include <gdk-pixbuf/gdk-pixdata.h> + +#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 <gtk/gtk.h> #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]; |