~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to plug-ins/imagemap/imap_polygon.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: james.westby@ubuntu.com-20070502163303-6wchheivjxgjtlna
Tags: upstream-2.3.16
ImportĀ upstreamĀ versionĀ 2.3.16

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 *
4
4
 * Generates clickable image maps.
5
5
 *
6
 
 * Copyright (C) 1998-2004 Maurits Rijk  m.rijk@chello.nl
 
6
 * Copyright (C) 1998-2005 Maurits Rijk  m.rijk@chello.nl
7
7
 *
8
8
 * This program is free software; you can redistribute it and/or modify
9
9
 * it under the terms of the GNU General Public License as published by
31
31
#include "imap_commands.h"
32
32
#include "imap_main.h"
33
33
#include "imap_misc.h"
 
34
#include "imap_menu.h"
34
35
#include "imap_object_popup.h"
35
36
#include "imap_polygon.h"
36
37
#include "imap_stock.h"
653
654
   output(param, " %d,%d", first->x, first->y);
654
655
}
655
656
 
 
657
static Object_t *_current_obj;
656
658
static gboolean _insert_edge;
657
659
static gint _insert_x;
658
660
static gint _insert_y;
659
661
 
660
 
static void
661
 
polygon_insert_point(GtkWidget *widget, gpointer data)
 
662
void
 
663
polygon_insert_point(void)
662
664
{
663
 
   Command_t *command = insert_point_command_new(get_popup_object(), _insert_x,
664
 
                                                 _insert_y, _insert_edge);
665
 
   command_execute(command);
 
665
  Command_t *command = insert_point_command_new (_current_obj, _insert_x,
 
666
                                                 _insert_y, _insert_edge);
 
667
  command_execute (command);
666
668
}
667
669
 
668
 
static void
669
 
polygon_delete_point(GtkWidget *widget, gpointer data)
 
670
void
 
671
polygon_delete_point(void)
670
672
{
671
 
   Command_t *command = delete_point_command_new(get_popup_object(),
672
 
                                                 _sash_point);
673
 
   command_execute(command);
 
673
  Command_t *command = delete_point_command_new(_current_obj, _sash_point);
 
674
  command_execute (command);
674
675
}
675
676
 
676
677
static gboolean
711
712
}
712
713
 
713
714
static void
 
715
polygon_handle_popup (GdkEventButton *event, gboolean near_sash,
 
716
                      gboolean near_edge)
 
717
{
 
718
  GtkWidget *popup = menu_get_widget ("/PolygonPopupMenu");
 
719
  GtkWidget *delete = menu_get_widget ("/PolygonPopupMenu/DeletePoint");
 
720
  GtkWidget *insert = menu_get_widget ("/PolygonPopupMenu/InsertPoint");
 
721
 
 
722
  gtk_widget_set_sensitive (delete, near_sash);
 
723
  gtk_widget_set_sensitive (insert, near_edge);
 
724
 
 
725
  gtk_menu_popup(GTK_MENU(popup), NULL, NULL, NULL, NULL,
 
726
                 event->button, event->time);
 
727
}
 
728
 
 
729
static void
714
730
polygon_do_popup(Object_t *obj, GdkEventButton *event)
715
731
{
716
 
   gint x = get_real_coord((gint) event->x);
717
 
   gint y = get_real_coord((gint) event->y);
718
 
 
719
 
   if (polygon_near_sash(obj, x, y)) {
720
 
      static ObjectPopup_t *delete_popup;
721
 
      if (!delete_popup) {
722
 
         delete_popup = make_object_popup();
723
 
         object_popup_prepend_menu(delete_popup, _("Delete Point"),
724
 
                                   polygon_delete_point, delete_popup);
725
 
      }
726
 
      object_handle_popup(delete_popup, obj, event);
727
 
   } else {
728
 
      _insert_edge = polygon_near_edge(obj, x, y);
729
 
      if (_insert_edge) {
730
 
         static ObjectPopup_t *insert_popup;
731
 
 
732
 
         _insert_x = x;
733
 
         _insert_y = y;
734
 
 
735
 
         if (!insert_popup) {
736
 
            insert_popup = make_object_popup();
737
 
            object_popup_prepend_menu(insert_popup, _("Insert Point"),
738
 
                                      polygon_insert_point, insert_popup);
739
 
         }
740
 
         object_handle_popup(insert_popup, obj, event);
741
 
      } else {
742
 
         object_do_popup(obj, event);
743
 
      }
744
 
   }
 
732
  gint x = get_real_coord ((gint) event->x);
 
733
  gint y = get_real_coord ((gint) event->y);
 
734
 
 
735
  _current_obj = obj;
 
736
 
 
737
  if (polygon_near_sash (obj, x, y))
 
738
    {
 
739
      polygon_handle_popup (event, TRUE, FALSE);
 
740
    }
 
741
  else
 
742
    {
 
743
      _insert_edge = polygon_near_edge (obj, x, y);
 
744
      if (_insert_edge)
 
745
        {
 
746
          _insert_x = x;
 
747
           _insert_y = y;
 
748
 
 
749
           polygon_handle_popup (event, FALSE, TRUE);
 
750
        }
 
751
      else {
 
752
        object_do_popup (obj, event);
 
753
      }
 
754
    }
745
755
}
746
756
 
747
757
static const gchar*