spk121 / guile-gi

Bindings for GObject Introspection and libgirepository for Guile
GNU General Public License v3.0
58 stars 7 forks source link

gtk:dialog-new-with-buttons missing #92

Closed daym closed 3 years ago

daym commented 3 years ago

dialog:new-with-buttons is missing. Maybe because of the varargs ?

It would be nice to have a list of all such varargs-functions in gi, which are missing in guile-gi. Does it exist ?

Reading Gtk source, this function does some extra stuff.

  dialog = GTK_DIALOG (gtk_dialog_new_empty (title, parent, flags));
  gtk_dialog_add_buttons_valist (dialog, first_button_text, args);

... where gtk_dialog_new_empty is not exported. It is:

  dialog = g_object_new (GTK_TYPE_DIALOG,
                         "use-header-bar", (flags & GTK_DIALOG_USE_HEADER_BAR) != 0,
                         NULL);

  if (title)
    gtk_window_set_title (GTK_WINDOW (dialog), title);

  if (parent)
    gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);

  if (flags & GTK_DIALOG_MODAL)
    gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);

  if (flags & GTK_DIALOG_DESTROY_WITH_PARENT)
    gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);

  return GTK_WIDGET (dialog);
daym commented 3 years ago

symbol->dialog-flags is missing, too.

LordYuuma commented 3 years ago

Rather than trying to generate a list of functions, that are missing, you might want to try (gi documentation) for generating reference documentation for what does exist. Since you are already acquainted with require and load, you can also wrap some of your load calls in (apply peek 'some-debug-key [YOUR LOAD HERE]) to see what symbols get defined.

Alternatively, you can also enable debug messages to see what gets/doesn't get loaded in real time along with information on what goes wrong where.

LordYuuma commented 3 years ago

symbol->dialog-flags is missing, too.

Because they're flags. You have list->dialog-flags and number->dialog-flags.

LordYuuma commented 3 years ago
      <constructor name="new_with_buttons"
                   c:identifier="gtk_dialog_new_with_buttons"
                   introspectable="0">
      [...]
      </constructor>

Yeah, that seems to be a feature.

daym commented 3 years ago

Implementing that myself, I need to read the gtk source code and do some arcane stuff:

(define (dialog:add-buttons dialog buttons-and-responses)
  (for-each
    (match-lambda
     ((text response)
      (dialog:add-button dialog text response)))
    buttons-and-responses)
  dialog)

(define (dialog:new-with-buttons title parent flags . buttons-and-responses)
  (let ((dialog (make <GtkDialog> #:use-header-bar (and (member 'use-header-bar flags) #t)))
    (set-title dialog title)
    (set-transient-for dialog parent)
    (when (member 'modal flags)
      (set-modal dialog #t))
    (when (member 'destroy-with-parent flags)
      (set-destroy-with-parent dialog #t))
    (dialog:add-buttons dialog buttons-and-responses)
    dialog))

Therefore, I filed a bug report upstream: https://gitlab.gnome.org/GNOME/gtk/-/issues/3311