Libxfce4ui api review

Nick Schermer nickschermer at gmail.com
Tue Jul 7 10:12:29 CEST 2009


2009/7/7 Brian J. Tarricone <brian at tarricone.org>:
> On 2009/07/06 23:58, Nick Schermer wrote:
>>
>> 2009/7/6 Brian J. Tarricone<brian at tarricone.org>:
>> xfce_dialog_show_error takes the error message as secondary argument.
>> For the xfce_dialog_show_{info,warning,confirm} functions we could do
>> add a secondary text and use the format for the primary text, like:
>>
>> void xfce_dialog_show_warning (gpointer     parent,
>>                           const gchar *secondary_text,
>>                           const gchar *format,
>>                           ...);
>>
>> Are you ok with that?
>
> Hmm, yeah, that might work pretty well.  Maybe call the last arg
> 'primary_format' instead.

Yeah good point.

> Does it make more sense to use the format string capability for the primary
> or secondary string?  I'm not sure...

I don't think so, most of the time the secondary text describes what
the action does (in a less specific way) for example:
Pri: Are you sure you want to remove "%s"?
Sec: This will remove the item from the configuration permanently.

>>> 6.  xfce_gdk_pixbuf_new_from_inline_at_size() -- I forget why we need
>>> this... is using gdk directly much more difficult?
>>
>> I searched through the code at the time and IIRC it was still used at
>> 2 or more modules. Could be convenient.
>
> All right.  Yeah, I know I've used it before, but I wasn't sure how useful
> it is.  Really, tho, looking at the code, it's a pretty simple function.
>  It's basically just:
>
> pixbuf = gdk_pixbuf_new_from_inline(...);
> if(pixbuf && (width != pixbuf_width && height != pixbuf_height)) {
>    scaled = gdk_pixbuf_scale_simple(...);
>    g_object_unref(pixbuf);
>    pixbuf = scaled;
> }
> return pixbuf;
>
> I mean, it's effectively a 6-line function.  I dunno... I'm just attempting
> to push throwing away everything that's possible so at least the new lib
> starts out small.  But I guess it's useful.

I'll remove it, we'll see if we need it while porting the modules,
easier to add it in a later stage.

>>> 7.  We could also use a xfce_gtk_window_center_on_screen() that takes a
>>> GdkScreen* and monitor number.  I know I use the analogous libxfcegui4
>>> function in places.
>>
>> Function now uses gtk_window_set_position() so gtk centers the screen,
>> the old xfce_gtk_window_center_on_monitor in gui4 calculated the
>> center by using the size requisition, which is a bit of a hack.
>> Haven't tried gtk_window_set_position() in a while but IIRC is does
>> the right thing.
>
> I feel like the reason we had this function was because
> gtk_window_set_position() doesn't work in some instances.  Unfortunately the
> revision log for libgui's xfce-gtk-extensions.c doesn't provide any clues.

Will test it, see if it works (IIRC it only works during realize, but
we could handle that too in the code, print a warning or fallback to
the old way if realized). We can always change it to the way gui4
handles it.

>> Is there a place where xfce_gtk_window_center_on_screen is preferred
>> over xfce_gtk_window_center_on_active_screen?
>
> Probably not, good point.

Ok then we leave it out for the time being.

> Can you explain what those functions are for exactly?  I'm curious... If
> they're useful, we should keep them, but maybe make the API a little less
> weird.

It was mostly used for the dialogs, thunar uses it in some other
internal dialogs so therefore I made it public. Probably not very
useful in public api, since we decided we use GtkDialog parents in the
xfce_dialog_ code.

> EggSMClient itself is pretty well done and even has non-unix support (not
> that that's entirely useful for the Xfce core desktop).  As much as I don't
> want to create a new libnetk, it might make sense to base work on our
> session client on EggSMClient.  Or maybe just import it as-is. Or maybe even
> just bite the bullet and copy the sources into the core Xfce apps that use
> it, and don't have a session client at all.  That way we could just wait for
> gtk to have one.

We could add a libxfce4ui-session-private library (loooong name) using
eggsmclient so the code is in a central place, then we can drop it at
any time without having an api break.

Nick



More information about the Xfce4-dev mailing list