示例#1
0
static gint
properties_apply(GtkWidget *canvas, gpointer data)
{
  ObjectChange *obj_change = NULL;

  if ( (current_obj == NULL) || (current_dia == NULL) )
    return 0;
  
  object_add_updates(current_obj, current_dia);
  obj_change = current_obj->ops->apply_properties(current_obj);
  object_add_updates(current_obj, current_dia);

  diagram_update_connections_object(current_dia, current_obj, TRUE);
  
  if (obj_change != NULL) {
    undo_object_change(current_dia, current_obj, obj_change);
  }
  
  diagram_modified(current_dia);

  diagram_update_extents(current_dia);
    
  if (obj_change != NULL) {
    undo_set_transactionpoint(current_dia->undo);
  }  else {
    message_warning(_("This object doesn't support Undo/Redo.\n"
		      "Undo information erased."));
    undo_clear(current_dia->undo);
  }

  diagram_flush(current_dia);

  return 0;
}
示例#2
0
文件: undo.c 项目: krattai/monoflow
void
undo_destroy(UndoStack *stack)
{
  undo_clear(stack);
  g_free(stack->current_change); /* Free first transaction point. */
  g_free(stack);
}
示例#3
0
static gint
properties_respond(GtkWidget *widget,
                   gint       response_id,
                   gpointer   data)
{
  ObjectChange *obj_change = NULL;
  gboolean set_tp = TRUE;
  GList *tmp;

  if (   response_id == GTK_RESPONSE_APPLY
      || response_id == GTK_RESPONSE_OK) {
    if ((current_objects != NULL) && (current_dia != NULL)) {
      object_add_updates_list(current_objects, current_dia);

      for (tmp = current_objects; tmp != NULL; tmp = tmp->next) {
	DiaObject *current_obj = (DiaObject*)tmp->data;
	obj_change = current_obj->ops->apply_properties_from_dialog(current_obj, object_part);
	object_add_updates(current_obj, current_dia);
	diagram_update_connections_object(current_dia, current_obj, TRUE);

	if (obj_change != NULL) {
	  undo_object_change(current_dia, current_obj, obj_change);
	  set_tp = set_tp && TRUE;
	} else
	  set_tp = FALSE;

	diagram_object_modified(current_dia, current_obj);
      }

      diagram_modified(current_dia);
      diagram_update_extents(current_dia);

      if (set_tp) {
	undo_set_transactionpoint(current_dia->undo);
      }  else {
	message_warning(_("This object doesn't support Undo/Redo.\n"
  			"Undo information erased."));
	undo_clear(current_dia->undo);
      }

      diagram_flush(current_dia);
    }
  }

  if (response_id != GTK_RESPONSE_APPLY) {
#ifdef G_OS_WIN32
    /* on windows we are not hiding the dialog, because shrinking when hidden does
     * not work (the dialog shows up with the same size as before, bug #333751) */
    gtk_widget_destroy (dialog);
#else
    properties_dialog_hide();
#endif
  }

  return 0;
}
示例#4
0
文件: undo.c 项目: krattai/monoflow
/** Remove items from the undo stack until we hit an undo item of a given
 *  type (indicated by its apply function).  Beware that the items are not
 *  just reverted, but totally removed.  This also takes with it all the 
 *  changes above current_change.
 *
 * @param stack The undo stack to remove items from.
 * @param type Indicator of undo type to remove: An apply function.
 * @returns The Change object that stopped the search, if any was found,
 * or NULL otherwise.  In the latter case, the undo stack will be empty.
 */
Change*
undo_remove_to(UndoStack *stack, UndoApplyFunc *type)
{
  Change *current_change = stack->current_change;
  if (current_change == NULL) 
    return NULL;
  while (current_change && current_change->apply != *type) {
    current_change = current_change->prev;
  }
  if (current_change != NULL) {
    stack->current_change = current_change;
    undo_remove_redo_info(stack);
    return current_change;
  } else {
    undo_clear(stack);
    return NULL;
  }
}
示例#5
0
文件: file.c 项目: smaclennan/zedit
void Zrevert_file(void)
{
	unsigned long offset;

	if (!Curbuff->fname) {
		tbell();
		return;
	}

	if (Bbuff->bmodf && ask("File modifed. Ok to loose changes?") != YES)
		return;

	/* Lose the undo history */
	undo_clear(Curbuff->buff);

	offset = blocation(Bbuff);
	zreadfile(Curbuff->fname);
	boffset(Bbuff, offset);
	uncomment(Curbuff);
}
示例#6
0
文件: app_procs.c 项目: UIKit0/dia
gboolean
app_exit(void)
{
  GList *list;
  GSList *slist;

  /*
   * The following "solves" a crash related to a second call of app_exit,
   * after gtk_main_quit was called. It may be a win32 gtk-1.3.x bug only
   * but the check shouldn't hurt on *ix either.          --hb
   */
  static gboolean app_exit_once = FALSE;

  if (app_exit_once) {
    g_error(_("This shouldn't happen.  Please file a bug report at bugzilla.gnome.org\n"
	      "describing how you caused this message to appear.\n"));
    return FALSE;
  }

  if (diagram_modified_exists()) {
    if (is_integrated_ui ())
    {
      GtkWidget                *dialog;
      int                       result;
      exit_dialog_item_array_t *items  = NULL;
      GList *                   list; 
      Diagram *                 diagram;
      
      dialog = exit_dialog_make (GTK_WINDOW (interface_get_toolbox_shell ()), 
                                _("Exiting Dia"));

      list = dia_open_diagrams();
      while (list)
      {
        diagram = list->data;

        if (diagram_is_modified (diagram))
        {
          const gchar * name = diagram_get_name (diagram);
          const gchar * path = diagram->filename;
          exit_dialog_add_item (dialog, name, path, diagram);
        }

        list = g_list_next (list);
      }

      result = exit_dialog_run (dialog, &items);
  
      gtk_widget_destroy (dialog);

      if (result == EXIT_DIALOG_EXIT_CANCEL)
      {
        return FALSE;
      }
      else if (result == EXIT_DIALOG_EXIT_SAVE_SELECTED)
      {
	    DiaContext *ctx = dia_context_new(_("Save"));
        int i;
        for (i = 0 ; i < items->array_size ; i++) {
	  gchar *filename;

	  diagram  = items->array[i].data;
	  filename = g_filename_from_utf8 (diagram->filename, -1, NULL, NULL, NULL);
	  diagram_update_extents (diagram);
	  dia_context_set_filename (ctx, filename);
	  if (!diagram_save (diagram, filename, ctx)) {
	    exit_dialog_free_items (items);
	    dia_context_release (ctx);
	    return FALSE;
	  } else {
	    dia_context_reset (ctx);
	  }
	  g_free (filename);
	}
	dia_context_release (ctx);
	exit_dialog_free_items (items);
      } 
      else if (result == EXIT_DIALOG_EXIT_NO_SAVE) 
      {
        list = dia_open_diagrams();
        while (list) {
          diagram = list->data;

	  /* slight hack: don't ask again */
          diagram_set_modified (diagram, FALSE);
	  undo_clear(diagram->undo);
          list = g_list_next (list);
	}
      }
    }
    else
    {
    GtkWidget *dialog;
    GtkWidget *button;
    dialog = gtk_message_dialog_new(
	       NULL, GTK_DIALOG_MODAL,
               GTK_MESSAGE_QUESTION,
               GTK_BUTTONS_NONE, /* no standard buttons */
	       _("Quitting without saving modified diagrams"));
    gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
		 _("Modified diagrams exist. "
		 "Are you sure you want to quit Dia "
 		 "without saving them?"));

    gtk_window_set_title (GTK_WINDOW(dialog), _("Quit Dia"));
  
    button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
    gtk_dialog_add_action_widget (GTK_DIALOG(dialog), button, GTK_RESPONSE_CANCEL);
#if GTK_CHECK_VERSION(2,18,0)
    gtk_widget_set_can_default (GTK_WIDGET (button), TRUE);
#else
    GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
#endif
    gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL);

    button = gtk_button_new_from_stock (GTK_STOCK_QUIT);
    gtk_dialog_add_action_widget (GTK_DIALOG(dialog), button, GTK_RESPONSE_OK);

    gtk_widget_show_all (dialog);

    if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_OK) {
      gtk_widget_destroy(dialog);
      return FALSE;
    }
    gtk_widget_destroy(dialog);
    }
  }
  prefs_save();

  persistence_save();

  dynobj_refresh_finish();

  {
    DiaContext *ctx = dia_context_new (_("Exit"));
    dia_object_defaults_save (NULL, ctx);
    dia_context_release (ctx);
  }
  /* Free loads of stuff (toolbox) */

  list = dia_open_diagrams();
  while (list!=NULL) {
    Diagram *dia = (Diagram *)list->data;
    list = g_list_next(list);

    slist = dia->displays;
    while (slist!=NULL) {
      DDisplay *ddisp = (DDisplay *)slist->data;
      slist = g_slist_next(slist);

      gtk_widget_destroy(ddisp->shell);
    }
    /* The diagram is freed when the last display is destroyed */
  }
  
  /* save pluginrc */
  if (dia_is_interactive)
    dia_pluginrc_write();

  gtk_main_quit();

  /* This printf seems to prevent a race condition with unrefs. */
  /* Yuck.  -Lars */
  /* Trying to live without it. -Lars 10/8/07*/
  /* g_print(_("Thank you for using Dia.\n")); */
  app_exit_once = TRUE;

  return TRUE;
}
示例#7
0
OSStatus tool_wind_event_callback(EventHandlerCallRef eventhandler,EventRef event,void *userdata)
{
	int				i,k;
	ControlRef		ctrl;

	GetEventParameter(event,kEventParamDirectObject,typeControlRef,NULL,sizeof(ControlRef),NULL,&ctrl);
	
		// group combo
		
	if (ctrl==group_combo) {
		k=GetControl32BitValue(ctrl);
		
			// no group
			
		if (k==1) {
			group_set(-1);
			return(noErr);
		}
		
			// set a group
			
		group_set(k-3);
		return(noErr);
	}
		
		// buttons
		
	k=-1;
	for ((i=0);(i!=maxtool);i++) {
		if (ctrl==tool_ctrl[i]) {
			k=i;
			break;
		}
	}
	
	if (k!=-1) undo_clear();
	
	switch (k) {
		case 0:
			vertex_mode=vm_none;
            SetControlValue(tool_ctrl[0],1);
            SetControlValue(tool_ctrl[1],0);
            SetControlValue(tool_ctrl[2],0);
			break;
		case 1:
			vertex_mode=vm_lock;
            SetControlValue(tool_ctrl[0],0);
            SetControlValue(tool_ctrl[1],1);
            SetControlValue(tool_ctrl[2],0);
			break;
		case 2:
			vertex_mode=vm_snap;
            SetControlValue(tool_ctrl[0],0);
            SetControlValue(tool_ctrl[1],0);
            SetControlValue(tool_ctrl[2],1);
			break;
		case 3:
			dp_primitive=!dp_primitive;
			break;
		case 4:
			dp_auto_texture=!dp_auto_texture;
			break;
		case 5:
			SetControlValue(tool_ctrl[k],0);			// pop back up
			main_wind_rotate_view();
			main_wind_draw();
			break;
		case 6:
            select_clear();
			dp_wall=!dp_wall;
			break;
		case 7:
            select_clear();
			dp_floor=!dp_floor;
			break;
		case 8:
            select_clear();
			dp_ceiling=!dp_ceiling;
			break;
		case 9:
            select_clear();
			dp_liquid=!dp_liquid;
			break;
		case 10:
            select_clear();
			dp_ambient=!dp_ambient;
			break;
		case 11:
            select_clear();
			dp_object=!dp_object;
			break;
		case 12:
            select_clear();
			dp_lightsoundparticle=!dp_lightsoundparticle;
			break;
		case 13:
            select_clear();
            dp_node=!dp_node;
			break;
		case 14:
			dp_textured=!dp_textured;
			break;
		case 15:
            dp_y_hide=!dp_y_hide;
			break;
		case 16:
			SetControlValue(tool_ctrl[k],0);			// pop back up
			segment_sub_point();
			break;
		case 17:
			SetControlValue(tool_ctrl[k],0);			// pop back up
			segment_add_point();
			break;
		case 18:
			SetControlValue(tool_ctrl[k],0);			// pop back up
			segment_tesselate();
			break;
		case 19:
			SetControlValue(tool_ctrl[k],0);			// pop back up
			launch_map_script_editor();
			break;
		case 20:
			SetControlValue(tool_ctrl[k],0);			// pop back up
			launch_engine();
			break;
			
	}
    
    menu_fix_enable();
    
    main_wind_draw();
			
	return(noErr);
}