Re: coordinate system context for a drawing area uses (relative to get_allocation)

2017-05-15 Thread Tadej Borovšak
On Sat, May 13, 2017 at 05:00:43PM -0700, Dan Hitt wrote:
> So it appears that when you draw in a drawing area, using commands
> like (cairo_)move_to and (cairo_)line_to, the path is rendered
> relative to the top left of the area.
> 
> More explicitly, if you try to figure out how far you can draw, the x
> and y values from get_allocation(...) are not relevant, only the width
> and height.
> 
> Or in other words, the location at the top left of the drawing area
> has coordinates (0, 0) and at the bottom right has coordinates (width,
> height), rather than (x, y) and (x+width, y+height), at least as far
> as primitives like move_to and line_to are concerned.
> 
> This sure seems to be true on my system (debian stretch) using gtk3,
> but if i'm wrong, please correct me.

Yes, you are correct, things do work this way.

> Also, is this documented anywhere, or am i the only person clueless
> enough to try to get to the top left by going to the x,y returned by
> get_allocation, instead of to (0,0)?

This is documented in the draw signal docs [1].

Cheers,
Tadej


[1] https://developer.gnome.org/gtk3/stable/GtkWidget.html#GtkWidget-draw

-- 
Tadej Borovšak
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Get a list of object *names* from GtkBuilder

2015-11-15 Thread Tadej Borovšak
Hi.

Dne 16.11.2015 (pon) ob 13:26 +1100 je Daniel Kasak napisal(a):
> Greetings all.
> 
> I'd like to get a list of object names from a GtkBuilder object ( I'm
> using Perl ). I know about
> https://developer.gnome.org/gtk3/stable/GtkBuilder.html#gtk-builder-g
> et-objects
> - which returns a list of objects, but I really need the names. Is it
> possible?

Maybe you can call perl equivalent of gtk_buildable_get_name() on each
object in the list, returned by gtk_builder_get_objects()?

Cheers,
Tadej

-- 
Tadej Borovšak
tadej.borov...@gmail.com
tadeb...@gmail.com
blog.borovsak.si


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GTK signals question.

2014-03-05 Thread Tadej Borovšak
Dne 05.03.2014 (sre) ob 18:38 +1100 je Chris Angelico napisal(a):
> On Wed, Mar 5, 2014 at 6:29 PM, Tristan Van Berkom
>  wrote:
> > Interesting, if I were you I would try to share the same adjustment
> > between all of your views.
> >
> > I.e. I would keep the adjustment in the finest grained unit of each
> > unit you want to display, and have your spin buttons format the value
> > differently depending on what they are used for (or perhaps use GtkScale
> > if that makes sense in your UI).
> 
> Now *that* is an elegant solution, if it can be done!

Sure it can;) In the code below, this sharing is implemented between
spin buttons in first row. Beware though that now both widgets increment
for the same angle - increment in fixed to 0.1 radians.

If you need more flexibility, you can use 2 adjustments and bind their
"value" property through simple transformation. This method is
implemented in second row. Now incrementing can be done independently in
both widgets (first widgets increments in 0.1 radians, second in 1
degree steps).

--8<-

#include 

static gboolean
cb_output (GtkSpinButton *spin)
{
  GtkAdjustment *adj = gtk_spin_button_get_adjustment (spin);
  double val = gtk_adjustment_get_value (adj);
  gchar *text = g_strdup_printf ("%d", (gint)(val * 180 / G_PI + .5));

  gtk_entry_set_text (GTK_ENTRY (spin), text);
  g_free (text);

  return TRUE;
}

static gint
cb_input (GtkSpinButton *spin,
  gdouble   *value)
{
  gchar const *text = gtk_entry_get_text (GTK_ENTRY (spin));
  double val = g_strtod (text, NULL);
  *value = val * G_PI / 180;

  return TRUE;
}

static gboolean
rad_to_deg (GBinding *bind G_GNUC_UNUSED,
const GValue *from,
GValue   *to,
gpointer  data G_GNUC_UNUSED)
{
  double val = g_value_get_double (from);
  g_value_set_double (to, val * 180 / G_PI);

  return TRUE;
}

static gboolean
deg_to_rad (GBinding *bind G_GNUC_UNUSED,
const GValue *from,
GValue   *to,
gpointer  data G_GNUC_UNUSED)
{
  double val = g_value_get_double (from);
  g_value_set_double (to, val / 180 * G_PI);

  return TRUE;
}

int
main (intargc,
  char **argv)
{
  GtkWidget *window, *grid, *s1, *s2, *s3, *s4;
  GtkAdjustment *adj, *adj1, *adj2;

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect (window, "destroy", gtk_main_quit, NULL);

  grid = gtk_grid_new ();
  gtk_container_add (GTK_CONTAINER (window), grid);

  /* Use single adjustment: both spin buttons use radians as the data
   * storage, second one converts radians to degrees on input/output */
  adj = gtk_adjustment_new (1, 0, 2 * G_PI, 0.1, 0.5, 0);
  s1 = gtk_spin_button_new (adj, 0.5, 2);
  g_object_set (s1, "expand", TRUE, NULL);
  gtk_grid_attach (GTK_GRID (grid), s1, 0, 0, 1, 1);

  s2 = gtk_spin_button_new (adj, 0.5, 2);
  g_object_set (s2, "expand", TRUE, NULL);
  g_signal_connect (s2, "output", G_CALLBACK (cb_output), NULL);
  g_signal_connect (s2, "input", G_CALLBACK (cb_input), NULL);
  gtk_grid_attach (GTK_GRID (grid), s2, 1, 0, 1, 1);

  /* Use 2 adjustments: one in radians and one in degrees. GBinding
   * keeps values of those adjustments in sync */
  adj1 = gtk_adjustment_new (3.14, 0, 2 * G_PI, 0.1, 0.5, 0);
  s3 = gtk_spin_button_new (adj1, 0.5, 2);
  g_object_set (s3, "expand", TRUE, NULL);
  gtk_grid_attach (GTK_GRID (grid), s3, 0, 1, 1, 1);

  adj2 = gtk_adjustment_new (100, 0, 360, 1, 5, 0);
  s4 = gtk_spin_button_new (adj2, 0.5, 0);
  g_object_set (s4, "expand", TRUE, NULL);
  gtk_grid_attach (GTK_GRID (grid), s4, 1, 1, 1, 1);

  g_object_bind_property_full (adj1, "value", adj2, "value",
   G_BINDING_BIDIRECTIONAL |
   G_BINDING_SYNC_CREATE,
   rad_to_deg, deg_to_rad,
   NULL, NULL);

  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}

--8<---

Cheers,
Tadej


-- 
Tadej Borovšak
tadej.borov...@gmail.com
tadeb...@gmail.com
blog.borovsak.si

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Gdk PixbufAnimation supported formats

2013-04-18 Thread Tadej Borovšak
Hi.

2013/4/18 Kip Warner 
>
> I've tried looking through the Gtk+ source in gdk/* and gtk/*, but
> maybe I've just been looking in the wrong places. I also tried looking
> through what relevant documentation I could find on the Gdk's C API,
> and didn't manage to find what I needed. I'm guessing that perhaps this
> is because the actual loading is deferred to some other lower level
> external backend to Gdk, such as Cairo, but I'm speaking from
> ignorance.


Gtk+ uses gdk-pixbuf [1] library to load/store images. You can check
what image formats your library supports by calling
gdk-pixbuf-query-loaders [2] utility.

Cheers,
Tadej


[1] https://developer.gnome.org/gdk-pixbuf/stable/
[2] https://developer.gnome.org/gdk-pixbuf/stable/gdk-pixbuf-query-loaders.html

--
Tadej Borovšak
blog.borovsak.si
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: gtkrbtree core dump

2012-09-30 Thread Tadej Borovšak
Hi.

> I was wondering about that, but unfortunately my code does not explicitly 
> use any GtkTree* objects! Is there any way to search the documentation 
> efficiently to determine which object types are inheriting from 
> GtkTreeView? I have begun searching on my objects one by one (e.g., 
> GtkMenu, etc.), but I am not finding any that appear to inherit from 
> GtkTree*. Of course my app uses dozens of different object types and it 
> will be quite a chore to exhaustively search the documentation of each one 
> to examine its object hierarchy graph. I suspect that in the end I will 
> come up empty, as I have already looked at the objects I am using which, 
> by their appearance, look the most related to a GtkTreeView, e.g., menus, 
> file chooser dialogs, etc.

IF you want to see which widgets are derived from GtkTreeView, simply
open GtkTreeView API docs and check "Object Hierarchy" section. Direct
descendants will be listed here (if there are any). There is no "stock"
gtk widget that would be derived from GtkTreeView.

File chooser dialogs use GtkTreeView to display files/folders and as far
as I can tell from your description, this is the only place where tree
view is used in your app. Maybe file system changes cause tree view to
update itself in a bad way? (I'm mostly guessing here after a quick git
grep through sources.)

Cheers,
Tadej

-- 
Tadej Borovšak
tadej.borov...@gmail.com
tadeb...@gmail.com
tadeboro.blogspot.com

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: getting the icon pixbuf for a file

2012-08-16 Thread Tadej Borovšak
Hi.

> I am trying to get the icon bitmap for a file and insert it into a
> TreeView widget - That is the pixbuf for the mime-type of a file. Is
> there any examples of doing this in plain C using GTK/GLib?

I think you'll want gtk_widget_render_icon() function [1]. This will
use current theme settings to load proper icon and render it. For icon
names, you can consult gtk-demo application that features icon
browser.

Cheers,
Tadej


[1] http://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-render-icon

-- 
Tadej Borovšak
blog.borovsak.si
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GList strange behavior

2012-08-16 Thread Tadej Borovšak
Hi.

Not sure what is troubling you here. GList is represented by pointer
to first element or NULL if list is empty. And when you append items
to the list, the address of the list stays the same, since first
element of the list is unchanged (exception to this is when append
first element to an empty list).

Some code to explain some things:

GList *list = NULL /* Empty list */
list = g_list_append (list, GINT_TO_POINTER (1)); /* Add first
element, list points to some ADDR1 */
list = g_list_append (list, GINT_TO_POINTER (2)); /* Add second
element, list still points to ADDR1 */
...

Cheers,
Tadej

-- 
Tadej Borovšak
blog.borovsak.si
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: gtk-win32 crash when trying to move a GTK top level window

2012-07-29 Thread Tadej Borovšak
Hi.

> 1)  Launch any gtk-win32 app
> 2)  Right-click the application's title bar and select 'Move'
> 3)  Without clicking your mouse yet, move the mouse, then left-click it, 
> anywhere outside of the app
> 4)  Right-click the title bar again and your app will crash
>
> If this is still present in the latest version I can file a bug with some 
> more information

I tested these steps using latest stable Gimp on Windows 7 and could
not replicate the crash (unfortunately I don't know which version of
GTK+ Gimp installer packs). I also tested this using gtk-demo.exe app
from latest all-in-one bundle from gtk.org and still no crash. So it
looks like things have been fixed somewhere between 2.20 and 2.24.10?

Cheers,
Tadej

-- 
Tadej Borovšak
blog.borovsak.si
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GTK 3.0 inactive buttons (Buttons : maximize , minimize , close )

2012-06-21 Thread Tadej Borovšak
Hello.

> Hello How I can make the buttons   are inactive  ,  the buttons  of
> the window  (Buttons : maximize , minimize , close )  or without focus when
> the pointer  isover  them ? 
> 
> I need to get the effect .   Caso 2 . View image
> 
> 
> http://fotos.subefotos.com/607c3fb8e19de4ed18357b85a33b3ab5o.png

This is not something you could do with GTK+, since window decorations
are usually handled by window manager. What window manager (desktop) are
you using? Maybe it can be themed to behave this way?

Cheers,
Tadej


-- 
Tadej Borovšak
tadej.borov...@gmail.com
tadeb...@gmail.com
tadeboro.blogspot.com

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GtkDrawingArea size

2012-03-08 Thread Tadej Borovšak
Hello.

2012/3/7 Christopher Howard :
> Hello again. So, I recently started a project to create a certain board
> game (in C) using gtk+, and I just started learning gtk+. I was planning
> to draw the board graphics, pieces, etc. all into one GtkDrawingArea.
> So, how do I fix the size of the drawing area so it doesn't get larger
> or smaller than my graphics?

I would add a wrapper GtkAlignment around my drawing area, set it's
xalign and yalign propertes to 0.5, it's xscale and yscale to 0, pack
GtkDrawingArea inside it and fix it's size using
gtk_window_set_size_request().

Have a look at this simple app:

#include 

#define WIDTH  300
#define HEIGHT 400

static gboolean
cb_draw (GtkWidget  *w,
 GdkEventExpose *e)
{
  cairo_t *cr = gdk_cairo_create (e->window);
  cairo_set_source_rgb (cr, 1.0, 1.0, 0.0);
  cairo_paint (cr);
  cairo_destroy (cr);

  return TRUE;
}

int
main (intargc,
  char **argv)
{
  GtkWidget *window,
*align,
*area;

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect (window, "destroy", gtk_main_quit, NULL);

  align = gtk_alignment_new (0.5, 0.5, 0, 0);
  gtk_container_add (GTK_CONTAINER (window), align);

  area = gtk_drawing_area_new ();
  gtk_widget_set_size_request (area, WIDTH, HEIGHT);
  g_signal_connect (area, "expose-event", G_CALLBACK (cb_draw), NULL);
  gtk_container_add (GTK_CONTAINER (align), area);

  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}

Cheers,
Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Where is GStatBuf ?

2012-02-25 Thread Tadej Borovšak
Hi.

> Thanks Tadej.  I must admit, it's not in my copy or any copy I can find on 
> the internet (though admittedly, most of them look quite out of date).  Could 
> you post a link to the current repo please?

Here is the link to current head in git:
http://git.gnome.org/browse/glib/tree/glib/gstdio.h#n32

Quickly looking at the log revealed that it's been almost 2 years
since this file has been changed significantly for the last time, so
your version should have the same file.

BTW, on disk, this header is probably located under
/usr/include/glib-2.0/glib/gstdio.h

Cheers,
Tadej


-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Where is GStatBuf ?

2012-02-25 Thread Tadej Borovšak
Hello.

> 'GStatBuf' is supposed to be typedef'd somewhere to ensure that the correct 
> 'stat' struct gets used, depending on the compiler and platform - but I can't 
> find GStatBuf anywhere.

"git grep GStatBuf" says GStatBuf is defined in glib/gstdio.h

Cheers,
Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: "HELP/About" was :: [Re: suggestions on user config?]

2012-02-19 Thread Tadej Borovšak
Hi

>        the dialoh has a "Close" button in the lower right.  In the
>        lower left are two buttons.  one is labeled "Credits"; next
>        to it is a button labeled "License" that displays the GNU
>        copyright.  can somebody clue  me in on how to add the two
>        buttons  s on the lower left?

I don't have GNOME installed here, but my guess would be that you're
looking at the stock GtkAboutDialog, which is part of the GTK+.

Cheers,
Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: How does gtk display glyph with code in private use area?

2012-02-13 Thread Tadej Borovšak
Hi.

Not an expert in this area, but maybe you can get away by passing
codepoint of your glyph to g_unicode_to_utf8() and use the result in
your strings. If this doesn't work, you can still manually convert
010005 to UTF-8 and use that in your document. (I think codepoint
010005 converts to 4 bytes: 0xF0 0x90 0x80 0x85)

Cheers,
Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: window icon resolution

2012-02-08 Thread Tadej Borovšak
Hi.

> When I call gdk_pixbuf_new_from_file() to set a window icon, the resulting
> image in the Gnome Shell ALT+TAB switcher is fuzzy and clearly
> low-resolution.
>
> The window icon is a 128x128 pixel 24-bit PNG file. When I have the file
> displayed in another viewer (eog) and ALT+TAB, the Gnome Shell image is
> smaller than the full image in eog, but clearly fuzzier and lower
> resolution.
>
> Other applications such as Pidgin, Firefox, or Geany display clear,
> high-resolution icons.
>
> What am I doing wrong that other applications are doing right? I checked the
> Geany source and saw it had inlined the GdkPixbuf image and loaded it that
> way. Why would that make a difference?

Not an expert, but my guess would be that gnome-shell loads images on
it's own based on what is defined in your .desktop file when this file
is available. Do you install this file for your app?

Cheers,
Tadej


-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: gtk_tree_view_column_set_cell_data_func gives GTK-CRITICAL error

2011-11-30 Thread Tadej Borovšak
Hi.

2011/11/30 James Steward :
> col = gtk_tree_view_insert_column_with_attributes (
>                GTK_TREE_VIEW (view),
>                -1,
>                "Title",
>                renderer,
>                "text", i,
>                "strikethrough", j,
>                "background", k,
>                "background-set", TRUE,
>                NULL);
>
> gtk_tree_view_column_set_cell_data_func(
>                gtk_tree_view_get_column(GTK_TREE_VIEW(view), col),
>                renderer,
>                render_float,
>                GINT_TO_POINTER(i),
>                NULL);

IIRC, gtk_tree_view_insert_column_with_attributes() returns number of
columns and gtk_tree_view_get_column() expects to get column number
where first column is 0. So you may be off-by-one in your call to
gtk_tree_view_column_set_cell_data_func().

Cheers,
Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: IconView select_path "inactive" selection

2011-09-13 Thread Tadej Borovšak
Hi.

> using IconView select_path(...), how can I make it look like it was selected
> by clicking on it, i.e. not in that "inactive" grey color? [1]

Did you try using this:
http://developer.gnome.org/gtk/stable/GtkIconView.html#gtk-icon-view-set-cursor

Cheers,
Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Re: HScale don't move

2011-08-09 Thread Tadej Borovšak
Hi.

> I changed both page size and page increment to 0, and the slider moves.
> However, why I get an initial value of 0, instead of 5?

Make sure your value is defined after lower and upper, otherwise it
may be clamped to something unexpected.

BTW, what version of glade are you using? Recent versions produce
GtkAdjustment's properties in proper order.

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: HScale don't move

2011-08-08 Thread Tadej Borovšak
Hi.

> 
>    5
>    10
>    0.10001
>    10
>    10
>  

page-size property of GtkAdjustment should be set to 0 when not being
used with scrollbars. value property of GtkAdjustment is confined to
interval [lower, upper - page_size], which in your case is only single
value 0.

Cheers,
Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Window styles

2011-05-27 Thread Tadej Borovšak
Hi.

> Incidentally (sorry for the dumb questions but my background is mostly with 
> MFC) - is it possible to set a GTK+ window to be "always on top"?

See gtk_window_set_transient_for() function. I think it'll do what you
need to be done.

Cheers,
Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GSource object lifetime

2011-05-03 Thread Tadej Borovšak
Hi.

> That did help (I think I still have an unrelated leak). I think a few
> things could be made more clear in the docs (I'm not 100% sure I'm correct
> either):

I must agree with you here. Docs are a bit scarce on this topic. But ...

> -A newly created source (from g_idle_source_new() ) has a reference count
> of 1 not 0.
>
> -g_source_attach() increases the reference count by 1
>
> -returning FALSE in a source callback function detaches the source from
> the source's attached main context, and decreases the reference count by 1
>
> -Once a source has been detached by source callback function returning
> FALSE, it can not be reattached g_source_attach(). An assertion error is
> thrown. You can however, decrease the source's reference count down to 0 so
> it will free itself, then create a fresh source.

You got it exactly right. I would only add that you decrease reference
count right after attaching it to context (like Colomban already
suggested). This way memory used by source will be freed when detached
from context.


All that being said, maybe you could "cook up" a patch for API docs
with this info? I'm sure people would find it useful.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GSource object lifetime

2011-05-03 Thread Tadej Borovšak
Hi.

> I'm repetitively calling g_idle_source_new(), g_source_set_callback(),
> g_source_attach() to get an idle callback to run in a separate thread. The
> callback in question always exits with FALSE.

Do you call g_source_unref() after attaching it?

Cheers, Tadej.

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GOption & friends

2011-03-21 Thread Tadej Borovšak
Hello.

> Maybe those git pages are not searched by google? In fact I just
> randomly picked a (one line) literal text from the Changelog in git -
> and google didn't find it (did find two instances in mailing list
> copies, but not the one in git).
> 
> So, one of the most important sources for info isn't accessible to
> google it seems. (to be fair, bing.com doesn't find it either)

I usually use Google's Code Search (http://www.google.com/codesearch)
when hunting for example code.

Cheers,
Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

RE: GtkSwitch — lack of specific signal

2011-03-05 Thread Tadej Borovšak
Hello.

> I checked.   notify::active is not mentioned anywhere in any of those! (I 
> used my browser's find  -  can you find it mentioned somewhere?)
> Cheers,   John Lumby

Those two links were just examples that demonstrate how signal handler's
prototype can be obtained. Notify signal is part of GObject.

When searching for a signals that are relevant to particula widget, you
start by examining signals listed in widget's API docs, after those
signals you inspect signals of it's parent, ... (API docs for each
widget have a section named "Object Hierarchy" that lists relationships
of objects).

I would suggest that you install Devhelp and -doc packages of
GTK/GLib/Cairo to make your life a bit easier.

Cheers,
Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

RE: GtkSwitch — lack of specific signal

2011-03-04 Thread Tadej Borovšak
Hello.

> Thanks both. I tried notify::active and it works as well as event-after 
> but still the data pointer argument is bad on entry to the callback(it's not 
> zero but not a valid  GTK_WIDGET either). I don't know why  - maybe 
> something related to GtkSwitch or maybe a mistake in my code somewhere.
> Cheers,   John Lumby

Are you sure your functions has the right prototype? GObject::notify
signal handlers should have callbacks defined like this:

void
notify_callback (GObject*obj,
 GParamSpec *pspec,
 gpointer   *data)
{
  /* La la la */
}

Cheers,
Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Drawing area with different layers

2011-02-28 Thread Tadej Borovšak
Hello.

> I'm new to gtk programming so this might be a very dummy question.  I
> use a DrawingArea to draw a map with three layers: the background map,
> the legend window, and app data.  Since the legend layer does not
> change often, can I store it in a pixmap and simply copy it rather
> than redraw it every time the map and app data change?

I would suggest that you use cairo to do all of the drawing. Then you
can "store" your drawings onto cairo surface and paint it when needed.

Cheers,
Tadej


-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: g_spawn_async_with_pipes

2011-02-12 Thread Tadej Borovšak
Hi.

> Well yes, it is simpler.  And, you are correct, it is awkward.  I just
> had this vision of two g_spawn_async_with_pipes() hooked together.
> Running echo output &echo_out directly into lilypond's input &echo_out
> as if they "may" share &echo_out.  I will need to test/hack this.  I
> hate hacking.  I wish we had more examples here in linux land!
>
> I just thought it would be more efficient and quicker to send data
> directly to lilypond instead of a file location.

Since you're already using g_spawn_async_with_pipes(), why don't you
simply execute "/usr/bin/lilypond --output=scale.png -" and then feed
the lilyponds stdin through obtained file descriptor that g_spawn...()
gives you?

Cheers,
Tadej


-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Bring a widget to the foreground

2011-01-02 Thread Tadej Borovšak
Hi.

> I followed that link but it doesn't look as if it would work for a button.  
> I'd need to be able to get the button's label object (if there is one) but I 
> can't see an obvious way of getting it  :-(

How you'll get your hands on GtkLabel object inside button depends on
how your button has been constructed. The safest and simplest way of
doing this would be to manually add label to your button using code
like this:

/* *** CODE ***
button = gtk_button_new ();
label = gtk_label_new ("Label");
gtk_container_add (GTK_CONTAINER (button), label);
/* *** end CODE ***

If this approach is not right for your situation, you'll need to walk
the widget hierarchy in the button until you find your label.
Hierarchies as produced by different constructors are (I'm almost
certainly wrong here, but I'm sure someone will correct me):

gtk_button_new_with_label(): button->label
gtk_button_new_from_stock(): button->hbox->label
 `>image

Exact widget tree doesn't really matter, since it's relatively easy to
create code that recursively checks for GtkLabel.

Hope this helps a bit.

Tadej
-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GTK and color names

2010-12-04 Thread Tadej Borovšak
Hello.

I think gdk_color_parse() function is what you're looking for. But be
aware that this function will return 16-bit RGB components (not the
usual 8-bit ones).

Cheers,
Tadej


-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Widget name is 0x0 after GtkWidget key-press-event

2010-08-13 Thread Tadej Borovšak
Hi.

Your problems are caused by the fact that GtkBuilder since GTK+-2.20
doesn't set widget's "name" property to "id" field anymore. API
docs[1] warn about this change (see the first "Note" section in
description).

Tadej

[1] 
http://library.gnome.org/devel/gtk/stable/GtkBuilder.html#GtkBuilder.description

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GtkIconView remove item

2010-08-11 Thread Tadej Borovšak
Hi.

You need to remove the data from underlying model and your icon view
will get updated automatically.

Sample code that is capable of removing multiple items at a time would
look like this:
--
GtkIconView  *icon_view;
GtkListStore *store;
GList*elements,
 *iter;

/* Initialize icon_view here */

elements = gtk_icon_view_get_selected_items (icon_view);

/* Convert to row references for safe removal */
for (iter = elements; iter; iter = g_list_next (iter))
{
  GtkTreeRowReference *ref;
  GtkTreePath *path = (GtkTreePath *)iter->data;

  ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (store), path);
  gtk_tree_path_free (path);
  iter->data = ref;
}

/* Remove now */
for (iter = elements; iter; iter = g_list_next (iter))
{
  GtkTreeRowReference *ref = (GtkTreeRowReference *)iter->data;
  GtkTreePath *path;
  GtkTreeIter  remove_me;

  path = gtk_tree_row_reference_get_path (ref);
  gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &remove_me, path);
  gtk_tree_path_free (path);

  gtk_list_store_remove (store, &remove_me);
  gtk_tree_row_reference_free (ref);
}

g_list_free (elements);
-

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: How to work with a gpointer argument

2010-08-10 Thread Tadej Borovšak
Hi.

> void rip( GtkWidget *widget, GdkEvent *event, gpointer
> source_combo_box )

You're getting a segfault because GtkButton::clicked signal[1]  has
only 2 arguments: a GtkButton and user provided data. Your function
should be defined as:

void
rip (GtkWidget *button,
 gpointer source_combo_box)

Tadej


[1] http://library.gnome.org/devel/gtk/stable/GtkButton.html#GtkButton-clicked

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: how to read Gtk signal document ?

2010-08-10 Thread Tadej Borovšak
Hi.

> What is [1] you mentioned ?

Heh, I forgot to paste a link;)

 [1] 
http://library.gnome.org/devel/gobject/stable/gobject-Signals.html#GSignalFlags

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: how to read Gtk signal document ?

2010-08-09 Thread Tadej Borovšak
Hi.

For exact explanation, see [1]. You'll probably also want to read more
about GObject and signals after that;)

But for end user (programmer), knowing that signals in docs that are
marked as "Run first" will run default signal handler before any user
supplied one. "Run last" will run default signal handler after user
provided signal handlers. "Action" signals can be freely emitted from
your code and most of them have a wrapper function (for example,
gtk_button_clicked (button) is equivalent to g_signal_emit_by_name
(button, "clicked")).

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Question concerning forced expose-events

2010-08-04 Thread Tadej Borovšak
Hi.

Are you using threads in your application? Problems like this usually
arise when you don't initialize GLib/GDK thread subsystems.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GTK deadlock in gtk_main

2010-08-03 Thread Tadej Borovšak
Hi.

> So what you suggest is to have gdk_threads_enter and gdk_threads_leave at
> the beginning and at the end of the idle function?
>
> Is this really intended?

Yes, this is how things should be done. But for your convenience, GDK
provides a function that will wrap your idle callback in lock/unlock:
gdk_threads_add_idle().

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GTK deadlock in gtk_main

2010-08-03 Thread Tadej Borovšak
Hi.

You're having troubles because gtk_main_iteration_do() does it's own
unlock/lock cycle.

When your idle callback is executed, your mutex is unlocked.
gtk_main_iteration_do() "unlocks" it again, executes whatever is there
to be executed and locks it. Now control returns back to main loop,
which tries to lock mutex and here you have your lock.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: how to implement my own window decoration

2010-07-28 Thread Tadej Borovšak
Hi

Window decorations are currently managed by window manager. There is a
branch of GTK+ where decorations would be managed by application
itself (this is called client-side decorations).

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: image printing

2010-07-23 Thread Tadej Borovšak
Hi.

You need to unref your pixbuf only after it has been rendererd to
cairo context, since GList will not take ownership of it. Call
_unref() just after cairo_paint() call and you should be fine.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Screen resolution

2010-07-09 Thread Tadej Borovšak
Hi.

> Thanks Tadej.  I looked at gdk_window_get_origin() but it seems to return x 
> and y co-ordinates relative to the parent window.  What I'm trying to find 
> out is which monitor contains (or mostly contains) a given window.  Therefore 
> I need the screen co-ordinates.  I'll try get_frame_extents() and see what 
> happens.  I just found its library description and it looks promising.

From API docs about gdk_window_get_origin():
---
Obtains the position of a window in root window coordinates. (Compare
with gdk_window_get_position() and gdk_window_get_geometry() which
return the position of a window relative to its parent window.)
---

Did you test it and it gave some strange results?

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Screen resolution

2010-07-09 Thread Tadej Borovšak
Hi.

> Suppose I have two monitors, each of resolution 1024x768.  The monitors are 
> placed side-by-side to cover a total screen size of 2048x768.  I have a 
> GdkWindow of some description situated at co-ordinates 900 pixels (x) and 0 
> pixels (y).
>
> If the window is (say) 600x600 pixels, it's bounding rectangle should return 
> 900,0,600,600  Is gdk_window_get_frame_extents() the correct way to retrieve 
> this info?  I don't seem to be able to find much information about it.

I would probably use gdk_window_get_origin() and
gdk_drawable_get_size() to obtain the geometry of the window, since
_get_frame_extents() may include window manager decorations if they
are present.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Screen resolution

2010-07-09 Thread Tadej Borovšak
Hi.

> "Can I tell how many monitors span the screen horizontally and vertically?"
>
> I've found a function called get_screen_n_monitors() but if it returned (say) 
> 4 monitors, would it be possible to tell if they were in a 2x2 array or a 4x1 
> array?

You can get the layout of monitors by inspecting their geometry (x and
y coordinates).

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: liststore manipulation question

2010-07-08 Thread Tadej Borovšak
Hi.

You'll probably want to do something like this in your functions (replace my
data parameter with whatever you're using to get widget's inside callback):

static void
move_up (GtkButton *button,
 Data  *data)
{
  GtkTreeIter   current,
prev;
  GtkTreePath  *path;
  GtkTreeModel *model;

  if (!gtk_tree_selection_get_selected (data->sel, &model, ¤t))
return;

  path = gtk_tree_model_get_path (model, ¤t);
  if (gtk_tree_path_prev (path))
{
  gtk_tree_model_get_iter (model, &prev, path);

  /* Now current "points" to currently selected row and prev to row before.
   * Do number switch here now. */
}
  gtk_tree_path_free (path);
}

static void
move_down (GtkButton *button,
   Data  *data)
{
  GtkTreeIter   current,
next;
  GtkTreeModel *model;

  if (!gtk_tree_selection_get_selected (data->sel, &model, ¤t))
return;

  next = current;
  if (gtk_tree_model_iter_next (&next))
{
  /* Now current "points" to currently selected row and prev to row before.
   * Do number switch here now. */
}
}

Hopefully this will help you a bit.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: custom widgets - advice on where to start?

2010-07-07 Thread Tadej Borovšak
Hello.

I usually encapsulate my code into custom widgets when:
 - I need my widget in lots of places
 - I need my construct to emit signals

As long as code is small and relatively clean, I simply use
GtkDrawingArea and draw onto it from ::expose-event handler.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Treeview, different Cell-render per row

2010-07-06 Thread Tadej Borovšak
Hi.

> My other Idea was to make a new column for the GtkCellRendererToggle, and
> just show it when needed.
> Is it possible to hide a one of the renderer?

This is how I would do this. Just add one gboolean column to your data
store and connect it to cell renderer's "visible" property.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Treeview, start editing with any Key, not just Enter or space

2010-07-06 Thread Tadej Borovšak
Hello.

You'll probably need to connect to GtkWidget::key-press-event signal
and initiate editing from there using
gtk_tree_view_set_cursor_on_cell() function.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GTK/GDK equivalent to UpdateWindow() ?

2010-07-04 Thread Tadej Borovšak
Hi.

> But how/where do I acquire a pointer to the canvas's GdkWindow??

gtk_widget_get_window() function is probably what you're looking for.
Call this on your canvas and then force updates on it. I'm not sure
how this is called in gtkmm though, but I'm sure you'll be able to
find it.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Implementing my own ScrolledWindow

2010-07-04 Thread Tadej Borovšak
Hello.

> How can I make it not expand?

You cannot do that with GtkTable, since table will always grant all
the space GtkTextView requested. I see two possible solutions here:
write GtkScrolledWindow-like widget from scratch (with all the
scrollbar positioning, ...) or create simple wrapper widget that will
"underallocate" your text view and place that into a table. Second
solution is probably easier to implement, but first one is more
flexible.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: gtk_action_block_activate fails to block ?!?

2010-06-29 Thread Tadej Borovšak
Hi.

API docs state that this function is only intended to be called when
manually modifying state of action's proxy and this modification could
cause recursion. In reality, gtk_action_block_activate() simply causes
gtk_action_activate() function calls to be ignored.

There is no way to stop signal from being emitted when modifying
action directly. You'll need to block signal handlers that are
connected to this signal in order to avoid calling them. You may find
g_signal_handlers_block* family of functions useful here.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GdkDrawingArea on the GtkImage

2010-06-29 Thread Tadej Borovšak
Hello.

> How can i impose GdkDrawingArea on the GtkImage for painting on image
> for example?

Why don't you simply draw your image onto drawing area too? No need
for layered widgets here.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: using GdkPixbuf icons in GtkUIManager ?

2010-06-24 Thread Tadej Borovšak
Hello.

I think the simplest thing to do here would be to add your images to
icon theme (you can use inlined images, but it would probably be
better to shell them out now that you're updating application). After
this is done, you can refer to the images simply by their registered
name when defining GtkActions.

BTW, can you provide a link to one of the outdated files?

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: custom spin button format

2010-06-18 Thread Tadej Borovšak
Hello.

> Below is a minimal test program. I'd expect that, since the spin
> button's range is set as 1 to 4, I ought to be able to display
> "B", "C"  and "D" in turn by pressing the button's up-arrow. But
> what actually happens is that the first up-press gives "B" and
> then subsequent up-presses leave the displayed value at "B": I
> can't make it show "C" or "D". Can anyone tell me what I'm doing
> wrong? Thanks!

If you do anything fancy inside your GtkSpinButton::output signal
handler (this basically means that you set spin button to hold
non-numeric data like in your case), you need to also provide handler
for GtkSpinButton::input signal. Input signal is not properly
documented, but it's function is to take the contents of the spin
button and convert it to gdouble number.

I updated your sample code to show you how this fits together. API
docs will be updated soonish (I do have a patch, but it must wait
until docs are migrated from template files to sources).


#include 

gchar *n_to_alpha (int n)
{
   if (n == 1) {
   return g_strdup("A");
   } else if (n == 2) {
   return g_strdup("B");
   } else if (n == 3) {
   return g_strdup("C");
   } else if (n == 4) {
   return g_strdup("D");
   } else {
   return g_strdup("X");
   }
}

static gboolean
alpha_input (GtkSpinButton *spin,
 gdouble   *new_val,
 gpointer   p)
{
  gchar current;

  current = (gtk_entry_get_text (GTK_ENTRY (spin)))[0];
  *new_val = current - 'A' + 1;

  return TRUE;
}

gint alpha_output (GtkSpinButton *spin, gpointer p)
{
   gint n = gtk_spin_button_get_value_as_int(spin);
   gchar *s = n_to_alpha(n);

   printf("obs_button_output: %d -> '%s'\n", n, s);
   gtk_entry_set_text(GTK_ENTRY(spin), s);
   g_free(s);

   return TRUE; /* block the default output */
}

int main (int argc, char **argv)
{
   GtkWidget *w, *spinner;

   gtk_init(&argc, &argv);

   w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
   gtk_window_set_default_size(GTK_WINDOW(w), 100, -1);
   gtk_container_set_border_width(GTK_CONTAINER(w), 5);
   g_signal_connect(G_OBJECT(w), "destroy",
gtk_main_quit, NULL);

   spinner = gtk_spin_button_new_with_range(1, 4, 1);
   gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(spinner), FALSE);
   g_signal_connect(G_OBJECT(spinner), "input",
G_CALLBACK(alpha_input), NULL);
   g_signal_connect(G_OBJECT(spinner), "output",
G_CALLBACK(alpha_output), NULL);
   gtk_container_add(GTK_CONTAINER(w), spinner);

   gtk_widget_show_all(w);
   gtk_main();

   return 0;
}
-

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: gtk_window_fullscreen problem

2010-06-13 Thread Tadej Borovšak
Hi.

Try to keep mailing list in loop too. I'm redirecting this back again.

2010/6/14 Alexander Kuleshov :
> Yes.
>
> typedef struct _MainWin MainWin;
> typedef struct _MainWinClass MainWinClass;
>
> #define LOAD_BUFFER_SIZE 65536
>
> #define MAIN_WIN_TYPE            (main_win_get_type ())
> #define MAIN_WIN(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj),
> MAIN_WIN_TYPE, MainWin))
> #define MAIN_WIN_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),
> MAIN_WIN_TYPE, MainWinClass))
> #define IS_MAIN_WIN(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
> MAIN_WIN_TYPE))
> #define IS_MAIN_WIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
> MAIN_WIN_TYPE))
> #define MAIN_WIN_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),
> MAIN_WIN_TYPE, MainWinClass))
>
>
>
> typedef struct _MainWinClass
> {
>    GtkWindowClass parent_class;
> };
>
> typedef struct _MainWin
> {
>    GtkWindow parent;
>    GtkWidget* scroll;
>    GtkWidget* box;
>    GtkWidget *toolbar;
> };
>
> /* constructor */
> GtkWindow* main_win_new();
>
> gboolean main_win_open( MainWin* mw, const char* file_path);
>
> void main_win_show_error( MainWin* mw, const char* message);
>
> void main_win_close( MainWin* mw );
>
> GType main_win_get_type(void);
>
> void on_open( GtkWidget* btn, MainWin* mw );

You still haven't answered how yout type is registered with GType (you
need to show the contents of main_win_get_type() function or suitable
macro that provides it).

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: gtk_window_fullscreen problem

2010-06-13 Thread Tadej Borovšak
Hello.

> Where MainWin:
> typedef struct _MainWin MainWin;
>
> typedef struct _MainWin
> {
>    GtkWindow parent;
>    GtkWidget* scroll;
>    GtkWidget* box;
>    GtkWidget *toolbar;
>    gboolean full_screen;
> };

Looking at this piece of code, I would say that you're creating custom
widget, derived from GtkWindow. If this is true, then you're having
troubles because type of your widget is probably not properly
registered using GType. Are you using all of the standard boilerplate
code for GObject?

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GNOME images not displaying

2010-06-13 Thread Tadej Borovšak
Hello.

Looks like I need to write a blog post or something about icon
handling in GTK+, since this topic has been quite (un)popular both on
mailing lists and IRC ;-)

To make things short, "gnome-stock-trash" is not a stock icon, it's a
named icon that comes from user selected theme and in order to be able
to display it properly, this line in your UI description:

gnome-stock-trash

should be edited to become this:

gnome-stock-trash

This will probably fix your issue here (I haven't tested this).


For more info about themed and stock icons, see this discussion: Part
1[1], Part 2[2].

Tadej


[1] http://mail.gnome.org/archives/gtk-list/2010-May/msg00135.html
[2] http://mail.gnome.org/archives/gtk-list/2010-June/msg00012.html

-- 
Tadej Borovšak
00386 (0)40 613 131
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Translating co-ordinates from local to screen space

2010-06-11 Thread Tadej Borovšak
Hello.

> I'm trying to translate co-ordinates from local widget space into screen
> space and back again. Is that possible with GTK?

gdk_window_get_root_coords() or gdk_window_get_origin() will be of
interest in this situation.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: How to get a widget from its parent of parent(...) by name?

2010-06-09 Thread Tadej Borovšak
Hello.

> Thank you, I'm sorry for that I didn't explain the problem clearer. What I
> meant is that there is no similar function of
> 'glade_get_widget_tree(widget)'. At the context where should call
> gtk_builder_get_object(), there is no 'GtkBuilder* builder' available. In
> the previous code, we can call 'glade_get_widget_tree(widget)' to get the
> GladeXml object of the given 'widget'. However, I don't know how to do it in
> GtkBuilder?
>
> If I can get the GtkBuilder object from 'assistant', then I can call
> gtk_builder_get_object() to get the widget by its id. If I cannot get it,
> then how to get the widget by id from the top level widget? Thanks.

I'm afraid that there is no equivalent for that in GtkBuilder (objects
that are constructed by builder don't carry any information about who
constructed them). You'll need to pass your builder object around
manually (g_object_set_data() would be one option, global variable
second, struct that is passed to all of the functions would be third,
...).

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: how to control aspect ratio of a child widget using gtk_window_set_geometry_hints

2010-06-03 Thread Tadej Borovšak
Hi.

> How can I control the aspect ratio of a child which is a
> GtkDrawingArea?  I've tried

Use GtkAspectFrame as parent of drawing area.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: 1-Bit Bitmap

2010-05-31 Thread Tadej Borovšak
Hello.

> I'm looking to create an application that requires using 1-bit bitmaps
> to store a monochrome printing pattern. But I've looked at both Pixmaps
> and Pixbufs, but Pixbufs doesn't offer direct access to the bits (I need
> to set and read them) and Pixmaps doesn't support 1-Bit pixels (at least
> that's what I understand from my reading of the docs).
> Any suggestions?

cairo_image_surface_t can have a depth of one bit (CAIRO_FORMAT_A1)
and offers direct access to pixel values.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GtkProgressBar state update issue

2010-05-28 Thread Tadej Borovšak
Hi.

> The gtk_progress_bar_set_fraction() is called by a separate thread.

This is probably the main cause of your troubles. Try reading this
blogpost for some info on how to use GTK+ from multiple threads:
http://tadeboro.blogspot.com/2009/06/multi-threaded-gtk-applications.html
(I'm sorry for the self-promotion).

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Focus of about dialog

2010-05-26 Thread Tadej Borovšak
Hello.

> I've added an about dialog to my gtk application, using GtkAboutDialog.
> However, when the dialog is displayed, the user can still switch to the
> main window, which is undesirable. The dialog should steal focus of the
> whole application. How can I do that ? I have looked at
> gtk_widget_set_parent_window () but couldn't get it to work.

Have a look at gtk_window_set_modal() and
gtk_window_set_transient_for() functions.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: gtk_tree_view_scroll_to_cell() not scrolling

2010-05-16 Thread Tadej Borovšak
Hi.

> I guess the problem is related to the fact, that the tree_view is inside
> a GtkScrolledWindow (to precise: inside a GtkViewPort, which is inside
> the GtkScrolledWindow). What's necessary to get the scrolling to work
> here? Do you need the code?

GtkTreeView has native scrolling ability and should be added to
GtkScrolledWindow directly using gtk_container_add() (no viewport
should be added between the two).

Tadej


-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Setting the font for Gtk::Button

2010-05-06 Thread Tadej Borovšak
Hi.

> I would try gtk_bin_get_child(), since it is a subclass of GtkBin.
>
> http://library.gnome.org/devel/gtk/stable/GtkBin.html#gtk-bin-get-child

What is packed into button depends on how the button was constructed.
If you only set it's label, then GtkLabel will indeed be the child; in
any other situation (if the image has been set alongside label for
example) gtk_bin_get_child() will return container that holds various
pieces together.

My advice to you would be to create label manually and then simply
pack it into empty GtkButton using gtk_container_add().

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: how to get the parent of a selected row in treeview?

2010-04-26 Thread Tadej Borovšak
Hi.

You can obtain parent iter like this:
 1a. converting GtkTreeIter that you got from
gtk_tree_view_selection_get_selected() into GtkTreePath using
gtk_tree_model_get_path()
 1b. get selected path directly using
gtk_tree_view_selection_get_selected_rows()
 2. get parent path using gtk_tree_path_up()
 3. convert path back to iter using gtk_tree_model_get_iter()

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Default values for spin buttons in Glade

2010-04-26 Thread Tadej Borovšak
Hi.

> Is there a way to set the default value without an adjustment? The only other 
> solution I can think of is to create the adjustment in code and then apply it 
> to the spin button at runtime.

You can use latest released version of glade (I think it's 3.7) or git
master. Both have this issue fixed, but you'll need GTK+ >= 2.20 for
it to work.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: gtk_list_store from XML UI not storing strings

2010-04-25 Thread Tadej Borovšak
Hi,

Why are you using '%x' format specifier in print statement to print
strings? Try replacing %x with %s and I'm almost sure things will work
out just fine.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Puzzling behavior when passing user data to callback from Glade

2010-04-25 Thread Tadej Borovšak
Hello.

> How come the userdata is passed in as the first argument, while the button 
> widget itself is passed in as the second arguement?

When the data field is not empty in Glade, signal is connected like
you would call g_signal_connect_swapped() macro in C code. This was
probably done from convenience reasons. For example, you can connect
gtk_widget_hide() function to GtkButton::clicked signal, pass some
some toplevel as user data and you have hiding working with no
additional code.

In latest git version, Tristan overhauled signal dialog and things are
much clearer now. See his blog post for some screenshots[1].

Tadej


[1] 
http://blogs.gnome.org/tvb/2010/03/30/one-week-of-glade-brought-to-you-by-openismus-gmbh/

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: what do i get if a cell is empty?

2010-04-24 Thread Tadej Borovšak
Hello.

You get NULL pointer. To test for it, you should do something like:

if( s == NULL )
{
/* Handle empty string */
}

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Zoom/magnification of images in GDK

2010-04-21 Thread Tadej Borovšak
Hello

> Now, I know how I could do this if I used gtkglext to get OpenGL in the 
> picture, so I could throw the image into a texture and then render it at an 
> arbitrary size. But I was wondering if there were any options built into 
> GTK/GDK which would allow me to avoid the extra dependency?

There are three options that I can remember now:
1. Convert your gray pixels into GdkPixbuf and then scale it using
gdk_pixbuf_scale() to proper size, then draw it.
2. Convert your gray pixels into GdkPixbuf and then scale it using
cairo directly when drawing.
3. Convert your gray pixels into CairoImageSurface and then scale it
using cairo directly when drawing.

Those three methods won't require you to add any additional
dependencies, since everything listed above is part of the standard
GTK+ installation.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: how to remove the contents of vbox?

2010-04-19 Thread Tadej Borovšak
Hello.

> hello, I got this func: static void (GtkWidget *vbox) {...}, when passed in
> an vbox, it should insert a GtkWidget *scrolled_window into the vbox, but I
> want to clear the contents of vbox first,otherwise the old contents will be
> displayed as well as the newly inserted widget. I am wondering how to
> implement this.Any tips will be appreciated.

Just call gtk_widget_destroy() on previously inserted scrolled window.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: How to create custom keyboard shortcuts for GTKTreeView?

2010-04-17 Thread Tadej Borovšak
Hello.

2010/4/17 Jez :
> Oh, I had the impression that the move-cursor signal was emitted by
> the TreeView when the cursor was moved. I didn't know it was the other
> way around. I've already managed to get it working after reading your
> earlier email, but I might rewrite it with this when I have the time.
> Thanks for the pointer!

The signal that is emitted when cursor moves is
GtkTreeView::cursor-changed. GtkTreeView::move-cursor is action signal
that can be safely emitted by application.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: How to create custom keyboard shortcuts for GTKTreeView?

2010-04-17 Thread Tadej Borovšak
Hi.

> Nonetheless, it feels a bit unnatural to replicate in my code behavior
> that's already available in GtkTreeView, just so I can remap the
> keys.. but whatever works, I guess (:

Alternatively, you can also emit GtkTreeView::move-cursor signal with
proper arguments, but getting them right is a bit tricky, since no
documentation exists.

Sample code would look something like this:
---
gboolean result;
g_signal_emit_by_name( treeview, "move-cursor",
   GTK_MOVEMENT_DISPLAY_LINES, 1, &result );
---
Third parameter is GtkMovementStep, but not all elements of enum are valid in
this context. You should only use:
 1. GTK_MOVEMENT_LOGICAL_POSITIONS -> move horizontally in the selected row
 2. GTK_MOVEMENT_VISUAL_POSITIONS -> same as above (for now at least;)
 3. GTK_MOVEMENT_DISPLAY_LINES -> move up or down lines
 4. GTK_MOVEMENT_PAGES -> move up or down pages
 5. GTK_MOVEMENT_BUFFER_ENDS -> move to beginning or end

Fourth parameter controls direction of movement:
 - for 1 and 2, 1 means move to the right, anything else means move to
the left (rtl languages have this mirrored)
 - for 3, -1 means move up, anything else means move down
 - for 4, this number is used as number of pages to move (-3 means
move three pages up, 2 means move two pages down)
 - for 5, -1 means go to start, anything else means go to end

Note that this is not 100% sure, since I obtained this knowledge using
grep, but I think you should be able to start experimenting.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: How to create custom keyboard shortcuts for GTKTreeView?

2010-04-17 Thread Tadej Borovšak
Hello.

Actually, things are not as contorted as you depicted here. For
example, if you would hit the last node at path 2:3:2 (3rd root
element, 4th element on level 1 and 3rd element on level 2),
gtk_tree_model_iter_next() will return FALSE, which means that you
need to get one level up. Getting one level up is as simple as calling
gtk_tree_model_iter_parent() (this will give you node at path 2:3) and
getting next iter on second level is again simple call to
gtk_tree_model_iter_next() (and you get to the path 2:4).

Should move to path 2:4:1 or to 2:5 on next move? It depends on what
gtk_tree_view_row_expanded() function returns. (BTW, is this the API
call you were missing?) In any case, things are again accomplished by
simple call to gtk_tree_model_iter_children() for move to 2:4:1 or
gtk_tree_model_iter_next() for move to 2:5.

This mechanism can be implemented wit just a few simple if clauses in
code that handles movement. You'll need to do some GtkTreeIter <->
GtkTreePath conversions in order to get everything working, but apart
from that, things should be relatively easy.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Hover decorations in GtkIconView

2010-03-26 Thread Tadej Borovšak
Hi.

I don't think items in icon view can be in prelit state. They are
either selected or not. You'll probably need to create custom icon
view widget to get on-hover effect.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: What version do I have

2010-03-15 Thread Tadej Borovšak
Hello.

"pkg-config --modversion gtk+-2.0" will give you version of the installed GTK+.

Tadej


-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Bug inside GtkBuilder w/ GtkAdjustment

2010-02-28 Thread Tadej Borovšak
Hello

> Today working with glade, I noticed a strange behaviour while working
> with GtkAdjustment.
>
> import gtk
>
> str_gui = """
> 
> 
>  
>  
>  
>    10
>    1
>    100
>    1
>  
> 
> """
>
> builder = gtk.Builder()
> builder.add_from_string(str_gui)
> print builder.get_object('foo').get_value()
>
> The output is 0.0 and not 10 as espected. Is this something already known?

This is a known problem and I think it is already fixed in git master.
Basically, I boils down to the fact that properties need to be
specified in right order for GtkBuilder to work properly. See this bug
report for more info:
https://bugzilla.gnome.org/show_bug.cgi?id=594372

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: putting combobox in toolbar

2010-02-23 Thread Tadej Borovšak
Hello.

Don't use GtkToolButton for this purpose, use it's parent,
GtkToolItem[1] directly and pack combo box inside it.

Tadej


[1] http://library.gnome.org/devel/gtk/stable/GtkToolItem.html

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: g_spawn_async_with_pipes on windows

2010-02-10 Thread Tadej Borovšak
Hi

> Does anyone have a clue how this is supposed to work? The documentaion
> has a lot of references to win32, so I guess this is supposed to work !?

As far as I can remember, spawning functions on windows need a helper
executable that is distributed along with glib (I don't remember the
exact name right now, but it's something along the
gspawn-win32-helper.exe). Is this helper application reachable when
executing your application?

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GtkAttachOptions usage!!

2010-02-05 Thread Tadej Borovšak
Hi.

Again, this is really annoying. I'm having 3 exactly the same
messages, caused by your cross-posting. Please, stop doing that.

Tadej


-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: gtk_table_attach api, GtkAttachOptions usage

2010-02-05 Thread Tadej Borovšak
Hello.

First of all, cross-posting is bad and tends to annoy people. Stick to
your original post.

> Iam trying to use gtk_table_attach api. I have issues using
> xoptions(GtkAttachOptions) and yoptions in this api.
> Iam not able to understand how I can use EXPAND, SHRINK and FILL options.
> I tried to write a program that does the following:
>
> 1. create a table using gtk_table_new api
> 2. Attach a button to the table using gtk_table_attach api with this expand
> option
> 3. Then resized the table.
>
> Iam expecting the button be resized in the window since the table is
> re-sized.
> Can you please provide me a input on how the GtkAttachOptions  be used from
> the application point of view.

GtkAttachOptions is enumeration of bitfield flags. These flags can be
added together using bitwise or. And as David already said, you
probably missed GTK_FILL flag in your gtk_table_attach() call.

For example, this call:

gtk_table_attach( table, child, 0, 1, 0, 1,
  GTK_FILL | GTK_EXPAND, GTK_EXPAND, 0, 0 );

will cause widget to expand horizontally when table is resized.
Vertically, widget will stay of the same size, only distance to other
widgets will increase.

Tadej


-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: ComboBox submenus

2010-01-19 Thread Tadej Borovšak
Hello.

> 1) Submenus should look the same in ComboBox and Popup menus.  Therefore
> Main 1 and Main 2 (see working example or tree store below) should not
> appear repeated again in the submenus. Even if they were there, they should
> not be selectable as they are only entry points to submenus. The workaround
> I know is: when users select Main 1 or Main 2, just select a sensible
> default instead, such as the first main item, the last chosen item, the
> first item in the submenu.

I'm only commenting about this point, since I reported a bug[1] on
this behavior not long ago. I proposed an additional property that
would control toplevel copying, but Matthias Clasen pointed out that
this can be achieved by using cell data function as shown in gtk-demo
application.

Tadej

[1] https://bugzilla.gnome.org/show_bug.cgi?id=604868

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: bitmap in button doesn't appear in 64bit 9.10

2010-01-19 Thread Tadej Borovšak
Hello.

> The following code works great in 32 bit and 64bit <= 9.04, but no bitmap
> appears when I run in 64bit 9.10.
>
>    Gtk::Image* img = NULL;
>    if (btnImageName.length() > 0)
>    {
>        cppstring path = GUtils::OSGetIconFolder() + btnImageName + L".png";
>        img = new
> Gtk::Image(GTextUtils::ConvertUTF16WideStringToUTF8String(path));
>    }
>
>    Gtk::Button* btn = new Gtk::Button;
>    if (img != NULL)
>    {
>        btn->set_image(*img);
>        btn->set_image_position(Gtk::POS_LEFT);
>    }
>    btn->set_alignment(0.0, 0.5);
>    btn->signal_clicked().connect(sigc::bind(sigc::mem_fun(this,
> &LXLiveReadoutManager::ToggleSourceWindow), sourceID));
>    m_ButtonMap[sourceID] = btn;
>    m_ButtonBox->add(*btn);
>
>    m_ButtonBox->show_all();

I think this is Ubuntu's "fault". They decided to reduce visual
clutter and trim images from menu items, buttons, etc. by default.
User can change this by setting "gtk-button-images" and
"gtk-menu-images" GtkSettings to TRUE, but I cannot help you with GUI
tools, since I don't use Ubuntu or GNOME.

Tadej


-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Nobody ever used GTK_STOCK_FILE?

2010-01-12 Thread Tadej Borovšak
Hello.

> How they are expected to be used when they cannot be found by
> gtk_stock_lookup?
>
> Should not be added at least
>  { GTK_STOCK_FILE, NC_("Stock label", "_File"), 0, 0, GETTEXT_PACKAGE },
> and maybe also
>  { GTK_STOCK_DIRECTORY, NC_("Stock label", "Folder"), 0, 0, GETTEXT_PACKAGE
> },
> ?

As far as I can understand this, some stock icons are not meant to be
used as items. For example, having "File" stock item doesn't make much
sense, since files usually carry their own name and this is what
should be displayed. Another example are DND icons. I really cannot
imagine situation where menu item with DND stock icon would make
sense.

BTW, I'm not the one who decides what becomes item and what not.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: progress popup and flushing events

2010-01-09 Thread Tadej Borovšak
Hello.

> I'm trying to display a popup status window while my application does a
> search. It works, but only appears after the search is done because I'm not
> flushing the requests and processing the events. What is the right way to do
> that in GTK?

It would probably be best to do searching in separate thread and only
queue updates of your GUI using g_idle_add() function.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: how to catch window manager close

2010-01-08 Thread Tadej Borovšak
Hello.

When window is asked to be closed by window manager, it'll will
receive "delete-event" signal. If you wish to prevent your window to
be destroyed, simply return TRUE from this function, which will
prevent default handler destroying your window.

There is also a utility function that will hide window for you:
gtk_widget_hide_on_delete()[1].

Tadej


[1] 
http://library.gnome.org/devel/gtk/stable/GtkWidget.html#gtk-widget-hide-on-delete

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GTK Action Handler

2009-12-31 Thread Tadej Borovšak
Hello.

> When the button or expander is clicked with the mouse the callbacks work
> fine.  The problem is from the menu the "activate" signal has GtkAction
> as the first parameter of the callback and I don't think that can be
> cast to a GtkButton or GtkExpander.  I want to call the button and
> expander callbacks as if they were clicked with the mouse.

You can get hold of the proxy widget of the action by calling
gtk_action_get_proxies(). After you obtain the needed widget, you cna
call callback function like it would be called by GTK+ itself.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GTK Action Handler

2009-12-31 Thread Tadej Borovšak
Hello.

Callback prototype for "activate" signal is: void callback( GtkAction
*action, gpointer data );

When widget that proxies specific action is activated, it calls
gtk_action_activate() function which emits "activate" signal.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Problem with table

2009-12-29 Thread Tadej Borovšak
Hello.

I just answered your query here:
http://gtkforums.com/viewtopic.php?p=12741#12741

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GtkTreeView auto selecting row

2009-12-16 Thread Tadej Borovšak
Hello.

Just call gtk_tree_selection_select_iter/path() and you should be good.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Storing images in GtkTreeView model

2009-12-16 Thread Tadej Borovšak
Hello.

> /lhs_store=gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_PIXBUF); //2 cols, 1st
> is string, 2nd is icon/

Store creation should be done like this:

lhs_store = gtk_list_store_new( 2, G_TYPE_STRING, GDK_TYPE_PIXBUF );

Hint: For most of GTK+/GDK types, you can get tybe by this simple convention:
GtkWidget -> GTK_TYPE_WIDGET
GdkPixbuf -> GDK_TYPE_PIXBUF
...

> /gtk_list_store_set(lhs_store,&lhs_treeiter,0,"Subscribers",-1); //put
> string in col0/

To store pixbuf in second column, do something like this:
gtk_list_store_set( lhs_store, &lhs_treeiter, 0, "Subscribers", 1, pixbuf, -1 );

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: how to browse values from a GtkListStore ?

2009-11-15 Thread Tadej Borovšak
Hello.

> Ok, here a sample of code used :
>
> GtkListStore *list;
> GtkTreeIter iter;
>
> funct3(GtkListStore *list)
> {
>    gtk_list_store_append(list, &iter);
>    gtk_list_store_set(list, &iter, 0,"apple", -1);
> }
>
> funct2()
> {
>    funct3(list);
>    // I would like to return some value here.
> }
>
> funct1()
> {
>    list = gtk_list_store_new(1, G_TYPE_STRING);
>    // CellRenderer code here
> }

This is all I need. To retrieve string from store, simply use
something like this:
 CODE 
gchar *string;
gtk_tree_model_get( GTK_TREE_MODEL( store ), &iter, 0, &string, -1 );
/* Do something with string here */
g_free( string );
 CODE 

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: how to browse values from a GtkListStore ?

2009-11-15 Thread Tadej Borovšak
Hello.

> Sorry this written in multiple separate functions, I can't paste it easily.
> There is no gtk function that do that ?? We can set values in the store but we
> can't get !

I don't need your functions in their entirety. What I need to know in
order to help you is how did you create your list store (just paste a
single line of code that uses gtk_list_store_new function) and one
sample call that adds data to store (again, all I need is a single
sample line with gtk_list_store_set function call). Without this
information, I cannot offer you more detailed help.

And thinking about your problem again, you may also be interested in
this tutorial: http://scentric.net/tutorial/sec-treemodels.html, since
I feel like you don't know exactly how GtkTreeIter, GtkTreePath and
various stores fit together.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: how to browse values from a GtkListStore ?

2009-11-15 Thread Tadej Borovšak
Hello

> How to return string "orange" at iter ?

This depends on how you GtkListStore has been created and how those
strings have been added into the store. In order for to be able to
help you, you'll need to provide gtk_list_store_new function call you
used to create new store and gtk_list_store_set call that added
strings into the store.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: how to browse values from a GtkListStore ?

2009-11-15 Thread Tadej Borovšak
Hello.

>> Is possible to browse them with an index ?
>
> What is an index?
>
> You can use gtk_tree_mogel_get_iter() to get an iter corresponding to
> given position in the tree (as represented by GtkTreePath).
>
> You can iterate using gtk_tree_iter_first()/gtk_tree_iter_next().

If index is mean as a row number, than you can directly access it
using a code like this:

 CODE 
GtkTreePath *path;
GtkTreeIter iter;

path = gtk_tree_path_new_from_indices( index, -1 );
gtk_tree_model_get_iter( model, &iter, path );
gtk_tree_path_free( path );
---- CODE 

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: code work wrong when i put it in gtk+ application

2009-11-12 Thread Tadej Borovšak
Hello.

What about using g_ascii_* family of functions to do C locale
compliant conversion. g_ascii_strtod seems to be the function you
could use.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: gdk_pixbuf_composite leaves artifacts in the dest pixbuf, if, dest_x is > 0. Help please?

2009-11-11 Thread Tadej Borovšak
Hello.

Composing function is a bit hard to use at first. Your code should
probably look something like this (I haven't tested it).

 CODE 
gchar *imgSrcName;
GdkPixbuf *src, *interm, *result;
guint width, height, xOffset, yOffset;
int i = 0;
...
src = gdk_pixbuf_load_from_file_at_scale( imgSrcName, 128, 128, TRUE, NULL );
result = gdk_pixbuf_new( GDK_COLORSPACE_RGB, TRUE,
gdk_pixbuf_get_bits_per_sample( src ), 128, 128 );

interm = gdk_pixbuf_apply_embedded_orientation( src );
gdk_pixbuf_unref( src );
width = gdk_pixbuf_get_width( interm );
height = gdk_pixbuf_get_height( interm );
...
while ( i < 2 )
{
   gchar *save;

   gdk_pixbuf_fill( result, 0xff00 );
   xOffset = i++ * ( 128 - width ) / 2;
   yOffset = i++ * ( 128 - height ) / 2;
   gdk_pixbuf_composite( interm, result, xOffset, yOffset, width,
height, xOffset, yOffset, 1.0, 1.0, GDK_INTERP_NEAREST, 255 );

   save = g_strdup_printf( "test%d.jpg", i );
   gdk_pixbuf_save( result, save, "jpeg", NULL, "quality", "100", NULL );
   g_free( save );
}
gdk_pixbuf_unref( interm );
gdk_pixbuf_unref( result );
 CODE 

BTW, gdk_pixbuf_unref is deprecated in favor of g_object_unref, since
GdkPixbuf is derived from GObject now.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: gobject ref and unref ?

2009-11-10 Thread Tadej Borovšak
Hello.

> Is there any documentation available for it ? as to when to ref and
> unref it based upon the api's ?

You don't need to know those things, since object's total reference
count is of no importance to you. All you need to do is keep track of
your own references on an object. Let me explain this based on your
example.

When you create new store for GtkTreeView (be it GtkListStore or
GtkTreeStore), you get an object that has a reference count of 1 and
this reference is owned by you and is the only thing that is keeping
you newly created object "alive". Now you add this store to the
GtkTreeView, which is from now "co-owner" of the store. I
intentionally co-owner in last sentence, because you don't need to
know what exactly GtkTreeView does to claim ownership (it can add 1, 2
or 10 references if it needs to). If you don't need created store for
anything else, you can now remove your own reference from it, which
essentially makes GtkTreeView the only "owner" of the store.

You can see that no explicit reference counting wizardry is needed to
properly count references. Just make sure your own references are
removed when you don't need an object to stick around.

Tadej


-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GtkTreeView: g_signal_handlers_unblock_by_func

2009-10-31 Thread Tadej Borovšak
Hello.

> Essentially adding a simple store model:
>
> store = gtk_list_store_new (1, G_TYPE_STRING);
> while (foo_bar != NULL)
>  {
>  gtk_list_store_append (store, &iter);
>  gtk_list_store_set (store, &iter, 0, my_name, -1);
>  }
> gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), GTK_TREE_MODEL (store));
> g_object_unref (store);
>
> I need to block before and unblock in the end because treeview is connected
> to this signal:
>
> g_signal_connect (treeview, "cursor-changed",
> G_CALLBACK (update_model), window);
>
> Everytime a user clicks on a row, "cursor-changed" is triggered,
> update_model is called, and a new model replaces the previous one. It
> happens that this model change triggers again the "cursor-changed" signal,
> so to prevent "cursor-changed" from calling again update_model, I have to
> block the signal before I change the store model. The issue here is the
> signal must be unblocked again only at the very end. What happens now is,
> the signal is unblocked at the end, but GTK still calls update_model AFTER
> that... the timer solves the issue, because it forces GTK to clean all his
> stuff before calling the timer... in fact this works even with the delay set
> to zero...

My assumptions were correct. The thing that is causing you troubles
here is GtkTreeView's internally installed idle callbacks that update
the tree view after the function that caused the changes returns. I'm
afraid that there is no other way around it but to use g_idle_add.
Idle callbacks that are installed by GtkTreeView have quite high
priority, so your installed timeout/idle handlers will be called after
the ones GtkTreeView installed.

Tadej


-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GtkTreeView: g_signal_handlers_unblock_by_func

2009-10-31 Thread Tadej Borovšak
Hello.

Only situation that comes to my mind that would cause
g_signal_handlers_block_by_func to misbehave is if you do something
inside blocked part of code that installs idle handler to do the real
work. What are you doing inside "do_stuff" part?

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: How to suppress text on GtkCellRendererToggle

2009-09-24 Thread Tadej Borovšak
Hi.

I'm returning this back to the mailing list.

> Hmm. OK, going through gtk_tree_view_insert_column_with_attributes works
> for me, too. So there's something about the sequence of calls generating
> this other column that creates this behavior.
>
> This is part of a large GUI project so it goes through a utility
> function in our library.
>
> OK, I feel stupid now. The library function is adding a text renderer
> and then adding the renderer I specified rather than replacing it. I
> gather you can have multiple renderers in a column?

Sure you can. GtkTreeViewColumn implements GtkCellLayout interface,
which enables you to pack more than one cell renderer.

> So what I need to do is delete the text renderer somehow and leave the
> toggle renderer.

Looking at the API reference, there is no function to remove specific
cell renderer from cell layout. You can empty it using
gtk_cell_layout_clear, but this is the only thing I could find. Maybe
you can clear the column before adding your cell renderer?

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

  1   2   >