Beispiel #1
0
static void
directory_chooser_show(enum dir_choice dir_choice, const char *title,
	const char *current_directory)
{
	GtkWidget *widget;

	if (directory_chooser) {
		gtk_widget_destroy(directory_chooser);
		directory_chooser = NULL;
	}

	widget = gtk_file_chooser_dialog_new(title,
				GTK_WINDOW(gui_main_window()),
				GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
				GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
				GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
				(void *) 0);
	g_return_if_fail(NULL != widget);
	directory_chooser = widget;

	gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(widget), TRUE);
	gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(widget),
		gtk_file_filter_new());	/* Display only directories */

	if (NULL != current_directory) {
		gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(widget),
			current_directory);
	}

	gui_signal_connect(widget, "destroy-event",
		on_directory_chooser_destroy_event, NULL);
	gui_signal_connect(widget, "delete-event",
		on_directory_chooser_delete_event, NULL);
	gui_signal_connect(widget, "response",
		on_directory_chooser_response, uint_to_pointer(dir_choice));

	gtk_widget_show(widget);
}
Beispiel #2
0
void
on________s_1_activate                 (GtkMenuItem     *menuitem,
                                        AD         data)
// 儲存檔案  
{
  GtkWidget *dialog;

  dialog = gtk_file_chooser_dialog_new ("Save File",
	 			                                GTK_WINDOW(data->window),
	 			                                GTK_FILE_CHOOSER_ACTION_SAVE,
	 			                                GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
				                                GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
				                                NULL);

  gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
  
  if (0)//user_edited_a_new_document)
  {
    gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), "NEW.txt");//default_folder_for_saving);
    gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), "Untitled document");
  }
  else
    gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dialog), "OLD.txt");//filename_for_existing_document);


  if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
  {
    char *filename;

    filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
    save_to_file (filename, GTK_TEXT_VIEW (data->textview));
    gtk_window_set_title (GTK_WINDOW (data->window), filename);
    g_free (filename);
  }
  
  gtk_widget_destroy (dialog);

}
Beispiel #3
0
EXPORT
void
on_save_history_as_activate (GtkMenuItem *menuitem, gpointer user_data)
{
	GtkWidget *dialog;
	char *log_path, *name, *key;

	dialog = gtk_file_chooser_dialog_new ("Save File", GTK_WINDOW
			(glade_xml_get_widget (warlock_xml, "main_window")),
			GTK_FILE_CHOOSER_ACTION_SAVE,
			GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
			GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
			NULL);
	gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER
			(dialog), TRUE);

	key = preferences_get_key (PREF_LOG_PATH);
	log_path = preferences_get_string (key);
	g_free (key);
	(void)gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog),
			log_path);
	g_free (log_path);

	name = warlock_log_get_name ();
	gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), name);
	g_free (name);

	if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
		char *filename;

		filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER
				(dialog));
		save_log (filename);
		g_free (filename);
	}

	gtk_widget_destroy (dialog);
}
Beispiel #4
0
void load_lastwallpaperfile_cb ( GtkWidget *widget, AnypaperWindow *window )
{
	GtkWidget *dialog;
	GdkColor color;
	gint positionx, positiony, rangex, rangey;

	dialog = gtk_file_chooser_dialog_new ("Open File", GTK_WINDOW(window->priv->window), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
	gtk_file_chooser_set_filename(GTK_FILE_CHOOSER (dialog), lastwallpaperfile);

	if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) 
	{
		block_callback(window);
		g_free(lastwallpaperfile);
		lastwallpaperfile = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
		anypaper_parameters_load(window->parameters, lastwallpaperfile);
		positionx = window->parameters->positionx;
		positiony = window->parameters->positiony;
		anypaper_image_make (window->image, window->parameters);
		rangex = window->parameters->positionx;
		rangey = window->parameters->positiony;
		anypaper_parameters_position_test(window->parameters, rangex, rangey, positionx, positiony);
		anypaper_image_move (window->image, window->parameters);
		gtk_entry_set_text (GTK_ENTRY (window->priv->file_entry), window->parameters->file);
		anypaper_window_set_position_range(window, rangex, rangey);
		gtk_spin_button_set_value(GTK_SPIN_BUTTON (window->priv->spin1), window->parameters->positionx);
		gtk_spin_button_set_value(GTK_SPIN_BUTTON (window->priv->spin2), window->parameters->positiony);
		gtk_spin_button_set_value(GTK_SPIN_BUTTON (window->priv->spin3), window->parameters->width);
		gtk_spin_button_set_value(GTK_SPIN_BUTTON (window->priv->spin4), window->parameters->height);
		gtk_spin_button_set_value(GTK_SPIN_BUTTON (window->priv->spin5), window->parameters->scalex);
		gtk_spin_button_set_value(GTK_SPIN_BUTTON (window->priv->spin6), window->parameters->scaley);
		gtk_combo_box_set_active (GTK_COMBO_BOX (window->priv->combo), window->parameters->style);
		gdk_color_parse (window->parameters->background, &color);
		gtk_color_button_set_color (GTK_COLOR_BUTTON(window->priv->cbutton), &color);
		gtk_image_set_from_pixbuf(GTK_IMAGE(window->priv->preview), window->image->preview);
		unblock_callback(window);
	}
	gtk_widget_destroy (dialog);
}
int
mc_show_file_browser (GtkWidget *widget,
		      MCData    *mc)
{
    if(mc->file_select && GTK_WIDGET_VISIBLE(mc->file_select)) {
        gtk_window_present (GTK_WINDOW (mc->file_select));
        return TRUE;
    }

    /* build file select dialog */
    mc->file_select = gtk_file_chooser_dialog_new((gchar *) _("Start program"),
						  NULL,
						  GTK_FILE_CHOOSER_ACTION_OPEN,
						  GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
						  GTK_STOCK_EXECUTE, GTK_RESPONSE_OK,
						  NULL);

    g_signal_connect(G_OBJECT(mc->file_select),
		     "response",
		     G_CALLBACK(file_browser_response_signal),
		     mc);

    /* set path to last selected path */
    if (browsed_folder)
        gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER(mc->file_select),
			          (gchar *) browsed_folder);

    /* Set as modal */
    gtk_window_set_modal(GTK_WINDOW(mc->file_select),TRUE);

    gtk_window_set_screen (GTK_WINDOW (mc->file_select),
			   gtk_widget_get_screen (GTK_WIDGET (mc->applet)));
    gtk_window_set_position (GTK_WINDOW (mc->file_select), GTK_WIN_POS_CENTER);

    gtk_widget_show(mc->file_select);

    return FALSE;
}
/*---------------------------------导出down-----------------------------*/
	void export_selcet_file(GtkWidget *window,gpointer data)
{
	GtkWidget *dialog;
	static gchar *filename55=NULL;
	GtkTreeModel *model55;
	static gchar *buf55=NULL;
	static gchar *tmp55=NULL;
	GtkTreeIter iter55;
	
	model55=gtk_tree_view_get_model (GTK_TREE_VIEW(tree_view));
	
	if(gtk_tree_selection_get_selected (GTK_TREE_SELECTION(data),&model55,&iter55)){
		buf55=(char *)malloc(sizeof(char)*20);
		tmp55=(char *)malloc(sizeof(char)*200);
		gtk_tree_model_get (model55,&iter55,1,&buf55,-1);
	dialog=gtk_file_chooser_dialog_new(_("Please rename the exported file"),NULL,GTK_FILE_CHOOSER_ACTION_SAVE,GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_SAVE,
	                                   GTK_RESPONSE_OK,NULL);
	if(gtk_dialog_run (dialog)==GTK_RESPONSE_OK){
		//import_print_file_name (dialog);
		filename55=gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(dialog));
		//g_printf("yyyy%s\n",buf55);
		//g_printf("%s\n",filename55);
		sprintf(tmp55,"docker export -o %s %s",filename55,buf55);
		system(tmp55);
		g_printf("%s\n",tmp55);
		g_free(buf55);
		g_free(tmp55);
		gtk_widget_destroy (dialog);
	}
	else{
		gtk_widget_destroy (dialog);
	}
	}
	else{
	contains_message (GTK_MESSAGE_ERROR,_("Choose a line of content"));
		return;
	}
}
Beispiel #7
0
/**
 * Crée le dialogue pour le choix du nouveau répertoire et entre le choix
 * dans le GtkComboBoxEntry
 *
 * \param bouton appelant
 *
 * \return void
 *
 * */
void gsb_select_icon_create_file_chooser ( GtkWidget * button,
                                           gpointer user_data )
{
    GtkWidget *chooser;
    GtkFileFilter *filter;

    chooser = gtk_file_chooser_dialog_new ( _("Select icon directory"),
                        GTK_WINDOW (dialog),
                        GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
                        GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                        GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
                        NULL);

	gtk_window_set_position ( GTK_WINDOW (chooser), GTK_WIN_POS_CENTER_ON_PARENT );
    gtk_window_set_transient_for (GTK_WINDOW (chooser), GTK_WINDOW (dialog));
	gtk_window_set_destroy_with_parent (GTK_WINDOW (chooser), TRUE);
    gtk_widget_set_size_request ( chooser, 600, 750 );
    filter = gtk_file_filter_new ();
	gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (chooser), filter);
    gtk_file_chooser_set_current_folder ( GTK_FILE_CHOOSER ( chooser ), path_icon );
    if (gtk_dialog_run (GTK_DIALOG ( chooser ) ) == GTK_RESPONSE_ACCEPT )
    {
        GtkTreePath *path;

        path_icon = gtk_file_chooser_get_filename ( GTK_FILE_CHOOSER ( chooser ) );
        devel_debug ( path_icon );
        path = gsb_select_icon_fill_icon_view ( NULL );
        gtk_icon_view_scroll_to_path (GTK_ICON_VIEW ( icon_view ),
                            path, TRUE, 0.5, 0 );
        gsb_select_icon_add_path ( );
        gtk_entry_set_text ( GTK_ENTRY (GTK_BIN (entry_text)->child ),
                                 path_icon );
        gtk_widget_set_sensitive (bouton_OK, FALSE );
    }

    gtk_widget_destroy ( chooser );

}
Beispiel #8
0
/* Laed ein neues Listenfile bzw. erzeugt
 * eine neue Liste.
 * Dazu wird ein Dateiauswahl-Dialog angezeigt,
 * dessen Ergebnis der Listenname ist.
 * Es wird auch ueberprueft ob die Datei bereits 
 * geladen ist.
 * Args:
 *   selectorTitle .. Der Titel der Dateiauswahl
 *   existMsg      .. Der Text der in dem Dialog 
 *                    Angezeigt wird, der mitteilt,
 *                    das die Datei bereits geladen 
 *                    ist und fragt ob sie neu geladen
 *                    werden soll.
 *   type          .. Legt Fest ob es ein "Oeffnen" Dialog
 *                    (zum oeffnen existierender Listen) 
 *                    oder ein "Speichern" Dialog (zum 
 *                    anlegen neuer Listen) sein soll.
 * Ret:
 *   Nichts
 * */
void fetchNewListFile(char *selectorTitle, char *existMsg, int type){
  GtkWidget *fileSel;
  char *filename;

  fileSel = gtk_file_chooser_dialog_new (selectorTitle,
      (GtkWindow*)main_app_window,
      type,
      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
      GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
      NULL);

  if (gtk_dialog_run (GTK_DIALOG (fileSel)) == GTK_RESPONSE_ACCEPT){
    filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fileSel));
    if (getPhoneList(filename) == NULL){
      if (type == GTK_FILE_CHOOSER_ACTION_SAVE){
        newPhoneFile(filename);
      }
      if(pushPhoneList(readPhoneFile(filename), filename) == OK){
	addPhoneModelList(filename);
	addListsListElm(filename);
      }
    } else {
      if(askYesNo(existMsg)){
	closeListByName(filename, NULL);
	if(pushPhoneList(readPhoneFile(filename), filename) == OK){
	  addPhoneModelList(filename);
	  addListsListElm(filename);
	}
      }
    }
    GtkTreeIter iter = getIterByFilename(filename);
    if(gtk_list_store_iter_is_valid(listsListStore, &iter)){
      gtk_tree_selection_select_iter(listsListSel, &iter);
    }
    g_free (filename);
  }
  gtk_widget_destroy (fileSel);
}
Beispiel #9
0
static gchar*
remmina_ftp_client_get_download_dir(RemminaFTPClient *client)
{
	RemminaFTPClientPriv *priv = (RemminaFTPClientPriv*) client->priv;
	GtkWidget *dialog;
	gchar *localdir = NULL;

	dialog = gtk_file_chooser_dialog_new(_("Choose download location"),
			GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(client))), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
			"_Cancel", GTK_RESPONSE_CANCEL, "_OK", GTK_RESPONSE_ACCEPT, NULL);
	if (priv->working_directory)
	{
		gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), priv->working_directory);
	}
	if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
	{
		g_free(priv->working_directory);
		priv->working_directory = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(dialog));
		localdir = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
	}
	gtk_widget_destroy(dialog);
	return localdir;
}
void i_configure_ev_browse_for_entry( GtkWidget * target_entry )
{
  GtkWidget *parent_window = gtk_widget_get_toplevel( target_entry );
  GtkFileChooserAction act = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(target_entry),"fc-act"));
  if (gtk_widget_is_toplevel (parent_window))
  {
    GtkWidget *browse_dialog = gtk_file_chooser_dialog_new( _("AMIDI-Plug - select file") ,
                                                            GTK_WINDOW(parent_window) , act ,
                                                            GTK_STOCK_CANCEL , GTK_RESPONSE_CANCEL ,
                                                            GTK_STOCK_OPEN , GTK_RESPONSE_ACCEPT , NULL );
    if ( strcmp( gtk_entry_get_text(GTK_ENTRY(target_entry)) , "" ) )
      gtk_file_chooser_set_filename( GTK_FILE_CHOOSER(browse_dialog) ,
                                     gtk_entry_get_text(GTK_ENTRY(target_entry)) );
    if ( gtk_dialog_run(GTK_DIALOG(browse_dialog)) == GTK_RESPONSE_ACCEPT )
    {
      gchar *filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(browse_dialog) );
      gtk_entry_set_text( GTK_ENTRY(target_entry) , filename );
      DEBUGMSG( "selected file: %s\n" , filename );
      g_free( filename );
    }
    gtk_widget_destroy( browse_dialog );
  }
}
void
ags_menu_action_open_callback(GtkWidget *menu_item, gpointer data)
{
  AgsApplicationContext *application_context;
  AgsWindow *window;
  GtkFileChooserDialog *file_chooser;
  gint response;

  application_context = ags_application_context_get_instance();
  window = (AgsWindow *) ags_ui_provider_get_window(AGS_UI_PROVIDER(application_context));

  file_chooser = (GtkFileChooserDialog *) gtk_file_chooser_dialog_new("open file",
								      (GtkWindow *) window,
								      GTK_FILE_CHOOSER_ACTION_OPEN,
								      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
								      GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
								      NULL);
  gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(file_chooser), FALSE);
  gtk_widget_show_all((GtkWidget *) file_chooser);

  g_signal_connect((GObject *) file_chooser, "response",
		   G_CALLBACK(ags_menu_action_open_response_callback), data);
}
Beispiel #12
0
void gtkui_state_load() {
	// Load a state from the GUI
	GtkWidget *dialog = gtk_file_chooser_dialog_new("Load State (.nst)",
				GTK_WINDOW(gtkwindow),
				GTK_FILE_CHOOSER_ACTION_OPEN,
				GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
				GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
				NULL);

	GtkFileFilter *filter = gtk_file_filter_new();
	gtk_file_filter_set_name(filter, "Nestopia Save States");
	gtk_file_filter_add_pattern(filter, "*.nst");
	gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter);
	gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), nstpaths.statepath);
	
	if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
		char *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
		nst_state_load(filename);
		g_free(filename);
	}
	
	gtk_widget_destroy(dialog);
}
Beispiel #13
0
void FileChooser::openFileChooser(Document* document)
{
    FrameView* view = document->view();
    if (!view)
        return;

    GtkWidget* dialog = gtk_file_chooser_dialog_new(_("Upload File"),
                                                    GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(view->containingWindow()))),
                                                    GTK_FILE_CHOOSER_ACTION_OPEN,
                                                    GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                                    GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
                                                    NULL);

    // We need this protector because otherwise we can be deleted if the file upload control is detached while
    // we're within the gtk_run_dialog call.
    RefPtr<FileChooser> protector(this);
    String result;

    const bool acceptedDialog = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT;
    if (acceptedDialog && stringByAdoptingFileSystemRepresentation(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)), result))
        chooseFile(result);
    gtk_widget_destroy(dialog);
}
Beispiel #14
0
static void fileSelectButtonClick (GtkWidget *widget, gpointer data)
{
	GtkWidget *dialog;
	gchar *filename;

	dialog = gtk_file_chooser_dialog_new (
				"locate usbdevfs devices file",
				GTK_WINDOW (windowMain),
				GTK_FILE_CHOOSER_ACTION_OPEN,
				"_OK", GTK_RESPONSE_ACCEPT,
				"_Cancel", GTK_RESPONSE_REJECT,
				NULL);

	if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
	{
		filename = gtk_file_chooser_get_filename(
						GTK_FILE_CHOOSER (dialog));
		gtk_entry_set_text (GTK_ENTRY (fileEntry), filename);
		g_free (filename);
	}
			  
	gtk_widget_destroy (dialog);
}
Beispiel #15
0
static void file_save(GtkWidget *w, gpointer data)
{
	GtkWidget *dialog;
	dialog = gtk_file_chooser_dialog_new("Save File",
		GTK_WINDOW(main_window),
		GTK_FILE_CHOOSER_ACTION_SAVE,
		GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
		GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
		NULL);
	gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE);
	if (!existing_filename) {
		gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), "Untitled document");
	} else
		gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), existing_filename);

	if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
		char *filename;
		filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
		save_dives(filename);
		g_free(filename);
	}
	gtk_widget_destroy(dialog);
}
Beispiel #16
0
void gui_dialog_show_filename(GtkWidget * txt_entry)
{
    GtkWidget *file_chooser = NULL;
    GGaduKeyValue *kv = (GGaduKeyValue *) g_object_get_data(G_OBJECT(txt_entry), "kv");
    gchar *filename = NULL;
    gint response;

    file_chooser =
        gtk_file_chooser_dialog_new(_("Select file"), GTK_WINDOW(window), GTK_FILE_CHOOSER_ACTION_OPEN,
                                    GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);

    response = gtk_dialog_run(GTK_DIALOG(file_chooser));

    if (response == GTK_RESPONSE_OK)
    {
        gsize r, w;
        filename = g_filename_to_utf8(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(file_chooser)), -1, &r, &w, NULL);
        gtk_entry_set_text(GTK_ENTRY(txt_entry), filename);
        kv->value = (gpointer) filename;
    }

    gtk_widget_destroy(file_chooser);
}
Beispiel #17
0
/* Shows the file chooser dialog when base path button is clicked
 * FIXME: this should be connected in Glade but 3.8.1 has a bug
 * where it won't pass any objects as user data (#588824). */
G_MODULE_EXPORT void
on_project_properties_base_path_button_clicked(GtkWidget *button,
	GtkWidget *base_path_entry)
{
	GtkWidget *dialog;

	g_return_if_fail(base_path_entry != NULL);
	g_return_if_fail(GTK_IS_WIDGET(base_path_entry));

	dialog = gtk_file_chooser_dialog_new(_("Choose Project Base Path"),
		NULL, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
		GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
		GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
		NULL);

	if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
	{
		gtk_entry_set_text(GTK_ENTRY(base_path_entry),
			gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)));
	}

	gtk_widget_destroy(dialog);
}
Beispiel #18
0
void gtkui_cheats_load() {
	// Load cheats from the GUI
	GtkWidget *dialog = gtk_file_chooser_dialog_new("Load cheats (.xml)",
				GTK_WINDOW(gtkwindow),
				GTK_FILE_CHOOSER_ACTION_OPEN,
				"Cancel", GTK_RESPONSE_CANCEL,
				"Open", GTK_RESPONSE_ACCEPT,
				NULL);

	GtkFileFilter *filter = gtk_file_filter_new();
	gtk_file_filter_set_name(filter, "Nestopia cheats");
	gtk_file_filter_add_pattern(filter, "*.xml");
	gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter);
	gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), nstpaths.nstdir);
	
	if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
		char *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
		gtkui_cheats_fill_tree(filename);
		g_free(filename);
	}
	
	gtk_widget_destroy(dialog);
}
Beispiel #19
0
static void export_clicked(GtkWidget *w, gpointer user_data)
{
  dt_lib_styles_t *d = (dt_lib_styles_t *)user_data;
  char *name = get_style_name(d);
  if(name)
  {
    GtkWidget *win = dt_ui_main_window(darktable.gui->ui);
    GtkWidget *filechooser = gtk_file_chooser_dialog_new(
        _("select directory"), GTK_WINDOW(win), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, _("_Cancel"),
        GTK_RESPONSE_CANCEL, _("_Save"), GTK_RESPONSE_ACCEPT, (char *)NULL);
    gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(filechooser), g_get_home_dir());
    gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(filechooser), FALSE);
    if(gtk_dialog_run(GTK_DIALOG(filechooser)) == GTK_RESPONSE_ACCEPT)
    {
      char *filedir = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(filechooser));
      dt_styles_save_to_file(name, filedir, FALSE);
      dt_control_log(_("style %s was successfully saved"), name);
      g_free(filedir);
    }
    g_free(name);
    gtk_widget_destroy(filechooser);
  }
}
Beispiel #20
0
static void
pgd_annot_save_file_attachment_button_clicked (GtkButton                  *button,
					       PopplerAnnotFileAttachment *annot)
{
    GtkWidget         *file_chooser;
    PopplerAttachment *attachment;

    attachment = poppler_annot_file_attachment_get_attachment (annot);
    if (!attachment)
        return;

    file_chooser = gtk_file_chooser_dialog_new ("Save attachment",
						GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (button))),
						GTK_FILE_CHOOSER_ACTION_SAVE,
						"_Cancel", GTK_RESPONSE_CANCEL,
						"_Save", GTK_RESPONSE_ACCEPT,
						NULL);
    gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (file_chooser), attachment->name);
    g_signal_connect (G_OBJECT (file_chooser), "response",
		      G_CALLBACK (pgd_annots_file_attachment_save_dialog_response),
		      (gpointer) attachment);
    gtk_widget_show (file_chooser);
}
/* Game -> Open activated */
void open_file_dialog(GtkMenuItem *item, gpointer user_data)
{
        GtkWidget *dialog;

        halt_ai_thread();
        dialog = gtk_file_chooser_dialog_new("Open File",
        				     GTK_WINDOW(window),
        				     GTK_FILE_CHOOSER_ACTION_OPEN,
        				     GTK_STOCK_CANCEL,
        				     GTK_RESPONSE_CANCEL,
        				     GTK_STOCK_OPEN,
        				     GTK_RESPONSE_ACCEPT,
        				     NULL);
        if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
            char *filename;

            filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
            load_moves_list(filename);
            g_free(filename);
        }
        gtk_widget_destroy(dialog);
        start_ai_thread();
}
Beispiel #22
0
static void on_add_external(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer user_data)
{
	GtkWidget *dialog;

	dialog = gtk_file_chooser_dialog_new(_("Add External Directory"),
		GTK_WINDOW(geany->main_widgets->window), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
		_("_Cancel"), GTK_RESPONSE_CANCEL,
		_("Add"), GTK_RESPONSE_ACCEPT, NULL);
	gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), get_project_base_path());

	if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
	{
		gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
		
		prjorg_project_add_external_dir(filename);
		prjorg_sidebar_update(TRUE);
		project_write_config();
		
		g_free (filename);
	}

	gtk_widget_destroy(dialog);
}
Beispiel #23
0
void save_patch() //Actually save XML-data to an external file
{
    GtkWidget *dialog;
    std::string filename;
    dialog = gtk_file_chooser_dialog_new(
        "Save File",
        (GtkWindow*)(mainwindow),
        GTK_FILE_CHOOSER_ACTION_SAVE,
        GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
        GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
        NULL);
    gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
    gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), ""); //Default directory
    gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), "untitled.xml");
    if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
    {
        char *filename;
        filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
        dump_patch(filename);
        g_free (filename);
    }
    gtk_widget_destroy (dialog);
}//end save_patch()
Beispiel #24
0
static void backupcopy_dir_button_clicked_cb(GtkButton *button, gpointer item)
{
	/** TODO add win32_show_pref_file_dialog to the plugin API and use it **/
/*
#ifdef G_OS_WIN32
	win32_show_pref_file_dialog(item);
#else
*/
	GtkWidget *dialog;
	gchar *text;

	/* initialize the dialog */
	dialog = gtk_file_chooser_dialog_new(_("Select Directory"), NULL,
					GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
					GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
					GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);

	text = utils_get_locale_from_utf8(gtk_entry_get_text(GTK_ENTRY(item)));
	if (!EMPTY(text))
		gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), text);

	/* run it */
	if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
	{
		gchar *utf8_filename, *tmp;

		tmp = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
		utf8_filename = utils_get_utf8_from_locale(tmp);

		gtk_entry_set_text(GTK_ENTRY(item), utf8_filename);

		g_free(utf8_filename);
		g_free(tmp);
	}

	gtk_widget_destroy(dialog);
}
Beispiel #25
0
static void gtk_assert_dialog_save_backtrace_callback(GtkWidget*, GtkAssertDialog* dlg)
{
    GtkWidget *dialog;

    dialog = gtk_file_chooser_dialog_new ("Save assert info to file", GTK_WINDOW(dlg),
                                          GTK_FILE_CHOOSER_ACTION_SAVE,
                                          GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                          GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
                                          NULL);

    if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
    {
        char *filename, *msg, *backtrace;
        FILE *fp;

        filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
        if ( filename )
        {
            msg = gtk_assert_dialog_get_message (dlg);
            backtrace = gtk_assert_dialog_get_backtrace (dlg);

            /* open the file and write all info inside it */
            fp = fopen (filename, "w");
            if (fp)
            {
                fprintf (fp, "ASSERT INFO:\n%s\n\nBACKTRACE:\n%s", msg, backtrace);
                fclose (fp);
            }

            g_free (filename);
            g_free (msg);
            g_free (backtrace);
        }
    }

    gtk_widget_destroy (dialog);
}
Beispiel #26
0
/**
 * load_scm_file:
 * @btn : le bouton [inutilisé]
 * @data : [inutilisé]
 *
 * Charge un fichier scm dans l'interprêteur
 * afin que les fonctions soit chargées globalement
 * pour toute la calculette
 */
void
load_scm_file (GtkAction* btn, gpointer data)
{
	GtkFileFilter *filter;
	GtkWidget *chooser;
	gchar *chemin = NULL;
	SCM result;
	
	chooser = gtk_file_chooser_dialog_new ("Ouvrir...",
											GTK_WINDOW(SCM_CALC (data)->window),
											GTK_FILE_CHOOSER_ACTION_OPEN,
											GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
											GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
											NULL);
	
	gtk_window_set_modal(GTK_WINDOW(chooser), TRUE);
		
	filter = gtk_file_filter_new ();
	gtk_file_filter_add_pattern (filter, "*.scm");
	
	gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (chooser), filter);
	
	if (gtk_dialog_run (GTK_DIALOG (chooser)) == GTK_RESPONSE_ACCEPT)
	{
		chemin = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
		
		result = scm_c_catch (SCM_BOOL_T,
							wrapper_body_proc, (gpointer) chemin,
							wrapper_handler_proc, NULL,
							NULL, NULL);
		
		g_free (chemin);
	}


	gtk_widget_destroy (chooser);	
}
Beispiel #27
0
void
dialog_simulator_save_as ()
{
  char *name;
  char buffer[JB_BUFFER_SIZE];
  GtkFileChooserDialog *dlg;

  dlg =
    (GtkFileChooserDialog *)
    gtk_file_chooser_dialog_new (gettext ("Save system as"),
                                 dialog_simulator->window,
                                 GTK_FILE_CHOOSER_ACTION_SAVE,
                                 gettext ("_Cancel"), GTK_RESPONSE_CANCEL,
                                 gettext ("_OK"), GTK_RESPONSE_OK, NULL);
  gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dlg), 1);
  gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (dlg), 0);
  snprintf (buffer, JB_BUFFER_SIZE, "%s/%s", sys->directory, sys->name);
  if (!gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dlg), buffer))
    {
      gtk_file_chooser_set_current_folder
        (GTK_FILE_CHOOSER (dlg), sys->directory);
      gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dlg), sys->name);
    }
  window_parent = (GtkWindow *) dlg;
  if (gtk_dialog_run (GTK_DIALOG (dlg)) == GTK_RESPONSE_OK)
    {
      name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dlg));
      jb_free_null ((void **) &sys->name);
      sys->name = g_path_get_basename (name);
      jb_free_null ((void **) &sys->directory);
      sys->directory = g_path_get_dirname (name);
      g_free (name);
      system_save_xml (sys);
    }
  gtk_widget_destroy (GTK_WIDGET (dlg));
  window_parent = dialog_simulator->window;
}
Beispiel #28
0
static void on_select_post (GtkEntry* entry, GtkEntryIconPosition icon_pos, GdkEvent* event, UgtkDownloadForm* dform)
{
	GtkWidget*	chooser;
	gchar*		path;
	gchar*		title;

	// disable sensitive of parent window
	// enable sensitive in function on_file_chooser_response()
	if (dform->parent)
		gtk_widget_set_sensitive ((GtkWidget*) dform->parent, FALSE);

	title = g_strconcat (UGTK_APP_NAME " - ", _("Select Post File"), NULL);
	chooser = gtk_file_chooser_dialog_new (title, dform->parent,
			GTK_FILE_CHOOSER_ACTION_OPEN,
			GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
			GTK_STOCK_OK,     GTK_RESPONSE_OK,
			NULL);
	g_free (title);
	gtk_window_set_transient_for ((GtkWindow*) chooser, dform->parent);
	gtk_window_set_destroy_with_parent ((GtkWindow*) chooser, TRUE);

	path = (gchar*) gtk_entry_get_text ((GtkEntry*) dform->post_entry);
	if (*path) {
		path = g_filename_from_utf8 (path, -1, NULL, NULL, NULL);
		gtk_file_chooser_select_filename (GTK_FILE_CHOOSER (chooser), path);
		g_free (path);
	}
	g_signal_connect (chooser, "response",
			G_CALLBACK (on_select_post_response), dform);

	if (gtk_window_get_modal (dform->parent))
		gtk_dialog_run ((GtkDialog*) chooser);
	else {
		gtk_window_set_modal ((GtkWindow*) chooser, FALSE);
		gtk_widget_show (chooser);
	}
}
Beispiel #29
0
Datei: gtk.c Projekt: PKRoma/uTox
static void gtk_openavatarthread(void *UNUSED(args))
{
    void *dialog = gtk_file_chooser_dialog_new(S(SELECT_AVATAR_TITLE), NULL, 0, "gtk-cancel", -6, "gtk-open", -3, NULL);
    void *filter = gtk_file_filter_new();
    gtk_file_filter_add_mime_type(filter, "image/png");
    gtk_file_chooser_set_filter(dialog, filter);

    while (gtk_dialog_run(dialog) == -3) { // -3 means user selected an image
        char *filename = gtk_file_chooser_get_filename(dialog);
        uint32_t size;

        void *file_data = file_raw(filename, &size);
        g_free_utox(filename);
        if (!file_data) {
            void *message_dialog = gtk_message_dialog_new(dialog, 0, 1, 2, (const char *)S(CANT_FIND_FILE_OR_EMPTY));
            gtk_dialog_run(message_dialog);
            gtk_widget_destroy(message_dialog);
        } else if (size > UTOX_AVATAR_MAX_DATA_LENGTH) {
            free(file_data);
            char_t size_str[16];
            int len = sprint_bytes(size_str, sizeof(size_str), UTOX_AVATAR_MAX_DATA_LENGTH);
            void *message_dialog = gtk_message_dialog_new(dialog, 0, 1, 2, "%s%.*s.", S(AVATAR_TOO_LARGE_MAX_SIZE_IS), len, size_str);
            gtk_dialog_run(message_dialog);
            gtk_widget_destroy(message_dialog);
        } else {
            postmessage(SET_AVATAR, size, 0, file_data);
            break;
        }
    }

    gtk_widget_destroy(dialog);
    while(gtk_events_pending()) {
        gtk_main_iteration();
    }

    gtk_open = 0;
}
void on_save_as1_activate(GtkWidget *widget)
{
    GtkWidget *file_selection_box;
    gchar *filename;
    const gchar *last_opened_folder;

    if (document_manager_get_current_document(main_window.docmg)) {
        // Create the selector widget
        file_selection_box = gtk_file_chooser_dialog_new (_("Please type the filename to save as..."),
                             GTK_WINDOW(main_window.window), GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                             GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL);

        gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER(file_selection_box), FALSE);
        gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER(file_selection_box), TRUE);
        gtk_dialog_set_default_response (GTK_DIALOG(file_selection_box), GTK_RESPONSE_ACCEPT);

        if (document_manager_get_current_document(main_window.docmg)) { //FIXME: rework this code
            filename = document_get_filename(document_manager_get_current_document(main_window.docmg));
            if (!document_get_untitled(document_manager_get_current_document(main_window.docmg))) {
                gtk_file_chooser_set_uri(GTK_FILE_CHOOSER(file_selection_box), filename);
            }
            else {
                last_opened_folder = get_preferences_manager_last_opened_folder(main_window.prefmg);
                gphpedit_debug_message(DEBUG_MAIN_WINDOW,"last_opened_folder: %s", last_opened_folder);
                if (last_opened_folder) {
                    gphpedit_debug_message(DEBUG_MAIN_WINDOW,"Setting current_folder_uri to %s", last_opened_folder);
                    gtk_file_chooser_set_current_folder_uri(GTK_FILE_CHOOSER(file_selection_box),  last_opened_folder);
                }
            }
            g_free(filename);
        }
        if (gtk_dialog_run (GTK_DIALOG(file_selection_box)) == GTK_RESPONSE_ACCEPT) {
            save_file_as_ok(GTK_FILE_CHOOSER(file_selection_box));
        }
        gtk_widget_destroy(file_selection_box);
    }
}