From f819c5ba44023769d5c8512cdf489d001c1da09d Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Thu, 19 Apr 2012 13:22:42 +0100 Subject: Edges can now be reversed easily --- tikzit/NEWS | 1 + tikzit/src/common/Graph.h | 7 +++++++ tikzit/src/common/Graph.m | 19 ++++++++++++++++--- tikzit/src/common/GraphChange.h | 9 ++++++++- tikzit/src/common/GraphChange.m | 10 ++++++++++ tikzit/src/gtk/Menu.h | 2 ++ tikzit/src/gtk/Menu.m | 18 ++++++++++++++++++ tikzit/src/gtk/TikzDocument.h | 1 + tikzit/src/gtk/TikzDocument.m | 8 +++++++- 9 files changed, 70 insertions(+), 5 deletions(-) (limited to 'tikzit') diff --git a/tikzit/NEWS b/tikzit/NEWS index fdac837..1811ac4 100644 --- a/tikzit/NEWS +++ b/tikzit/NEWS @@ -12,6 +12,7 @@ tikzit 0.8 (2012-01-??): * Nodes and edges have consistent ordering, and this can be changed with Edge->Arrange * Edges now have colours + * Edges can now be reversed easily tikzit 0.7 (2011-12-06): * Add bounding box support diff --git a/tikzit/src/common/Graph.h b/tikzit/src/common/Graph.h index c680219..f5d8bed 100644 --- a/tikzit/src/common/Graph.h +++ b/tikzit/src/common/Graph.h @@ -277,6 +277,13 @@ */ - (GraphChange*)shiftNodes:(id)ns byPoint:(NSPoint)p; +/*! + @brief Reverse the given edges + @param es the edges to reverse + @result A GraphChange recording this action. + */ +- (GraphChange*)reverseEdges:(NSSet *)es; + /*! @brief Insert the given graph into this one. Used for copy and paste. diff --git a/tikzit/src/common/Graph.m b/tikzit/src/common/Graph.m index d04751a..27c2ebb 100644 --- a/tikzit/src/common/Graph.m +++ b/tikzit/src/common/Graph.m @@ -247,9 +247,7 @@ - (GraphChange*)removeEdges:(NSSet *)es { [graphLock lock]; - NSEnumerator *en = [es objectEnumerator]; - Edge *e; - while ((e = [en nextObject])) { + for (Edge *e in es) { [edges removeObject:e]; } dirty = YES; @@ -272,6 +270,16 @@ return [GraphChange shiftNodes:nodeSet byPoint:p]; } +- (GraphChange*)reverseEdges:(NSSet *)es { + [graphLock lock]; + for (Edge *e in es) { + [e reverse]; + } + dirty = YES; + [graphLock unlock]; + return [GraphChange reverseEdges:es]; +} + - (int)indexOfNode:(Node *)node { return [nodes indexOfObject:node]; } @@ -633,6 +641,11 @@ case NodesFlip: [self flipNodes:[ch affectedNodes] horizontal:[ch horizontal]]; break; + case EdgesReverse: + for (Edge *e in [[ch affectedEdges] objectEnumerator]) { + [e reverse]; + } + break; case BoundingBoxChange: [self setBoundingBox:[ch nwBoundingBox]]; break; diff --git a/tikzit/src/common/GraphChange.h b/tikzit/src/common/GraphChange.h index cb4ca09..ef56005 100644 --- a/tikzit/src/common/GraphChange.h +++ b/tikzit/src/common/GraphChange.h @@ -33,6 +33,7 @@ typedef enum { EdgesPropertyChange, NodesShift, NodesFlip, + EdgesReverse, BoundingBoxChange, GraphPropertyChange, NodeOrderChange, @@ -291,7 +292,6 @@ typedef enum { */ + (GraphChange*)shiftNodes:(NSSet*)ns byPoint:(NSPoint)p; - /*! @brief Construct a horizontal or vertical flip of a set of nodes. @param ns the affected nodes. @@ -300,6 +300,13 @@ typedef enum { */ + (GraphChange*)flipNodes:(NSSet*)ns horizontal:(BOOL)b; +/*! + @brief Construct a reversal of a set of edges. + @param es the affected edges. + @result A reverse of a set of edges. + */ ++ (GraphChange*)reverseEdges:(NSSet*)es; + /*! @brief Construct a bounding box change @param oldBB the old bounding box diff --git a/tikzit/src/common/GraphChange.m b/tikzit/src/common/GraphChange.m index 9707a19..c52a46d 100644 --- a/tikzit/src/common/GraphChange.m +++ b/tikzit/src/common/GraphChange.m @@ -90,6 +90,9 @@ inverse->affectedNodes = [affectedNodes retain]; [inverse setHorizontal:[self horizontal]]; break; + case EdgesReverse: + inverse->affectedEdges = [affectedEdges retain]; + break; case BoundingBoxChange: inverse->oldBoundingBox = nwBoundingBox; inverse->nwBoundingBox = oldBoundingBox; @@ -197,6 +200,13 @@ return [gc autorelease]; } ++ (GraphChange*)reverseEdges:(NSSet*)es { + GraphChange *gc = [[GraphChange alloc] init]; + [gc setChangeType:EdgesReverse]; + [gc setAffectedEdges:es]; + return [gc autorelease]; +} + + (GraphChange*)changeBoundingBoxFrom:(NSRect)oldBB to:(NSRect)newBB { GraphChange *gc = [[GraphChange alloc] init]; [gc setChangeType:BoundingBoxChange]; diff --git a/tikzit/src/gtk/Menu.h b/tikzit/src/gtk/Menu.h index 024c9e0..5a364e4 100644 --- a/tikzit/src/gtk/Menu.h +++ b/tikzit/src/gtk/Menu.h @@ -39,6 +39,8 @@ GtkAction *pasteAction; GtkAction **nodeSelBasedActions; guint nodeSelBasedActionCount; + GtkAction **edgeSelBasedActions; + guint edgeSelBasedActionCount; GtkAction **selBasedActions; guint selBasedActionCount; } diff --git a/tikzit/src/gtk/Menu.m b/tikzit/src/gtk/Menu.m index ea2e333..37ab87c 100644 --- a/tikzit/src/gtk/Menu.m +++ b/tikzit/src/gtk/Menu.m @@ -224,6 +224,12 @@ static void flip_vert_cb (GtkAction *action, MainWindow *window) { [pool drain]; } +static void reverse_edges_cb (GtkAction *action, MainWindow *window) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + [[window activeDocument] reverseSelectedEdges]; + [pool drain]; +} + static void bring_forward_cb (GtkAction *action, MainWindow *window) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [[window activeDocument] bringSelectionForward]; @@ -375,6 +381,7 @@ static const gchar ui_info[] = " " " " " " +" " " " " " " " @@ -561,6 +568,9 @@ static GtkActionEntry document_entries[] = { { "FlipVert", NULL, N_("Flip nodes _vertically"), NULL, N_("Flip the selected nodes vertically"), G_CALLBACK (flip_vert_cb) }, + { "ReverseEdges", NULL, N_("Rever_se edges"), NULL, + N_("Reverse the selected edges"), G_CALLBACK (reverse_edges_cb) }, + { "SendToBack", NULL, N_("Send to _back"), NULL, N_("Send the selected nodes and edges to the back of the graph"), G_CALLBACK (send_to_back_cb) }, @@ -764,6 +774,9 @@ create_recent_chooser_menu () nodeSelBasedActions[1] = gtk_action_group_get_action (documentActions, "Copy"); nodeSelBasedActions[2] = gtk_action_group_get_action (documentActions, "FlipHoriz"); nodeSelBasedActions[3] = gtk_action_group_get_action (documentActions, "FlipVert"); + edgeSelBasedActionCount = 1; + edgeSelBasedActions = g_new (GtkAction*, edgeSelBasedActionCount); + edgeSelBasedActions[0] = gtk_action_group_get_action (documentActions, "ReverseEdges"); selBasedActionCount = 2; selBasedActions = g_new (GtkAction*, selBasedActionCount); selBasedActions[0] = gtk_action_group_get_action (documentActions, "Delete"); @@ -820,6 +833,11 @@ create_recent_chooser_menu () gtk_action_set_sensitive (nodeSelBasedActions[i], hasSelectedNodes); } } + for (int i = 0; i < edgeSelBasedActionCount; ++i) { + if (edgeSelBasedActions[i]) { + gtk_action_set_sensitive (edgeSelBasedActions[i], hasSelectedEdges); + } + } for (int i = 0; i < selBasedActionCount; ++i) { if (selBasedActions[i]) { gtk_action_set_sensitive (selBasedActions[i], hasSelectedNodes || hasSelectedEdges); diff --git a/tikzit/src/gtk/TikzDocument.h b/tikzit/src/gtk/TikzDocument.h index ddeaf29..79a9b17 100644 --- a/tikzit/src/gtk/TikzDocument.h +++ b/tikzit/src/gtk/TikzDocument.h @@ -152,6 +152,7 @@ - (void) insertGraph:(Graph*)g; - (void) flipSelectedNodesHorizontally; - (void) flipSelectedNodesVertically; +- (void) reverseSelectedEdges; - (void) bringSelectionForward; - (void) bringSelectionToFront; - (void) sendSelectionBackward; diff --git a/tikzit/src/gtk/TikzDocument.m b/tikzit/src/gtk/TikzDocument.m index a5f1d9f..2016d2a 100644 --- a/tikzit/src/gtk/TikzDocument.m +++ b/tikzit/src/gtk/TikzDocument.m @@ -726,7 +726,13 @@ } } -// FIXME: undo +- (void) reverseSelectedEdges { + if ([[pickSupport selectedEdges] count] > 0) { + GraphChange *change = [graph reverseEdges:[pickSupport selectedEdges]]; + [self completedGraphChange:change withName:@"Reverse edges"]; + } +} + - (void) bringSelectionForward { BOOL hasNodeSelection = [[pickSupport selectedNodes] count] > 0; BOOL hasEdgeSelection = [[pickSupport selectedEdges] count] > 0; -- cgit v1.2.3 From ae0c9768b29086da17feab3db0e8d6e8ee8e2585 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Fri, 4 May 2012 14:05:54 +0100 Subject: Bump to version 1.0 Also set spec requirements --- tikzit/configure.ac | 2 +- tikzit/tikzit.spec | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'tikzit') diff --git a/tikzit/configure.ac b/tikzit/configure.ac index 114c154..d610fc5 100644 --- a/tikzit/configure.ac +++ b/tikzit/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.60]) -AC_INIT([TikZiT], [0.7], +AC_INIT([TikZiT], [1.0], [http://sourceforge.net/apps/trac/tikzit], [tikzit], [http://tikzit.sourceforge.net]) diff --git a/tikzit/tikzit.spec b/tikzit/tikzit.spec index 90e8386..67fad52 100644 --- a/tikzit/tikzit.spec +++ b/tikzit/tikzit.spec @@ -1,5 +1,5 @@ Name: tikzit -Version: 0.7 +Version: 1.0 Release: 1%{?dist} Summary: Tool for creating and modifying pgf/TikZ diagrams for TeX @@ -19,15 +19,15 @@ URL: http://tikzit.sourceforge.net Source0: http://switch.dl.sourceforge.net/project/%{name}/%{name}-%{version}/%{name}-%{version}.tar.bz2 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-build -BuildRequires: gcc-objc +BuildRequires: gcc-objc >= 4.6.0 BuildRequires: gnustep-base-devel >= 1.18.0 BuildRequires: gtk2-devel >= 2.18.0 BuildRequires: pango-devel >= 1.16 BuildRequires: cairo-devel >= 1.4 %if 0%{?suse_version}%{?mdkversion} -BuildRequires: libpoppler-glib-devel +BuildRequires: libpoppler-glib-devel >= 0.10 %else -BuildRequires: poppler-glib-devel +BuildRequires: poppler-glib-devel >= 0.10 %endif %if 0%{?suse_version} BuildRequires: update-desktop-files @@ -71,6 +71,10 @@ rm -rf %{buildroot} %changelog +* Tue Dec 06 2011 Alex Merry 1.0-1 +-Bumped version +-Bumped requirements + * Tue Dec 06 2011 Alex Merry 0.7-1 -Bumped version -- cgit v1.2.3 From 70b23cf6f3689c702a07925f14216a3385faa7a9 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Fri, 4 May 2012 14:12:05 +0100 Subject: We actually require gtk+ 2.18 --- tikzit/configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tikzit') diff --git a/tikzit/configure.ac b/tikzit/configure.ac index d610fc5..8f791b6 100644 --- a/tikzit/configure.ac +++ b/tikzit/configure.ac @@ -67,8 +67,8 @@ AM_CONDITIONAL([HAVE_POPPLER],[test "x$have_poppler" = "xyes"]) # Test all the pkg-config stuff together, so that # dependencies and duplicate flags are correctly handled AS_IF([test "x$have_poppler" = "xyes"], - [PKG_CHECK_MODULES([GTK], [gtk+-2.0 >= 2.16.0 gdk-pixbuf-2.0 >= 2.16.0 pango >= 1.16 cairo >= 1.4 poppler-glib >= 0.10])], - [PKG_CHECK_MODULES([GTK], [gtk+-2.0 >= 2.16.0 gdk-pixbuf-2.0 >= 2.16.0 pango >= 1.16 cairo >= 1.4])]) + [PKG_CHECK_MODULES([GTK], [gtk+-2.0 >= 2.18.0 gdk-pixbuf-2.0 >= 2.16.0 pango >= 1.16 cairo >= 1.4 poppler-glib >= 0.10])], + [PKG_CHECK_MODULES([GTK], [gtk+-2.0 >= 2.18.0 gdk-pixbuf-2.0 >= 2.16.0 pango >= 1.16 cairo >= 1.4])]) # Checks for header files. AC_FUNC_ALLOCA -- cgit v1.2.3 From 91ca7db574491e049ba4d7621284b73f5a232b0e Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Fri, 4 May 2012 14:14:17 +0100 Subject: Ignore package files --- tikzit/.gitignore | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tikzit') diff --git a/tikzit/.gitignore b/tikzit/.gitignore index 0f5e855..7fede17 100644 --- a/tikzit/.gitignore +++ b/tikzit/.gitignore @@ -23,3 +23,5 @@ Makefile.in /src/gtk/icondata.m /src/gtk/logodata.m /src/gtk/edgedecdata.m +/tikzit-*.tar.gz +/tikzit-*.tar.bz2 -- cgit v1.2.3 From 78c31f941a5be18b0b094718e203fed99040b493 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Fri, 4 May 2012 14:25:09 +0100 Subject: GTK: Add missing DIST files --- tikzit/src/Makefile.am | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'tikzit') diff --git a/tikzit/src/Makefile.am b/tikzit/src/Makefile.am index 4a63760..29b4cb6 100644 --- a/tikzit/src/Makefile.am +++ b/tikzit/src/Makefile.am @@ -15,6 +15,12 @@ LIBS = @FOUNDATION_LIBS@ \ @GTK_LIBS@ AM_YFLAGS = -d PARSERFILES = common/tikzlexer.m common/tikzparser.m common/tikzparser.h +ICONFILES = ../draw-ellipse.png \ + ../draw-path.png \ + ../select-rectangular.png \ + ../transform-crop-and-resize.png \ + ../transform-move.png +EDGEDECFILES = ../AH_*.png ../ED_*.png bin_PROGRAMS = tikzit BUILT_SOURCES = $(PARSERFILES) @@ -111,7 +117,7 @@ common/tikzparser.m: common/tikzparser.ym common/tikzparser.h: common/tikzparser.m -gtk/icondata.m: ../draw-ellipse.png ../draw-path.png ../select-rectangular.png ../transform-crop-and-resize.png ../transform-move.png +gtk/icondata.m: $(ICONFILES) $(AM_V_GEN)gdk-pixbuf-csource --struct --static --raw --build-list \ draw_ellipse ../draw-ellipse.png \ draw_path ../draw-path.png \ @@ -130,7 +136,7 @@ gtk/logodata.m: ../share/icons/hicolor/*/apps/tikzit.png logo128 ../share/icons/hicolor/128x128/apps/tikzit.png \ > $@ -gtk/edgedecdata.m: ../AH_*.png ../ED_*.png +gtk/edgedecdata.m: $(EDGEDECFILES) $(AM_V_GEN)gdk-pixbuf-csource --struct --static --raw --build-list \ AH_none_pixdata ../AH_none.png \ AH_latex_head_pixdata ../AH_latex_head.png \ @@ -146,5 +152,5 @@ gtk/Menu.m: gtk/icondata.m gtk/logo.m: gtk/logodata.m gtk/EdgeStyleEditor.m: gtk/edgedecdata.m -EXTRA_DIST = gtk/*.h common/*.h $(PARSERFILES) common/tikzlexer.lm common/tikzparser.ym +EXTRA_DIST = gtk/*.h common/*.h $(PARSERFILES) common/tikzlexer.lm common/tikzparser.ym $(ICONFILES) $(EDGEDECFILES) MAINTAINERCLEANFILES = $(PARSERFILES) gtk/icondata.m gtk/logodata.m gtk/edgedecdata.m -- cgit v1.2.3 From ff8296e4b074cdc4a59fa208e6ac620bed44661d Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Fri, 4 May 2012 14:27:12 +0100 Subject: Avoid deprecated methods --- tikzit/src/gtk/EdgeStyleSelector.m | 4 ++-- tikzit/src/gtk/NodeStyleSelector.m | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'tikzit') diff --git a/tikzit/src/gtk/EdgeStyleSelector.m b/tikzit/src/gtk/EdgeStyleSelector.m index 544ed98..c9c9780 100644 --- a/tikzit/src/gtk/EdgeStyleSelector.m +++ b/tikzit/src/gtk/EdgeStyleSelector.m @@ -289,7 +289,7 @@ enum { } else { GdkPixbuf *pixbuf = [self pixbufOfEdgeInStyle:style]; gtk_list_store_set (store, &row, STYLES_ICON_COL, pixbuf, -1); - gdk_pixbuf_unref (pixbuf); + g_object_unref (pixbuf); } } } while (gtk_tree_model_iter_next (model, &row)); @@ -411,7 +411,7 @@ enum { STYLES_ICON_COL, pixbuf, STYLES_PTR_COL, (gpointer)[style retain], -1); - gdk_pixbuf_unref (pixbuf); + g_object_unref (pixbuf); [self observeStyle:style]; } diff --git a/tikzit/src/gtk/NodeStyleSelector.m b/tikzit/src/gtk/NodeStyleSelector.m index af02338..885dc79 100644 --- a/tikzit/src/gtk/NodeStyleSelector.m +++ b/tikzit/src/gtk/NodeStyleSelector.m @@ -282,7 +282,7 @@ enum { } else { GdkPixbuf *pixbuf = [self pixbufOfNodeInStyle:style]; gtk_list_store_set (store, &row, STYLES_ICON_COL, pixbuf, -1); - gdk_pixbuf_unref (pixbuf); + g_object_unref (pixbuf); } } } while (gtk_tree_model_iter_next (model, &row)); @@ -387,7 +387,7 @@ enum { STYLES_ICON_COL, pixbuf, STYLES_PTR_COL, (gpointer)[style retain], -1); - gdk_pixbuf_unref (pixbuf); + g_object_unref (pixbuf); [self observeStyle:style]; } -- cgit v1.2.3 From 6c41239ab07752b4ba5009522bbaca0f3e0cdbc6 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Fri, 4 May 2012 14:36:36 +0100 Subject: Fix license header --- tikzit/src/gtk/mkdtemp.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tikzit') diff --git a/tikzit/src/gtk/mkdtemp.m b/tikzit/src/gtk/mkdtemp.m index f6b73aa..ee3cd7c 100644 --- a/tikzit/src/gtk/mkdtemp.m +++ b/tikzit/src/gtk/mkdtemp.m @@ -13,8 +13,8 @@ You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ + see . + */ /* Extracted from misc/mkdtemp.c and sysdeps/posix/tempname.c. */ -- cgit v1.2.3 From 37e7f18392109225ca5c257d14eda2f89a938370 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Mon, 7 May 2012 14:39:54 +0100 Subject: Correctly remove $ at end of latex commands Previously, a string like '$\alpha$' would retain the final $ when displayed on a label. --- tikzit/src/common/NSString+LatexConstants.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tikzit') diff --git a/tikzit/src/common/NSString+LatexConstants.m b/tikzit/src/common/NSString+LatexConstants.m index d2d0ed8..bd598b7 100644 --- a/tikzit/src/common/NSString+LatexConstants.m +++ b/tikzit/src/common/NSString+LatexConstants.m @@ -176,7 +176,9 @@ static NSSet *texModifiers = nil; if (c=='\\') { state = 1; } else { - [buf appendFormat:@"%C", c]; + if (c!='$') { + [buf appendFormat:@"%C", c]; + } state = 0; } -- cgit v1.2.3