Re: Function completion for GVariant maybe types?

2013-02-21 Thread Andrew Potter
On Thu, Feb 21, 2013 at 1:02 AM, Markus Elfring wrote:

> > In glibmm 2.36 it will be possible to test whether the GVariant is null
> or not
> > by just doing if (v), see bug 690121.
>
> Thanks for your information about the issue "Provide operator BoolExpr for
> VariantBase".
>
> How do deal with the desire to reset an object to "nothing" by the means
> of this
> C++ class library?
>
> Regards,
> Markus
>

#include 
#include 

void print_v(const Glib::Variant &v)
{
if (v.gobj() == NULL)
 std::cout << "v is a nothing" << std::endl;
else
std::cout << "v is an int containing " << v.get() << std::endl;
}

int main() {
Glib::Variant v = Glib::Variant::create(4);
print_v(v);

// Now I want to set v to 'Nothing'
v = Glib::Variant();
print_v(v);
}
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: Function completion for GVariant maybe types?

2013-02-20 Thread Andrew Potter
On Wed, Feb 20, 2013 at 1:44 PM, Markus Elfring wrote:

> I do not think that I can refer to such preallocated objects if I would
> like to
> reuse a template class like "Gtk::TreeModelColumn".
>
> I disagree to your conclusion here. - I would like to copy the data type
> information from the contained value into a new "Nothing GVariant" in an
> efficient way. I do not really want to know the concrete copied data type
> if I
> would like that this operation will be supported in a generic way so that
> it can
> be reused by other class libraries like "glibmm".


I can't say I really understand what you want, but in glibmm you can:
Glib::VariantBase v = Glib::VariantBase();
Which will create C++ VariantBase object that does not actually have an
allocated
GVariant backing it, e.g. v.gobj() == NULL

In glibmm 2.36 it will be possible to test whether the GVariant is null or
not by just
doing if (v), see bug 690121.
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: gtk_widget_set_size_request stopped working with GTK3

2012-09-30 Thread Andrew Potter
When creating a new widget subclass, you end up implementing
get_preferred_height/width. This allows you to specify both a
"minimum" and a "natural" size. Then in on_size_allocate() you can
decide to maybe set a clipped or scaled version of your pixbuf to a
GtkImage. When you do it this way, you don't need to put the image in
a scrolled window either.

Its a shame there are only methods to expose the minimum width and not
also the natural width on the default widgets, but I'd guess its
difficult to abstract across all widgets. But it does seem like
GtkImage should at least expose the natural width, as it seems like a
common problem one would have with pictures.

On Fri, Sep 28, 2012 at 11:28 PM, Tristan Van Berkom  wrote:
> Lets not go around the merry-go-round one more time.
>
> In GTK+3, widgets receive *at least* what they requested in the size
> requesting phase.
>
> User facing apis cannot undermine the minimal requirements for the geometry
> which a widget has requested.
>
> User facing apis can however, enforce a minimum size (i.e. the widget
> will be at least "this big")
> or they can configure a widget in such a way that it will require less size.
>
> The "pixel-size" thing not working for pixbufs could be considered an
> enhancement
> request bug for GtkImage.
>
> i.e. it should support clipping of pixbufs (and then, it should also
> need some alignment
> parameters to decide which portion of the input image should be
> clipped, also pixel-size
> does not really imply clipping directly, the user might very well
> expect the image to scale
> to the desired size).
>
> On Sat, Sep 29, 2012 at 2:28 AM, Steffen Gutmann  wrote:
> [...]
>> Here is what I am trying to do.
>>
>> I have an image.  The center part of the image contains a logo that I want 
>> to display to the user.  Around the center part there is little extra 
>> content that is not important but nice to have.  With GTK2 I set the min 
>> size (properties "with-request" and "height-request") to just about the size 
>> of the logo, place the GtkImage into a GtkWindow, set the default size of 
>> the GtkWindow to slightly larger than the min size but smaller than the 
>> fulll size of the image, make the window resizable, and show it to the user. 
>>  GtkImage in GTK2 automatically clipped the image and centered it.  The user 
>> can enlarge the window and see more of the image, or shrink it down to the 
>> min size where only the logo stays visible.
>>
>> I have not found a way yet to achive the same with GTK3.
>
> a.) Create a GtkDrawingArea
>
> b.) Connect to "draw" signal
>
> c.) Use this code:
>
>gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y);
>cairo_paint (cr);
>(borrowed directly from:
> http://developer.gnome.org/gtk3/3.5/gtk-migrating-2-to-3.html)
>
>
> The above should pretty much get you what you want, just consider the widget's
> allocation at "draw" time and use that to offset the given x,y for
> gdk_cairo_set_source_pixbuf().
>
> Cheers,
>  -Tristan
> ___
> gtk-devel-list mailing list
> gtk-devel-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gtk-devel-list
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list


TextView height incorrect when inserted in already show()n parent

2012-09-17 Thread Andrew Potter
Hi,
If you insert a TextView with some long line of text and word wrapping
enabled, it seems that its initial height request remains the same as
it would if hexpand were set to false. But, this only happens when
inserting into a parent that has already had show() called on it. A
test case is below. If someone could tell me some workaround I'd
appreciate it.

Its worth noting that if you click on the textview, it will fix
itself. It seems similar to bug 540909, but this doesn't involve any
notebooks. Just a Window, Grid, and TextView.
A line-wrapping GtkLabel does not exhibit this behavior (it always
renders as if TRIGGER_BUG == FALSE).

#include 
#include 

#define TRIGGER_BUG TRUE

int main(int argc, char** argv) {
gtk_init(&argc, &argv);
GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
GtkWidget *grid = gtk_grid_new();
GtkWidget *label = gtk_label_new("--");
GtkTextView *tv = GTK_TEXT_VIEW(gtk_text_view_new());
GtkTextBuffer *tb = gtk_text_view_get_buffer(tv);

gtk_window_set_default_size(GTK_WINDOW(window), 500, 800);
gtk_orientable_set_orientation(GTK_ORIENTABLE(grid), 
GTK_ORIENTATION_VERTICAL);

gchar *text = "The quick brown fox jumps over the lazy dog. Pack my
box with five dozen liquor jugs. A quick movement of the enemy will
jepordize six gunboats. The quick brown fox jumps over the lazy dog.";
gtk_widget_set_hexpand(GTK_WIDGET(tv), TRUE);
gtk_text_view_set_wrap_mode(tv, GTK_WRAP_WORD);
gtk_text_buffer_set_text(tb, text, strlen(text));

gtk_container_add(GTK_CONTAINER(grid), GTK_WIDGET(tv));
gtk_container_add(GTK_CONTAINER(grid), label);

if (TRIGGER_BUG)
gtk_widget_show_all (window);

gtk_container_add(GTK_CONTAINER(window), grid);

gtk_widget_show_all (window);
gtk_main();
return 0;
}
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list