Esempio n. 1
0
static void
select_release(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
   SelectRegionCommand_t *command = (SelectRegionCommand_t*) data;
   Object_t *obj = command->obj;
   Rectangle_t *rectangle = ObjectToRectangle(obj);
   gpointer id;
   gint count;

   g_signal_handlers_disconnect_by_func(widget,
                                        select_motion, data);
   g_signal_handlers_disconnect_by_func(widget,
                                        select_release, data);

   object_normalize(obj);

   id = object_list_add_select_cb(command->list, select_one_object, command);
   count = object_list_select_region(command->list, rectangle->x, rectangle->y,
                                     rectangle->width, rectangle->height);
   object_list_remove_select_cb(command->list, id);

   if (count) {
      command_list_add(&command->parent);
   } else {                     /* Nothing selected */
      if (command->unselect_command->sub_commands)
         command_list_add(&command->parent);
   }
   preview_unset_tmp_obj (command->obj);

   preview_redraw ();
}
Esempio n. 2
0
static void
handle_drop(GtkWidget *widget, GdkDragContext *context, gint x, gint y,
            GtkSelectionData *data, guint info, guint time)
{
  gboolean success = FALSE;

  if (gtk_selection_data_get_length (data) >= 0 &&
      gtk_selection_data_get_format (data) == 8)
    {
      ObjectList_t *list = get_shapes();
      Object_t *obj;

      x = get_real_coord(x);
      y = get_real_coord(y);
      obj = object_list_find(list, x, y);
      if (obj && !obj->locked)
        {
          command_list_add(edit_object_command_new(obj));
          object_set_url(obj, (const gchar *) gtk_selection_data_get_data (data));
          object_emit_update_signal(obj);
          success = TRUE;
        }
    }
  gtk_drag_finish(context, success, FALSE, time);
}
Esempio n. 3
0
static void
handle_drop(GtkWidget *widget, GdkDragContext *context, gint x, gint y,
	    GtkSelectionData *data, guint info, guint time)
{
  gboolean success = FALSE;
  if (data->length >= 0 && data->format == 8) {
    GtkTreePath *path;
    if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget), x, y,
				       &path, NULL, NULL, NULL)) {
      GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
      GtkTreeIter iter;

      if (gtk_tree_model_get_iter (model, &iter, path)) {
	Object_t *obj = selection_get_object (model, &iter);
	if (!obj->locked) {
	  command_list_add(edit_object_command_new (obj));
	  object_set_url (obj, (const gchar *) data->data);
	  object_emit_update_signal (obj);
	  success = TRUE;
	}
      }
      gtk_tree_path_free (path);
    }
  }
  gtk_drag_finish(context, success, FALSE, time);
}