Beispiel #1
0
void
on_listing_save_clicked (GtkButton * button, gpointer user_data)
{
  gchar *ltext;
  //i_save ();
  /* FIXME : the save dialog is getting hung in listing window! */
  g_assert (edit);
  ltext = gui_editor_get_text (edit);
  file_op_listing_save (ltext);
}
Beispiel #2
0
static gboolean
ori_save (gchar * fn, gboolean replace)
{
  gchar *text;
  FILE *fp;
  char *nullstr = "NULLSTRING";
  int ret;

  if (!fn)
	fn = nullstr;

  if (replace)
	{
	  fp = fopen (fn, "r");
	  if (fp != NULL)
		{
		  GtkWidget *dialog;
		  GtkResponseType response;
		  dialog = gtk_message_dialog_new (GTK_WINDOW(app->window_main),
						   GTK_DIALOG_DESTROY_WITH_PARENT,
						   GTK_MESSAGE_QUESTION, 
						   GTK_BUTTONS_YES_NO,
						   _("File already exists; overwrite it?"));
		  response = gtk_dialog_run (GTK_DIALOG (dialog));
		  gtk_widget_destroy (dialog);

		  if (response == GTK_RESPONSE_NO)
			return FALSE;

		  fclose (fp);
		}
	}
  text = gui_editor_get_text (app->editor);
  fp = fopen (fn, "w");
  if (fp == NULL)
	{
	  gchar errmsg[MAX_ERR_MSG_SIZE + 1];
	  g_snprintf (errmsg, MAX_ERR_MSG_SIZE, _("Failed to save <%s>"),
				  fn);
	  gui_app_show_msg (GTK_MESSAGE_ERROR, errmsg);
	  return TRUE;
	}
  // return value stored just to avoid compiler warnings.
  ret = fwrite (text, 1, strlen (text), fp);
  gtk_text_buffer_set_modified ((GtkTextBuffer *)app->editor->buffer, FALSE);
  
  /* debug */
  fclose (fp);

  g_free (text);
  if (replace)
	_set_file_name (fn);

  return TRUE;
}
Beispiel #3
0
static gboolean
ori_save (gchar * fn, gboolean replace)
{
  gchar *text;
  GFile *fp;
  GFileOutputStream *file_out;
  GError *error = NULL;
  char *nullstr = "NULLSTRING";
  gssize bytes;

  if (!fn)
	fn = nullstr;

  fp = g_file_new_for_uri (fn);

  file_out = g_file_create (fp, G_FILE_CREATE_NONE, NULL, &error);
  if ((file_out == NULL) && (error->code == G_IO_ERROR_EXISTS))
	{
	  if (replace)
		{
		  g_error_free (error);
		/* replace file */
		  file_out = g_file_replace (fp, NULL, TRUE, G_FILE_CREATE_NONE, NULL, &error);
		}
	}
  text = gui_editor_get_text (app->editor);
  if (file_out == NULL)
	{
	  gchar errmsg[MAX_ERR_MSG_SIZE + 1];
	  g_snprintf (errmsg, MAX_ERR_MSG_SIZE, _("Failed to save <%s>"),
				  fn);
	  gui_app_show_msg (GTK_MESSAGE_ERROR, errmsg);
	  return TRUE;
	}
  bytes = g_output_stream_write (G_OUTPUT_STREAM (file_out), text, strlen (text), NULL, NULL);
  gtk_text_buffer_set_modified ((GtkTextBuffer *)app->editor->buffer, FALSE);
  
  /* debug */
  g_output_stream_close (G_OUTPUT_STREAM (file_out), NULL, NULL);

  g_free (text);
  if (replace)
	_set_file_name (fn);

  /*g_error_free (error);*/
  return TRUE;
}
Beispiel #4
0
void
on_assemble1_activate (GtkMenuItem * menuitem, gpointer user_data)
{
  /* assemble file */
  gchar *a_text;

  /* la */
  validate_start_addr ();

  /* get text */
  a_text = gui_editor_get_text (app->editor);

  asm_error = b_assemble (a_text, start_addr);
  if (asm_error == FALSE)
	gui_app_show_msg (GTK_MESSAGE_WARNING,
					  _("Program has errors. Check the Message pane."));

  g_free (a_text);

  //disp_list( b_get_src() );
}