コード例 #1
0
void save_file_as_ok(GtkFileChooser *file_selection_box)
{
    gchar *uri=gtk_file_chooser_get_uri(file_selection_box);
    // Set the filename of the current document to be that
    document_set_GFile(document_manager_get_current_document(main_window.docmg), gtk_file_chooser_get_file(file_selection_box));
    document_set_untitled(document_manager_get_current_document(main_window.docmg), FALSE);
    gchar *basename = filename_get_basename(uri);
    g_free(uri);
    document_set_shortfilename(document_manager_get_current_document(main_window.docmg), basename);

    // Call Save method to actually save it now it has a filename
    on_save1_activate(NULL);
}
コード例 #2
0
void rename_file(GString *newfilename)
{
    gchar *basename=filename_get_basename(newfilename->str);
    gchar *filename = document_get_filename(document_manager_get_current_document(main_window.docmg));
    if (filename_rename(filename, basename)) {
        // Set the filename of the current document to be that
        document_set_GFile(document_manager_get_current_document(main_window.docmg), get_gfile_from_filename(newfilename->str));
        document_set_untitled(document_manager_get_current_document(main_window.docmg), FALSE);
        document_set_shortfilename(document_manager_get_current_document(main_window.docmg), basename);
        g_free(basename);
        // save as new filename
        on_save1_activate(NULL);
    }
    g_free(filename);
}
コード例 #3
0
ファイル: gconf.c プロジェクト: OpenHMR/Open-HMR600
gboolean on_window1_delete_event(GtkWidget * widget, GdkEvent * event,
				 gpointer user_data)
{
	GtkWidget *dialog, *label;
	gint result;

	if (config_changed == FALSE)
		return FALSE;

	dialog = gtk_dialog_new_with_buttons(_("Warning !"),
					     GTK_WINDOW(main_wnd),
					     (GtkDialogFlags)
					     (GTK_DIALOG_MODAL |
					      GTK_DIALOG_DESTROY_WITH_PARENT),
					     GTK_STOCK_OK,
					     GTK_RESPONSE_YES,
					     GTK_STOCK_NO,
					     GTK_RESPONSE_NO,
					     GTK_STOCK_CANCEL,
					     GTK_RESPONSE_CANCEL, NULL);
	gtk_dialog_set_default_response(GTK_DIALOG(dialog),
					GTK_RESPONSE_CANCEL);

	label = gtk_label_new(_("\nSave configuration ?\n"));
	gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label);
	gtk_widget_show(label);

	result = gtk_dialog_run(GTK_DIALOG(dialog));
	switch (result) {
	case GTK_RESPONSE_YES:
		on_save1_activate(NULL, NULL);
		return FALSE;
	case GTK_RESPONSE_NO:
		return FALSE;
	case GTK_RESPONSE_CANCEL:
	case GTK_RESPONSE_DELETE_EVENT:
	default:
		gtk_widget_destroy(dialog);
		return TRUE;
	}

	return FALSE;
}
コード例 #4
0
ファイル: document_manager.c プロジェクト: gphpedit/gphpedit
gboolean document_manager_try_save_page(DocumentManager *docmg, Document *document, gboolean close_if_can)
{
  gphpedit_debug(DEBUG_DOC_MANAGER);
  if (!docmg) return TRUE;
  gint ret;
  const gchar *short_filename;
  g_object_get(document, "short_filename", &short_filename, NULL);

  GtkWidget *confirm_dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW(main_window.window),
    GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE,
      /*TRANSLATORS: this is a pango markup string you must keep the format tags. */
    _("<b>The file '%s' has not been saved since your last changes.</b>\n<small>Are you sure you want to close it and lose these changes?</small>"),
     short_filename);

  gtk_dialog_add_button (GTK_DIALOG(confirm_dialog),_("Close and _lose changes"), 0);
  gboolean untitled;
  g_object_get(document, "untitled", &untitled, NULL);
  if (untitled){
    gtk_dialog_add_button (GTK_DIALOG(confirm_dialog), GTK_STOCK_SAVE_AS, 1);
  } else {
    gtk_dialog_add_button (GTK_DIALOG(confirm_dialog), GTK_STOCK_SAVE, 1);
  }
  gtk_dialog_add_button (GTK_DIALOG(confirm_dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
  gtk_dialog_set_default_response (GTK_DIALOG(confirm_dialog), 1); /* set save as default */

  ret = gtk_dialog_run (GTK_DIALOG (confirm_dialog));
  gtk_widget_destroy(confirm_dialog);
  switch (ret) {
    case 0:
      if (close_if_can) {
          document_manager_close_page(docmg, document);
      }
      return TRUE;
    case 1:
      on_save1_activate(NULL);
      // If chose neither of these, dialog either cancelled or closed. Do nothing.
  }
  return FALSE;
}
コード例 #5
0
ファイル: gconf.c プロジェクト: OpenHMR/Open-HMR600
void on_save_pressed(GtkButton * button, gpointer user_data)
{
	on_save1_activate(NULL, user_data);
}