Ticket #51116: patch-ipe-older-osx-versions.diff

File patch-ipe-older-osx-versions.diff, 12.5 KB (added by m7.thon@…, 9 years ago)

Fix ibtool error

  • ipe/Makefile

    diff --git ipe/Makefile ipe/Makefile
    index 06e07ed..6ab7658 100644
    ifdef IPEUI_COCOA 
    5151nib = $(RESOURCEDIR)/mainmenu.nib
    5252
    5353$(nib): mainmenu.xib
     54        $(INSTALL_DIR) $(RESOURCEDIR)
    5455        ibtool --compile $(nib) mainmenu.xib
    5556
    5657else
  • ipe/appui_cocoa.cpp

    diff --git ipe/appui_cocoa.cpp ipe/appui_cocoa.cpp
    index a26f7b8..6f7ecad 100644
    static NSImage *loadIcon(String action) 
    339339  return t;
    340340}
    341341
    342 - (NSArray<NSString *> *) toolbarAllowedItemIdentifiers:(NSToolbar *) toolbar
     342- (NSArray *) toolbarAllowedItemIdentifiers:(NSToolbar *) toolbar
    343343{
    344344  return @[ @"copy", @"cut", @"paste", @"delete", @"undo", @"redo",
    345345            @"zoom_in", @"zoom_out", @"fit_objects", @"fit_page",
    static NSImage *loadIcon(String action) 
    357357           ];
    358358}
    359359
    360 - (NSArray<NSString *> *) toolbarDefaultItemIdentifiers:(NSToolbar *) toolbar
     360- (NSArray *) toolbarDefaultItemIdentifiers:(NSToolbar *) toolbar
    361361{
    362362  return @[ @"mode_select", @"mode_translate", @"mode_rotate",
    363363            @"mode_stretch", @"mode_pan", @"mode_shredder",
    AppUi::AppUi(lua_State *L0, int model) 
    585585  iLayerBox = [[NSBox alloc] initWithFrame:subRect];
    586586  iLayerBox.title = @"Layers";
    587587
    588   NSRect layerFrame = iLayerBox.contentView.frame;
     588  NSRect layerFrame = [iLayerBox.contentView frame];
    589589  iLayerView = [[IpeLayerView alloc] initWithFrame:layerFrame];
    590590  iLayerView.delegate = iDelegate;
    591591  iLayerView.toolTip = @"Layers of this page";
    void AppUi::setCheckMark(String name, String value) 
    921921  NSString *prefix = I2N(name);
    922922  for (NSString *action in iActions) {
    923923    if ([action hasPrefix:prefix])
    924       iActions[action].state = NO;
     924      ((IpeAction *)iActions[action]).state = NO;
    925925  }
    926   iActions[I2N(name + value)].state = YES;
     926  ((IpeAction *)iActions[I2N(name + value)]).state = YES;
    927927}
    928928
    929929void AppUi::setLayers(const Page *page, int view)
    void AppUi::setNumbers(String vno, bool vm, String pno, bool pm) 
    955955BOOL AppUi::validateMenuItem(NSMenuItem *item, NSString *name)
    956956{
    957957  if ([name isEqualToString:@"snapbar"]) {
    958     item.title = iSnapBar.hidden ? @"Show Snap Toolbar" :
     958    item.title = [iSnapBar isHidden] ? @"Show Snap Toolbar" :
    959959      @"Hide Snap Toolbar";
    960960    return YES;
    961961  }
    962962  IpeAction *s = findAction(name);
    963963  if (s) {
    964964    if ([name isEqualToString:@"toggle_notes"])
    965       s.state = (iNotesPanel && iNotesPanel.visible);
     965      s.state = (iNotesPanel && [iNotesPanel isVisible]);
    966966    else if ([name isEqualToString:@"toggle_bookmarks"])
    967       s.state = (iBookmarksPanel && iBookmarksPanel.visible);
     967      s.state = (iBookmarksPanel && [iBookmarksPanel isVisible]);
    968968    [item setState:(s.state ? NSOnState : NSOffState)];
    969969    return actionsEnabled() || s.alwaysOn;
    970970  }
    void AppUi::fillDynamicSubmenu(NSMenuItem *item) 
    10241024
    10251025void AppUi::toggleSnapbarShown()
    10261026{
    1027   iSnapBar.hidden = !iSnapBar.hidden;
    1028   if (iSnapBar.hidden) {
     1027  iSnapBar.hidden = ![iSnapBar isHidden];
     1028  if ([iSnapBar isHidden]) {
    10291029    activateConstraint(iViewToSnapBar, NO);
    10301030    activateConstraint(iViewToTop, YES);
    10311031  } else {
  • ipe/appui_cocoa.h

    diff --git ipe/appui_cocoa.h ipe/appui_cocoa.h
    index 4305b86..fa25320 100644
    private: 
    112112  virtual void setButtonColor(int sel, Color color) override;
    113113
    114114private:
    115   NSMutableDictionary <NSString *, IpeAction *> *iActions;
     115  NSMutableDictionary *iActions; // <NSString *, IpeAction *>
    116116  bool iActionsEnabled;
    117117  bool iInUiUpdate;
    118118  NSWindow *iWindow;
  • ipe/controls_cocoa.cpp

    diff --git ipe/controls_cocoa.cpp ipe/controls_cocoa.cpp
    index d6d079c..1d1c582 100644
    extern CGContextRef ipeGetCGContext(); 
    229229
    230230@implementation IpeLayerView {
    231231  NSTableView *iTV;
    232   NSMutableArray <IpeLayerItem *> *iLayers;
     232  NSMutableArray *iLayers; // <IpeLayerItem *>
    233233}
    234234
    235235- (instancetype) initWithFrame:(NSRect) rect
    extern CGContextRef ipeGetCGContext(); 
    283283- (void) ipeLayerToggled:(id) sender
    284284{
    285285  int row = [sender tag];
    286   if (iLayers[row].checked)
    287     [self.delegate layerAction:@"selectoff" forLayer:iLayers[row].name];
     286  if (((IpeLayerItem *)iLayers[row]).checked)
     287    [self.delegate layerAction:@"selectoff" forLayer:((IpeLayerItem *)iLayers[row]).name];
    288288  else
    289     [self.delegate layerAction:@"selecton" forLayer:iLayers[row].name];
     289    [self.delegate layerAction:@"selecton" forLayer:((IpeLayerItem *)iLayers[row]).name];
    290290}
    291291
    292292- (void) ipeLayerClicked:(int) row
    293293{
    294   [self.delegate layerAction:@"active" forLayer:iLayers[row].name];
     294  [self.delegate layerAction:@"active" forLayer:((IpeLayerItem *)iLayers[row]).name];
    295295}
    296296
    297297- (void) ipeLayerMenuAt:(NSPoint) p forRow:(int) row
    298298{
    299   [self.delegate layerMenuAt:p forLayer:iLayers[row].name];
     299  [self.delegate layerMenuAt:p forLayer:((IpeLayerItem *)iLayers[row]).name];
    300300}
    301301
    302302- (NSInteger) numberOfRowsInTableView:(NSTableView *) tv
    objectValueForTableColumn:(NSTableColumn *) col 
    309309             row:(NSInteger)row
    310310{
    311311  if ([[col identifier] isEqualToString:@"checks"])
    312     return [NSNumber numberWithBool:iLayers[row].checked];
     312    return [NSNumber numberWithBool:((IpeLayerItem *)iLayers[row]).checked];
    313313  else
    314     return iLayers[row].name;
     314    return ((IpeLayerItem *)iLayers[row]).name;
    315315}
    316316
    317317- (NSView *) tableView:(NSTableView *) tv
    objectValueForTableColumn:(NSTableColumn *) col 
    328328    [result setAction:@selector(ipeLayerToggled:)];
    329329    [result setTarget:self];
    330330    [result setTag:row];
    331     [result setState:iLayers[row].checked];
     331    [result setState:((IpeLayerItem *)iLayers[row]).checked];
    332332    return result;
    333333  } else {
    334334    IpeLayerField *result = [tv makeViewWithIdentifier:@"LayerName" owner:self];
    objectValueForTableColumn:(NSTableColumn *) col 
    349349
    350350@implementation IpeBookmarksView {
    351351  NSTableView *iTV;
    352   NSMutableArray <NSString *> *iBookmarks;
     352  NSMutableArray *iBookmarks; // <NSString *>
    353353}
    354354
    355355- (instancetype) initWithFrame:(NSRect) rect
  • ipe/main_cocoa.cpp

    diff --git ipe/main_cocoa.cpp ipe/main_cocoa.cpp
    index 132eaaa..4e00495 100644
    static void setup_globals(lua_State *L) 
    7272                  IPELIB_VERSION % 100);
    7373  lua_setfield(L, -2, "version");
    7474
    75   NSArray <NSString *> *args = [[NSProcessInfo processInfo] arguments];
     75  NSArray *args = [[NSProcessInfo processInfo] arguments];
    7676  int argc = [args count];
    7777  lua_createtable(L, 0, argc - 1);
    7878  for (int i = 1; i < argc; ++i) {
  • ipe/pagesorter_cocoa.cpp

    diff --git ipe/pagesorter_cocoa.cpp ipe/pagesorter_cocoa.cpp
    index 3cb7500..4cbe980 100644
    extern NSSize thumbnail_size; // in ipeselector_cocoa.cpp 
    131131@interface IpePageSorterDelegate : NSObject <NSWindowDelegate,
    132132                                               NSCollectionViewDelegate>
    133133
    134 @property NSMutableArray <IpeSelectorItem *> *pages;
     134@property NSMutableArray *pages; // <IpeSelectorItem *>
    135135@property (assign) NSCollectionView *cv;
    136136
    137137- (void) ipeAccept;
    int AppUi::pageSorter(lua_State *L, Document *doc, 
    249249  }
    250250
    251251  NSScrollView *scroll =
    252     [[NSScrollView alloc] initWithFrame:panel.contentView.frame];
     252    [[NSScrollView alloc] initWithFrame:[panel.contentView frame]];
    253253  scroll.autoresizingMask = NSViewWidthSizable|NSViewHeightSizable;
    254254  scroll.hasVerticalScroller = YES;
    255255
    int AppUi::pageSorter(lua_State *L, Document *doc, 
    326326    int n = [delegate.pages count];
    327327    lua_createtable(L, n, 0);
    328328    for (int i = 1; i <= n; ++i) {
    329       lua_pushinteger(L, delegate.pages[i-1].index + 1);
     329      lua_pushinteger(L, ((IpeSelectorItem *)delegate.pages[i-1]).index + 1);
    330330      lua_rawseti(L, -2, i);
    331331    }
    332332    return 1;
  • ipecanvas/ipecanvas_cocoa.cpp

    diff --git ipecanvas/ipecanvas_cocoa.cpp ipecanvas/ipecanvas_cocoa.cpp
    index 2af4ca7..966a12b 100644
    static CGContextRef gc_graphics_port() 
    4545
    4646static CGContextRef gc_cgcontext()
    4747{
     48  #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
    4849  return [[NSGraphicsContext currentContext] CGContext];
     50  #else
     51  return nil;
     52  #endif
    4953}
    5054
    5155CGContextRef ipeGetCGContext()
    5256{
     57  #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
    5358  if ([NSGraphicsContext instancesRespondToSelector:@selector(CGContext)])
    54     return gc_cgcontext();
    55   else
    56     return gc_graphics_port();
     59    return [[NSGraphicsContext currentContext] CGContext];
     60  #endif
     61  return (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort];
    5762}
    5863
    5964// --------------------------------------------------------------------
    Canvas::Canvas(IpeCanvasView *view) 
    6368  iView = view;
    6469  iLayer = NULL;
    6570
     71  iGCGetter = gc_graphics_port;
     72  #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
    6673  if ([NSGraphicsContext instancesRespondToSelector:@selector(CGContext)])
    6774    iGCGetter = gc_cgcontext;
    68   else
    69     iGCGetter = gc_graphics_port;
     75  #endif
    7076}
    7177
    7278Canvas::~Canvas()
  • ipecanvas/ipeselector_cocoa.cpp

    diff --git ipecanvas/ipeselector_cocoa.cpp ipecanvas/ipeselector_cocoa.cpp
    index 9a5129b..7b2891d 100644
    int CanvasBase::selectPageOrView(Document *doc, int page, int startIndex, 
    241241  }
    242242
    243243  NSScrollView *scroll =
    244     [[NSScrollView alloc] initWithFrame:panel.contentView.frame];
     244    [[NSScrollView alloc] initWithFrame:[panel.contentView frame]];
    245245  scroll.autoresizingMask = NSViewWidthSizable|NSViewHeightSizable;
    246246  scroll.hasVerticalScroller = YES;
    247247  panel.contentView = scroll;
  • ipeui/ipeui_cocoa.cpp

    diff --git ipeui/ipeui_cocoa.cpp ipeui/ipeui_cocoa.cpp
    index 4ac1035..7918ca6 100644
    inline NSString *C2N(const char *s) {return [NSString stringWithUTF8String:s];} 
    5252
    5353CGContextRef ipeGetCGContext()
    5454{
     55  #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
    5556  if ([NSGraphicsContext instancesRespondToSelector:@selector(CGContext)])
    5657    return [[NSGraphicsContext currentContext] CGContext];
    57   else
    58     return (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort];
     58  #endif
     59  return (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort];
    5960}
    6061
    6162// --------------------------------------------------------------------
    void addToLayout(NSView *view, NSView *subview) 
    8384
    8485id layoutGuide(NSView *owner)
    8586{
     87  #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101100
    8688  if ([owner respondsToSelector:@selector(addLayoutGuide:)]) {
    8789#pragma clang diagnostic push
    8890#pragma clang diagnostic ignored "-Wdeprecated-declarations"
    id layoutGuide(NSView *owner) 
    9092    [owner addLayoutGuide:g];
    9193#pragma clang diagnostic pop
    9294    return g;
    93   } else {
    94     NSView *g = [[NSView alloc] initWithFrame:NSZeroRect];
    95     addToLayout(owner, g);
    96     return g;
    9795  }
     96  #endif
     97  NSView *g = [[NSView alloc] initWithFrame:NSZeroRect];
     98  addToLayout(owner, g);
     99  return g;
    98100}
    99101
    100102static NSLayoutAttribute layoutAttribute(char ch)
    static NSView *owner(id a) 
    138140{
    139141  if ([a respondsToSelector:@selector(superview)])
    140142    return [a superview];
     143  #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101100
    141144  if ([a respondsToSelector:@selector(owningView)])
    142145    return [a owningView];  // is a layout guide
     146  #endif
    143147  return nil;
    144148}
    145149
    146150void activateConstraint(NSLayoutConstraint *c, BOOL active)
    147151{
     152  #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
    148153  if ([c respondsToSelector:@selector(setActive:)]) {
    149154#pragma clang diagnostic push
    150155#pragma clang diagnostic ignored "-Wdeprecated-declarations"
    151156    c.active = active;
     157    return;
    152158#pragma clang diagnostic pop
    153   } else {
    154     // need to figure out lowest common ancestor
    155     id a = c.firstItem;
    156     id b = c.secondItem;
    157     NSView *lca = nil;
    158     NSView *ao = owner(a);
    159     NSView *bo = owner(b);
    160     if (b == nil)
    161       lca = a;
    162     else if (ao == b)
    163       lca = b;
    164     else if (bo == a)
    165       lca = a;
    166     else {
    167       assert(ao == bo);
    168       lca = ao;
    169     }
    170     if (active)
    171       [lca addConstraint:c];
    172     else
    173       [lca removeConstraint:c];
    174159  }
     160  #endif
     161  // need to figure out lowest common ancestor
     162  id a = c.firstItem;
     163  id b = c.secondItem;
     164  NSView *lca = nil;
     165  NSView *ao = owner(a);
     166  NSView *bo = owner(b);
     167  if (b == nil)
     168    lca = a;
     169  else if (ao == b)
     170    lca = b;
     171  else if (bo == a)
     172    lca = a;
     173  else {
     174    assert(ao == bo);
     175    lca = ao;
     176  }
     177  if (active)
     178    [lca addConstraint:c];
     179  else
     180    [lca removeConstraint:c];
    175181}
    176182
    177183NSLayoutConstraint *layout(id a, id b, const char *rel, double gap,
    private: 
    253259private:
    254260  NSPanel *iPanel;
    255261  IpeDialogDelegate *iDelegate;
    256   NSMutableArray <NSView *> *iViews;
     262  NSMutableArray *iViews; // <NSView *>
    257263};
    258264
    259265// --------------------------------------------------------------------