Re[2]: argv revisited



Le 2 mai 2016, Andrew Robinson a écrit :

I could find functions that worked for the command line, but I couldn't find
any that worked for the filechooser, and when I go online and do a search,
there are no examples for what I want to do. The GNOME forum answered my
UNICODE question for the command line issue, but didn't answer the part about
filechooser, and then they had the nerve to close out my bug report, which I
thought was very rude.

Also, I am kind of leery about having long filenames in Windows, and although
I didn't see a problem with it, I have seen lots of Linux programs that would
not work if certain file name paths contained any spaces. I am just not
getting any good feelings with GTK, which is sad, because it is the only
toolkit I know of that has a working add_from_file function.

I don't think I tried filenames with spaces, but I did test filenames with accented letters in both Linux and Windows, and it worked (using GTK2). E.g. for reading a file contents into one big string I have this:
-:-:-:-
  GtkWidget *dialog;
  dialog = gtk_file_chooser_dialog_new
    ("Title", GTK_WINDOW(gtkwin),
     GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
     GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
  /* gtk_file_chooser_set_current_name
         (GTK_FILE_CHOOSER (dialog), "foo.bar"); */
  if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT){
    char *filename;
    filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
    GFile *infile=g_file_new_for_path(filename);
    GFileInputStream *FIstream=g_file_read(infile, NULL, NULL);
    assert(FIstream);
    GDataInputStream *DIstream=
      g_data_input_stream_new(G_INPUT_STREAM(FIstream));
    assert(DIstream);
    char *string=
      g_data_input_stream_read_until(DIstream,"",NULL,NULL,NULL);
    assert(string);
    /* ... */
    g_free(string);
    g_object_unref(DIstream);
    g_object_unref(FIstream);
    g_object_unref(infile);
    g_free(filename);
  }
  gtk_widget_destroy(dialog);
-:-:-:-

(Not sure I understand your need, though.)

--
Lucas Levrel


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]