Fw: [PHP-GTK-DEV] Re: [php-gtk-cvs] cvs: php-gtk /test bug_gtkfilechooserbutton_actionselectfolder.phpw

From: Date: Wed, 05 Apr 2006 11:59:33 +0000
Subject: Fw: [PHP-GTK-DEV] Re: [php-gtk-cvs] cvs: php-gtk /test bug_gtkfilechooserbutton_actionselectfolder.phpw
Groups: php.gtk.dev 
Request: Send a blank email to php-gtk-dev+get-2711@lists.php.net to get a copy of this message
Hi Scott, Some attempt at diagnostics. All your errors are stemming from a single function in gtkfilechooserbutton.c: update_label_and_image (GtkFileChooserButton *button) { // skipping some code priv = GTK_FILE_CHOOSER_BUTTON_GET_PRIVATE (button); paths = _gtk_file_chooser_get_paths (GTK_FILE_CHOOSER (button->priv->dialog)); 'paths' at this point is a GSList representing _all_ the selected files in the current directory. It's defined at this stage as the highly experimental and unstable OO face of the interface: GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_paths (chooser); Now on my box this works, if slowly; - by 'selected' I _believe_ they mean 'in the combobox list at all', but as far as I can see it should only open initially with one selected item, and that one should represent the current directory (aka whereever your php is running). if (paths) { // you get through this part okay and into this block, so 'paths' DOES exist - but as what?
     GtkFilePath *path, *parent_path;
     GtkFileSystemVolume *volume;
     GtkFileFolder *folder;
     path = paths->data;   /*     struct _GSList {
                                             gpointer data;
                                             GSList *next;
                                           };
                                     */
     volume = gtk_file_system_get_volume_for_path (priv->fs, path);
/* This returns your first 'no path' error, and also prevents 'volume' from being populated, which in turn prevents base_path from being filled. So because this call failed, there's no data to label anything with... or to pix up pixmaps for. */
} } // skipping even more code There are no checks for either path or volume throughout the rest of the function that would prevent further errors, so you get an error in every block you can actually reach. So the next question is - where's it called from? GTK does this mapping thing to ensure inheritance: gtk_file_chooser_button_class_init (GtkFileChooserButtonClass * class) { // skip loads of stuff here gobject_class->set_property = gtk_file_chooser_button_set_property; // this is the important bit g_object_class_install_property (gobject_class, PROP_DIALOG, // skip LOTS of code to reach this
      g_param_spec_object ("dialog", // This is new in the code base
      P_("Dialog"), // "since 2.6" (it says in the src)
      P_("The file chooser dialog to use."), // QUESTION: is it missing from your copy?
      GTK_TYPE_FILE_CHOOSER_DIALOG,
      (G_PARAM_WRITABLE |
       G_PARAM_CONSTRUCT_ONLY)));  // skip lots more
} // end of class init function gtk_file_chooser_button_init (GtkFileChooserButton *button) { // the class instance is drawn a little later ... // but this might have no significance } // (the combo is drawn directly to private)
gtk_file_chooser_button_set_property (GObject      *object,
         guint         param_id,
         const GValue *value,
         GParamSpec   *pspec) {
switch (param_id) { // skip a bit more code g_object_set_property (G_OBJECT (priv->dialog), pspec->name, value); // The dialog was set
   update_label_and_image (GTK_FILE_CHOOSER_BUTTON (object));    // & our dodgy function called.
switch (g_value_get_enum (value)) {
       case GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER:
            gtk_widget_hide (priv->button);
            gtk_widget_show (priv->combo_box);
           break;
     }
case PROP_TITLE:
      g_object_set_property (G_OBJECT (priv->dialog), pspec->name, value); // Title is set very late?
break;
   case GTK_FILE_CHOOSER_PROP_FILE_SYSTEM_BACKEND:            // and so is backend
     /* Construct-only */
     priv->backend = g_value_dup_string (value);
break; } It'd be nice to be able to view that alleged GtkFileChooserDialog, but it's buried deep in privacy (and style helpers, but we won't go there). There's some reason to believe its typing hasn't always been reliable, so if you could confirm you have g_object_class_install_property() defined for the file chooser dialog in your copy of the source it'd be good. The struct for GtkFileChooserButton simply refers to it as a GtkWidget, because it needs to be cast as a GtkFileChooser at several points throughout the code. Some high-level debugging might be helpful too, e.g. are there any signals emitted prior to the death of the app? Particularly 'response', or 'current-folder-changed', or 'selection-changed'? Which directory does PHP think you're in when you're calling show()? I _think_ we'll probably need to override the constructor to ensure that we always create a GtkFileChooserButton with a GtkFileChooserDialog in it, or else we need to somehow make sure a path is actually registered with the dialog in some way. But I don't actually know for sure yet. BTW please don't bug it if you're trying to put a GtkFileChooserDialog in a GtkWindow - it's a close relative. - Steph

« previous php.gtk.dev (#2711) next »