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: Issue with linking.

2014-06-09 Thread Tadej Borovšak
Hi!

Dne 09.06.2014 (pon) ob 19:26 -0500 je Bill Brown napisal(a):
 Hello Gtk users / devs:
 
 
 I've got a program that compiles against gtk3 but fails to link.  The
 error I get is. 
 
 
 [ERROR] /usr/bin/ld: /home/bill//container.o: undefined reference to
 symbol 'gtk_window_get_default_widget'
 [ERROR] /usr/lib/libgtk-3.so.0: error adding symbols: DSO missing from
 command line

How are you compiling your program? This error is usually caused by
listing libraries before yur objects on linker command line.

Proper way of compiling GTK+ applications would be something like this:

  gcc -o app obj1.o obj2.o $(pkg-config --libs gtk-3.0)

Cheers,
Tadej

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

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


Re: calls of g_slice_new in different threads return the same address?

2014-03-11 Thread Tadej Borovšak
Hello.

Dne 11.03.2014 (tor) ob 19:15 +0800 je sunxiaobin napisal(a):
  Hi,
  I am using  g_slice_new to alloc some memory in my work, and it seems that 
 sometimes same 
  address would be returned if g_slice_new in different threads are called at 
 the same time,  I'm  
  wondering if anyone has ever encountered this problem? or it's already a 
 known bug?  because
  i am using the glib2-2.12.3, it's really a bit old now.
 
  i write a test program to create three threads to keep alloc and free mems 
 using g_slice_new and 
  g_slice_free respectively,  i will put the allocated mem in a hash table, so 
 everytime after calls to 
  g_slice_new, i check if it's in the hash table , and it turns out that it 
 does happen. and if i setG_SLICE=always_malloc  before i run the test 
 program, there will be no problem.  any advice will
  be appreciated.
 
  Attached is my test program, i copy some codes from ghash.c so that it can 
 be compiled only with 
  gcc -o gslice_test gslice_test.c -lglib-2.0 -I/usr/include/glib-2.0/ 
 -I/usr/lib64/glib-2.0/include/ -pthread -g
 
  Here is my enviroment:
  os:  Linux 183 2.6.18-128.el5 #1 SMP Wed Jan 21 10:41:14 EST 2009 x86_64 
 x86_64 x86_64 GNU/Linux
   (old enough too)
  glib version: 
   glib2-debuginfo-2.12.3-2.el5.centos
   glib2-2.12.3-2.fc6
   glib2-2.12.3-2.fc6
   glib2-devel-2.12.3-2.fc6
   glib2-devel-2.12.3-2.fc6
 
 
 ___
 gtk-list mailing list
 gtk-list@gnome.org
 https://mail.gnome.org/mailman/listinfo/gtk-list


If I'm not mistaken, older releases of GLib are not thread-safe by
default: you need to call g_thread_init(). Does adding this call makes
any difference?

Cheers,
Tadej

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

___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-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
 tris...@upstairslabs.com 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 gtk/gtk.h

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: Gtk Text View Question

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

 Sun5# gcc -Wall `pkg-config --cflags --libs gtk+-2.0` Test1.c -o Test1
 Test1.c: In function `createConsoleBox':
 Test1.c:6: warning: implicit declaration of function 
 `gtk_text_view_get_vadjustment'
 Test1.c:6: warning: passing arg 1 of `gtk_vscrollbar_new' makes pointer 
 from integer without a cast
 Undefined   first referenced
   symbol in file
 gtk_text_view_get_vadjustment   /var/tmp//ccS4tO2f.o
 ld: fatal: Symbol referencing errors. No output written to Test1
 collect2: ld returned 1 exit status
 
 Thomas Dineen

What version of GTK+ is installed on your machine? get_vadjustment()
function is only available since GTK+-2.22. You can check your version
like this:

  pkg-config --modversion gtk+-2.0

Cheers,
Tadej

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

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


Re: Gtk Text View Question

2013-09-29 Thread Tadej Borovšak
Hi.

Dne 29.09.2013 (ned) ob 11:22 -0700 je Thomas Dineen napisal(a):
 #include gtk/gtk.h
 
 GtkWidget* createConsoleBox()
 {
  GtkWidget* textArea = gtk_text_view_new();
  GtkWidget* scrollbar= 
 gtk_vscrollbar_new(gtk_text_view_get_vadjustment(GTK_TEXT_VIEW(textArea)));
  GtkWidget* textEntry = gtk_entry_new();
 
  GtkWidget* console = gtk_table_new(3, 2, FALSE);
 
  gtk_table_attach_defaults(GTK_TABLE(console), textArea, 0, 1, 0, 1);
  gtk_table_attach_defaults(GTK_TABLE(console), scrollbar, 1, 2, 0, 1);
  gtk_table_attach_defaults(GTK_TABLE(console), textEntry, 0, 2, 1, 2);
  //This code sets the preferred size for the widget, so it does not 
 ask for extra space
  gtk_widget_set_size_request(textArea, 320, 240);
 
  return console;
 }
 
 
 int main(int argc,char* argv[]){
  GtkWidget *window;
  gtk_init(argc, argv);
 
  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(window), Simple Sample);
  gtk_window_set_default_size(GTK_WINDOW(window), 800, 600);// does 
 not  matter this size
  gtk_container_add(GTK_CONTAINER(window), createConsoleBox());
  gtk_widget_show_all(window);
  gtk_window_set_resizable(GTK_WINDOW(window),FALSE);//because of this
  gtk_main();
  return 0;
 }

This code compiles just fine here. How are you compiling this program
and what errors do you get?

Cheers,
Tadej

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

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


Re: Gdk PixbufAnimation supported formats

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

2013/4/18 Kip Warner k...@thevertigo.com

 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: Where are the GTK+1.2 sources?

2013-02-19 Thread Tadej Borovšak
Hi.

2013/2/20 Troy Watson drt...@gmail.com:
 Where can I download the source for GTK+1.2? The official link from
 www.gtk.org doesn’t work: http://ftp.gnome.org/pub/gnome/sources/gtk+/1.2/

Sources can be downloaded from [1].

Cheers,
Tadej



[1] ftp://ftp.gtk.org/pub/gtk/

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


Re: Three widgets inside resizeable panes

2012-10-12 Thread Tadej Borovšak
Hi.

 How can I implement three widgets inside horizontally resizeable panes, 
 as given:
 
 +-+-+-+
 | ! ! |
 | ! ! |
 | ! ! |
 | ~ ~ |
 | w1  ~  w2 ~ w3  |
 | ~ ~ |
 | ! ! |
 | ! ! |
 | ! ! |
 +-+-+-+

Try creating something like this:

+-+---+
| !+++|
| !|!||
| !|!||
| ~|~||
| w1  ~| w2 ~ w3 ||
| ~|~||
| !|!||
| !|!||
| !+++|
+-+---+

Widget hierarchy should look something like this

parent
 `- HPaned1
 +- w1
 `- HPaned2
 +- w2
 `- w3

Cheers,
Tadej

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

___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-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: Question about deprecated Gdk thread lock functions

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

As far as I know, gdk-pixbuf is thread-safe and those global locks are
not needed. Are you sure other parts of your code that could contribute
to this error are fine?

Cheers,
Tadej


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

___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-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: 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: drawing on offscreen surface

2012-08-10 Thread Tadej Borovšak
Hi!

 Thanks for the code.
 However, it does not draw anything. I assume the draw rectangle need to be
 done in draw_cb() so I added this code in
   cairo_set_source_surface(cr, surface, 0, 0);

   cairo_set_source_rgb(cr, 0, 1, 0);
   cairo_rectangle(cr, 300, 300, 200, 200);
   cairo_stroke(cr);
   cairo_paint(cr);

 but it still does not draw any rectangle. Do I not need to have expose
 handler to draw?

What version of GTK+ are you using? Simple app I sent to you uses
version 3 and will not work properly with version 2. If you're using
GTK+ version 2, you'll need to make some minor changes (replace draw
signal with expose-event signal, update draw callback prototype and
manually create cairo context for GTkDrawingArea's GdkWindow).

 Also, I would like to know how to render contents from main window AND from
 offscreen both together on main visible window
 say, a primitive (Rectangle) on main window and another primitive (circle)
 from offscreen? Could you please show me how?

Not sure what is giving you trouble here. Drawing from offscreen is
done by two simple function calls: cairo_set_source_surface() and
cairo_paint(). If you need something else drawn onto your widgets,
simply draw that from inside draw (or expose-event for GTK+ 2.x)
callbackusing cairo drawing functions.

Cheers,
Tadej

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


Re: drawing on offscreen surface

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

Have a look at this code (targeted at GTK+-2.x):

#include gtk/gtk.h

static cairo_surface_t *surface = NULL;

static gboolean
configure_event_cb (GtkWidget *widget,
GdkEventConfigure *event,
gpointer   data)
{
  cairo_t *cr;

  g_print(configure event: %d, %d\n, event-width, event-height);

  if (surface)
cairo_surface_destroy (surface);

  surface = gdk_window_create_similar_surface (event-window,
   CAIRO_CONTENT_COLOR,
   event-width,
   event-height);

  cr = cairo_create(surface);
  cairo_set_source_rgb(cr, 1, 0, 0);
  cairo_paint (cr);

  cairo_move_to (cr, 100, 100);
  cairo_set_source_rgb (cr, 0, 0, 0);
  cairo_set_font_size (cr, 20);
  cairo_show_text (cr, Offscreen buffer is red);

  cairo_destroy(cr);

  return FALSE;
}

static gboolean
draw_cb (GtkWidget  *widget,
 GdkEventExpose *event,
 gpointerdata)
{
  cairo_t *cr;

  g_print(draw event\n);

  cr = gdk_cairo_create (event-window);

  cairo_set_source_surface(cr, surface, 0, 0);
  cairo_paint(cr);

  cairo_move_to (cr, 200, 200);
  cairo_set_source_rgb (cr, 0, 1, 0);
  cairo_set_font_size (cr, 20);
  cairo_show_text (cr, This text is not blitted);

  cairo_destroy (cr);

  return TRUE;
}

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

  gtk_init(argc, argv);

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (window), 1200, 800);
  g_signal_connect (window, destroy, gtk_main_quit, NULL);

  area = gtk_drawing_area_new();
  g_signal_connect (area, expose-event,
G_CALLBACK (draw_cb), NULL);
  g_signal_connect (area, configure-event,
G_CALLBACK(configure_event_cb), NULL);
  gtk_container_add (GTK_CONTAINER (window), area);

  gtk_widget_show_all(window);
  gtk_main();

  return 0;
}


surface is your offscreen buffer and contains red background and black
text. This is then blitted during expose-event and to finish off, some
green text is added. And that's it.

Cheers,
Tadej


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


Re: drawing on offscreen surface

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

There is a lot of unnecessary code in your example. I attached a
cleaned-up example that demonstrates how to handle situations like
yours.

Cheers,
Tadej



#include gtk/gtk.h

static cairo_surface_t *surface = NULL;

static gboolean
configure_event_cb (GtkWidget *widget,
GdkEventConfigure *event,
gpointer   data)
{
  cairo_t *cr;

  g_print(configure event: %d, %d\n, event-width, event-height);

  if (surface)
cairo_surface_destroy (surface);

  surface = gdk_window_create_similar_surface (event-window,
   CAIRO_CONTENT_COLOR,
   event-width,
   event-height);

  cr = cairo_create(surface);
  cairo_set_source_rgb(cr, 1, 0, 0);
  cairo_paint (cr);
  cairo_destroy(cr);

  return FALSE;
}

static gboolean
draw_cb (GtkWidget *widget,
 cairo_t   *cr,
 gpointer   data)
{
  g_print(draw event\n);

  cairo_set_source_surface(cr, surface, 0, 0);
  cairo_paint(cr);

  return TRUE;
}

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

  gtk_init(argc, argv);

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (window), 1200, 800);
  g_signal_connect (window, destroy, gtk_main_quit, NULL);

  area = gtk_drawing_area_new();
  g_signal_connect (area, draw,
G_CALLBACK (draw_cb), NULL);
  g_signal_connect (area, configure-event,
G_CALLBACK(configure_event_cb), NULL);
  gtk_container_add (GTK_CONTAINER (window), area);

  gtk_widget_show_all(window);
  gtk_main();

  return 0;
}


-- 
Tadej Borovšak
blog.borovsak.si
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-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-22 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: GTK Menu Window Type

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

Dne 15.06.2012 (pet) ob 14:14 +1000 je BRAGA, Bruno napisal(a):

 I am trying to use an application written in Perl/GTK (volwheel
 - http://oliwer.net/b/volwheel.html), but I had some trouble to
 display the popup menu on my screen, because I am using i3wm as my
 window manager, and it is bringing the menu as a whole (top level)
 window instead of a popup. According to developers of i3wm, this
 happens because the window type is not properly set. 

I quickly glimpsed at the volwheel's code [1] and popup menu you
describe seems to be just a normal, undecorated toplevel window and is
not a menu per-see.

 In i3, all windows with type  dialog, utility, toolbar and splash
 windows are defined to be floating (displayed such as a popup on
 screen), and all others are displayed as a top level.
 
 
 Is there any way to come around this problem?

I think this can be solved by simply changing the window type hint to
something from the list above. It should be simple thing to do, since
all you need to change is line 29 in linked file.

Cheers,
Tadej


[1]
http://code.google.com/p/olwtools/source/browse/trunk/volwheel/lib/MiniMixer.pm


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

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


Re: Why are GtkAdjustments not buildable?

2012-05-06 Thread Tadej Borovšak
Hello

 Hello, does anyone know why GtkAdjustments are not buildable?

They are buildable. (Glade has been producing markup for adjustments
for as long as I know). What makes you think they are not?

Cheers,
Tadej

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


Re: No more poppler_page_render_to_pixbuf() in Ubuntu 12.04

2012-04-28 Thread Tadej Borovšak
Hello.

 I used the code below to render a page of a pdf to a scrolled window in
 a gtk application of mine. After downloading Ubuntu 12.04 I get that
 there is no more support for poppler_page_render_to_pixbuf(). I do know
 that we are supposed to use cairo.  But how?  How do I replace the code
 below with cairo?  What are we supposed to use, total cairo or
 gdk_cairo_create().

I can see 2 different ways of dealing with this API removal. To reuse
as much existing code as possible, you can create
cairo_image_surface_t, let poppler render your page there using
poppler_page_render() and write your own function that will convert
between cairo_image_surface_t and GdkPixbuf.

Another way would involve replacing GtkImage widget with
GtkDrawingArea and drawing your page directly from expose-event/draw
signal handler. Details will depend on whether you'll use GTK+-2 or
GTK+-3.

Cheers,
Tadej


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


Re: GtkDrawingArea size

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

2012/3/7 Christopher Howard christopher.how...@frigidcode.com:
 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 gtk/gtk.h

#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
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: 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: 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: 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: Box packing vs table packing

2012-01-27 Thread Tadej Borovšak
Hi.

 A (maybe not so) simple question: why should I use one style of packing
 instead of the other?

I fail to see the problem here. If you have your widgets arranged is
some kind of grid, use GtkTable, otherwise GtkBox. Also, if you're
using GTK+-3.x, you can also use GtkGrid[1], which supports both of
styles of packing with proper support for height-for-width geometry.

Cheers,
Tadej

[1] http://developer.gnome.org/gtk3/stable/GtkGrid.html

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


Re: combo box trouble

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

 If however I click on the arrow of the populated combobox, the popup
 doesn't show any text. No signals are emitted either.

 I have a feeling that I am missing something simple...

You're missing a display component of combo box: GtkCellRenderer. You
must either pack it inside combo box in Glade or do it manually from
code.

Cheers,
Tadej

-- 
Tadej Borovšak
00386 (0)40 613 131
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-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 jamesstew...@optusnet.com.au:
 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.

 object class=GtkAdjustment id=adj_assign
    property name=value5/property
    property name=upper10/property
    property name=step_increment0.10001/property
    property name=page_increment10/property
    property name=page_size10/property
  /object

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: make file command not working

2011-07-31 Thread Tadej Borovšak
Hi.

2011/7/27 Shashank Gudipati sgsha...@gmail.com:
 this is after the ./configure -prefix=/opt/gtk

Configure command should be:

./configure --prefix=/opt/gtk

Does that fix anything?

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


Re: Does g_key_file_free() free pointers from g_key_file_get_string()?

2011-06-17 Thread Tadej Borovšak
Hello.

 Since the documentation says it's a newly allocated string, I have
 always freed the string when I no longer need it. This hasn't produced
 any ill effects so far. Usually, valgrind will catch problems related
 to freeing pointers to non-heap memory.

Another indicator that returned value should be freed is lack of const
modifier on return value.

If API docs state:

const char * get_something () - do not free result
  char * get_another_thing () - free result

Cheers,
Tadej

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

___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-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: Scrolling Problems with a Floating Widget

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

 I have done what you said, however the issue is that the TreeView,
 despite the setting of a size request of (0, 0) is not scrolled, it just
 takes up all the space and can't be resized, (screenshot here)
 http://i.imgur.com/mzrnc.png

I tested this and you're right: when linked against GTK+-3.0, treeview
ignores set size request. I also linked your sample app with GTK+-2.0
and things work as expected.

 How can I make it so that the TreeView does not do this, so that it can
 be scrolled? (Code is at the end)

Maybe someone that is familiar with GtkSizeRequest interface/GtkTreeView
can help here? Additionaly, could this be considered a regression in GTK
itself?

Cheers,
Tadej

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

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


Re: Scrolling Problems with a Floating Widget

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

 So I gathered that I had to use my own GtkHScrollbar and GtkVScrollbar,
 like so
 http://whyareyoureadingthisurl.files.wordpress.com/2011/02/layout.png
 
 However I cannot get this working in GTK3. Can someone point me to an
 example, or simply explain the different components in how this can be
 achieved, so I can try to get it working?

I haven't tested this, but steps that you probably need to take are:

1. create widget hierarchy
2. set some sensible minimal size on your GtkTreeView
3. interconnect scrollbars with tree view by sharing adjustments

Minimal size can be set using gtk_widget_set_size_request() and
adjustment sharing can be achieved using getters for scrollbars and
gtk_widget_set_scroll_adjustments().

Hope this helps a bit.
Tadej

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

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


Re: get_name returns name of the widget not the instance

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

This happens because GtkBuilder doesn't set name property of the
widget to id property in glade file anymore (I think GTK+-2.20
introduced this change).

Your code probably needs to be updated from this (it's been a while
since I coded for the last time, so take my advice with a grain of
salt):

$name = $object-get_name ();

to

$name = $object-Gtk2::Buildable::get_name ();


Or, you can set name property of the widget to it's id in Glade.

Cheers,
Tadej

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

___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-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: 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: Weird RadioButton behaviour

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

 I have an application on which a group of RadioButtons select the
 control mode. The modes that are not in control show the current
 reading, while the in control has a SpinButton. To do this widget
 switching I have hooked up to the signal_toggled and signal_clicked of
 the RadioButtons and in the handler I check the get_state() value.

 This works fine when I click on the radio buttons with the mouse. The
 callback is invoked four times; twice on the old selection with the
 get_state returning false, then twice on the new with get_state() true.
 I don't know which order the clicked and toggled signals occur but it
 doesn't really matter. I am slightly surprised that I get two events on
 the old  button - I haven't clicked it, after all.

I did have similar troubles quite some time ago. IIRC, the problems
were caused by the fact that GtkButton::clicked is an action signal
that gets emitted quite a lot by GTK+ itself.

It's been a while since I last looked at GTK+'s sources, but I think
that chain of events/signals that lead to observed behavior is:

Clicking with a mouse: GtkToggleButton::button-released -
GtkButton::clicked - GtkToggleButton::toggled

Not sure what would chain for keyboard navigation be, but I'm almost
sure that state change is done via GtkButton::clicked signal.

 The problem is when I use the cursor keys to change button. Most times
 it works the same, but often (and it seems to usually be most times I
 move away from a particular button) the two signals sent by the
 leaving button happen with its get_state() still returning true.

 Presumably this is a race condition of some sort, but why is it so
 consistently problematic on keyboard actions and never on mouse? Is
 there a better way to do the whole thing?

Why do you connect to both GtkButton::clicked and
GtkToggleButton::toggled signals? It would probably be better to only
connect to toggled one.

Hope this helps a bit,
Tadej

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


Re: 2 callbacks to same event

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

What do you return from your callbacks? If you return TRUE, event is
considered handled and no other callback is called from there on. Try
returning FALSE from your callbacks and I'm almost sure things will
work.

Cheers,
Tadej

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

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


Re: Timer start registration breaks the gtk_main()

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

 int main()
 {
   CFrame *frame = new CFrame();
   result = frame-OpenPort();
   if( !result )
   return 1;
   else
   {
g_timer_add_seconds( 1, (GSourceFunc) frame-ReadData(), NULL );
gtk_widget_show( window );
frame-ReadData();
gtk_main();
   }
 }

Where is your gtk_init() call?

Cheers,
Tadej

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

___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-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: GTK MenuShell Nested Menu's

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

 I'm trying to nest a menu using menu_shell,
 
 GtkWidget *tray_menu;
 GtkWidget *child_menu;
 tray_menu = gtk_menu_new ();
 child_menu = gtk_menu_new ();
 gtk_menu_shell_append(GTK_MENU_SHELL(tray_menu), child_menu);
 
 but i get an error:
 Gtk-CRITICAL **: gtk_menu_shell_insert: assertion `GTK_IS_MENU_ITEM
 (child)' failed
 
 so i guess my question is, how do i set one menu to be another menu's child?

You need to attach submenu to GtkMenuItem. Something like this:

GtkWidget *menu,
  *submenu,
  *item;

menu = gtk_menu_new ();

item = gtk_menu_item_new_with_label (Submenu);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);

submenu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);

Cheers,
Tadej

-- 
Tadej Borovšak
00386 (0)40 613 131
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com

___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-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: configure_event behavior

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

 What I should to do for changing this behaviour? I want that content
 automatically fits window with signal configure_event handler
 assigned.

Try returning FALSE from configure-event signal handler. I'm almost
sure this will fix your problem.

Cheers,
Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-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: Issues with Gtk2 dialogs and UTF8 data.

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

I'm almost sure your troubles are not GTK+ related. You'll find some
test code below that works fine for me (just put some UTF-8 encoded
text into sample.txt file).

 Code 
#!/usr/bin/env perl

use strict;
use warnings;
use Glib qw(TRUE FALSE);
use Gtk2;

Gtk2-init();

my $window = Gtk2::Window-new ('toplevel');
$window-signal_connect (delete_event = sub { Gtk2-main_quit(); });
$window-set_border_width (10);

my $input;
open $input, '', 'sample.txt';
binmode $input, ':utf8';

my $label = Gtk2::Label-new ($input);
$window-add ($label);
$window-show_all();

Gtk2-main();
 /Code 


BTW, talking about unicode data is not really helpful. In most
cases, this means xxx-encoded text, where xxx is one of the UTF-8,
UTF-16le, UTF-16be ..., and you should state this explicitly.

Cheers,
Tadej

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


Re: Signals received twice

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


 I'm using GtkFileChooserButton and connecting to selection-changed signal
 and the issue is that when i changed the selected fodler in the widget, I'm
 getting the signal 4 or 5 times repeatedly.
 And I think that should happens just one, Am I right ?

No, GtkFileChooser::selection-changed signal gets emitted for every
change of selection in file selection dialog. You should probably use
GtkFileChooserButton::file-set signal in your application.

Cheers,
Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-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: Mixing GLib and system file name encoding

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

 - convert the names from the list to GLib encoding (UTF-8) and combine
  it with the directory name of the list file and use g_fopen() to open
  the files

You can use g_locale_to_utf8() to convert names in the list to UTF-8,
which can then be fed along with base directory to g_build_filename()
or something similar and opened using g_fopen().

 - convert the directory name of the list file from GLib encoding to the
  system encoding and use fopen() to open the other files

g_locale_from_utf8() can be used to convert base path to system
encoding. After that you can concatenate it with filename from your
list and open it using fopen().


Note that both methods will only work if your input file is indeed
encoded in system locale. If your file originates from other system
that uses different locale, you're basically screwed.

Hope this helps a bit.

Tadej

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


Re: comboboxentry assertion `GTK_IS_CELL_RENDERER (cell)' issue

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

You're mixing simple, text-only version API of GtkCOmboBoxEntry with
complex one. Since you only need to show text, simple method should do
for you, but unfortunately, you cannot construct that type of combo
box using glade.

When dealing with GtkComboBoxEntry, you need to keep in mind that
there is always one GtkCellRendererText present. I fixed your code
that should work for you:

 $color_centry1= $builder-get_object('comboboxentry1');

 my $model3 = new Gtk2::ListStore('Glib::String');

 my @listing_centry1 = qw/red blue purple yellow black/;

 foreach $text (@listing_centry1) {
    my $iter = $model3-append ();
$model3-set ($iter, 0, $text);
 }

$color_centry1-set_model($model3);
 $color_centry1-set_text_column (0); # this line is generating the error 
 message
 $color_centry1-set_active(0);

Cheers,
Tadej


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


Re: Simple way to list keys values of a GHashTable object?

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

For simple printout, you may be interested in g_hash_table_foreach().
Something like this should dump key-value pairs to console (I assumed
here that both key and value are strings):

===
static void
dump_pair (const char *key,
   const char *value)
{
  g_print (Key: %s Value: %s\n, key, value);
}

...

g_hash_table_foreach (table, (GHFunc)dump_pair, NULL);
===

Cheers,
Tadej

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


Re: g_int64_hash can not be found

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

g_int64_hash() has been introduced in GLib-2.22. Is your GLib recent enough?

Tadej

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


Re: g_int64_hash can not be found

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

 How to
 check glib version from command line?

pkg-config --modversion glib-2.0

Cheers,
Tadej

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


Re: howto compare two GTypes

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

Not sure why your code doesn't work, since it looks clean to me. Maybe
you have an error somewhere else in your code?

I also quickly created compilable sample that demos type comparison:

-
#include gtk/gtk.h

int
main (intargc,
  char **argv)
{
  GList *list = NULL,
*iter;
  GType  type;

  gtk_init (argc, argv);

  list = g_list_prepend (list, gtk_window_new (GTK_WINDOW_TOPLEVEL));
  list = g_list_prepend (list, gtk_button_new ());
  list = g_list_prepend (list, gtk_label_new (Label));

  type = GTK_TYPE_LABEL;

  for (iter = list; iter; iter = g_list_next (iter))
if (G_OBJECT_TYPE (iter-data) == type)
  g_print (Match found\n);
else
  g_print (No match\n);

  return 0;
}
-

Tadej

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


Re: Writable array returned from gtk_tree_path_get_indices()

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

2010/10/7 Stef Walter stef-l...@memberwebs.com:
 Is the integer array returned from gtk_tree_path_get_indices() writable
 by design? Or should it be treated as readonly?

You should definitely not modify values in returned array, since this
central part of GtkTreePath. Currently, modifying parts of this array
is the same as moving your path using gtk_tree_path_(next|prev)(), but
if internal structure of GtkTreePath changes, you'll be in trouble.

 Some stuff like GtkTreeModelSort and GtkTreeModelFilter write to this
 index array, but those may be liberties taken by gtk+ internally.

Quickly looking at the code I would say that this is indeed the case
here. Directly modifying values avoids some type checking, which
speeds up some of the operations.

 Perhaps we would change the return values for the following to 'const
 gint*':

 gtk_tree_path_get_indices ()
 gtk_tree_path_get_indices_with_depth ()

 If not by design, I'll file a bug, and patch.

I think that minimal thing to do here is to update docs to something
like this: Returns the current indices of path. This is an array of
integers, each representing a node in a tree. This value should not be
freed and members of array should not be modified. Filling a bug is
definitely the way to go IMHO.

Cheers,

Tadej

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


Re: really freeing the memory allocated by g_slist

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

2010/10/7 Márcio Ricardo Pivello pive...@gmail.com:
 Hi all.
 I use a library called GTS for computational geometry tasks, and it is
 heavily based on GLib data structures. Specifically, in _many_ occasions it
 returns a GSList* containing vertices, edges and so on, which you use and
 then delete with g_slist_free( ). In my work, during a transient simulation
 this kind of operation occurs at least tens of millions of times. Since
 g_slist_free( ) does not actually deallocates the memory used by the list,
 my program always ends consuming all available memory during the simulation
 (8 GB, when it should use just 10% of that).

I don't think g_slist_free() is problematic here. My guess would be
that you're not freeing your data that is pointed to by list elements.
g_slist_free() will only free memory that is used by GSList structs,
data that is pointed to by data member of GSList structure needs to be
freed separately.

For example, take gtk_icon_view_get_selected_items() func. Usual usage is:

GSList *items = gtk_icon_view_get_selected_items (icon_view);

/* Do something here */

g_slist_foreach (items, (GFunc)gtk_tree_path_free, NULL);
g_slist_free (items);

The important line is g_slist_foreach() line, where actual data that
is pointed to by nodes is freed.

Tadej

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


Re: cairo functions too use instead of gdk ones

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

Replacements would probably look like this:

 gdk_gc_new

cairo_create() or gdk_cairo_create() if you're using GTK+

 gdk_gc_set_foreground

cairo_set_source_rgb() or gdk_cairo_set_source_color()

 gdk_pixmap_create_from_xpm

This last one is a bit tricky, since you should not use GdkPixmaps
anymore. For equivalent result, you'll need to
 - create new cairo surface that will serve as a replacement for GdkPixmap
 - load XPM into GdkPixbuf
 - paint that pixbuf onto your new surface

Tadej

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


Re: why is GtkOptionMenu deprecated?

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

 Hi, I really need something like GtkOptionMenu where you can pack
 widgets in a GtkMenu and make a choice. If I has to write it myself,
 could someone tell me why it has been deprecated, please?

API docs clearly state that GtkOptionMenu has been replaced by
GtkComboBoxEntry. There is even a migration guide available.

Tadej

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


Re: Doubt about button_press_event and drag and drop

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

First, signal handler for GtkWidget::button-press-event should return
gboolean value, not void. This return value is then used to determine
if the event should be propagated further or not.

If you return FALSE from your signal handler, you indicate that you
haven't handled the event and event is propagated further. If you
return TRUE, event is considered handled and chain stops here.

As for your problem, try returning FALSE from your signal handler and
see what happens.

Tadej

--
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-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 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: OpenGL drawing to widget actually draws in the whole window

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

GTK+-2.18 introduced client-side windows, which means that not all
GdkWindows are now backed with native window. The only GdkWindow that
is always backed by native window is applicaition's toplevel window.

This probably explains why your drawing would end-up on the toplevel.
It is possible to set GDK_NATIVE_WINDOWS env variable, in which case
all GdkWindows will be native windows like in GTK+2.18.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-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: GTK+ 2.20.0 Make Install Problem

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

I'm having exactly the same problems on my machine when using jhbuild
to build GTK+3. As a workaround, I simply set LD_PRELOAD env variable
before compiling/installing.

Tadej

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


Re: Syntax highlight in GtkDoc

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

Your markup is just fine, maybe your gtk-doc is too old to highlight
the examples? I think you'll need gtk-doc-1.14 for highlighted
examples.

Tadej

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


Re: Syntax highlight in GtkDoc

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

 I'm using GtkDoc 1.4, which is the default version for Ubuntu 10.04
 Maybe there is a flag that must be set into the Makefile.am?

There is no such switch AFAIK. Code should be made pretty by default.
I think someone even asked how would one go about disabling this, but
it's been a while since then.

Did you try generation any other docs apart yours? Are those pretty or plain?

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-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.

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: 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: fetch and display data in the form of a table

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

 I tried the gtkclist and it worked well..

GtkCList is one of the widgets that is not part of GTK+-3 (and is not
maintained in 2.x). Use GtkTreeView like Jeff already suggested.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-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: GtkRange API is incomplete

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

 Can't you just connect to two different signal handlers one for the
 update and one for the undo stack?

There is only one signal (GtkRange::value-changed) available.
Unfortunately, GtkRange's internals are one huge pile of ... and
adding another signal would not be that easy. Maybe you can combine
all ::value-changed signal emission in certain time interval into one
undo action?

Tadej

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


Re: GtkRange API is incomplete

2010-07-27 Thread Tadej Borovšak
Hi again.

 Hi there,
 You can just connect to the GtkRange's GtkAdjustment value-changed
 signal for the view update.

This will not work, because delayed emission of
GtkRange::value-changed signal is implemented by delaying emission of
GtkAdjustment::value-changed. You can connect to either of those
signals, end result is exactly the same (GtkRange::value-changed is
emitted in signal handler for GtkAdjustment::value-changed).

BTW, implementing delayed emission properly inside GtkRange would also
make it possible to hide public fields from GtkAdjustment.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-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: Query on Multiple row selection in a GtkTreeView

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

I think that returning TRUE from your button-press-event handler
should fix this.

Tadej

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


Re: How to add a mouse pressed event to GtkLabel

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

GtkLabel doesn't have it's own GdkWindow and thus cannor react to
button presses. You can wrap it inside GtkEventBox and connect to
button-press-event on it.

Tadej

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


Re: Why GtkFontSelectionDialog doesn't implements GtkFontSelection?

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

 Unstable here means that it maybe will not be part of stable version
 of GTK+ or that it will be part of a stable version and is just on a
 beta version?

Unstable means it'll be part of next GTK+ release, due to be out in
October 2010.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-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: 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.

 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: 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: Error compiling XInput2 support for GTK+...

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

This error is probably caused by removal of gdk-pixbuf from GTK+ (it
is now a standalone library).

Tadej

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


Re: Error compiling XInput2 support for GTK+...

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

 So, how do I get the build going again? Is this a bug to be reported?

Not sure exactly what should be done here. GTK+ from git master has
been already adapted to this change, so having a experimental branch
borked doesn't deserve a bug report. You can try fixing this branch
yourself or wait for Garnacho do come around and fix it.

BTW, is this branch actively maintained? IIRC, parts of xi2 branch
have already been merged into master.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeb...@gmail.com
tadej.borov...@gmail.com
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-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: 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: Implementing my own ScrolledWindow

2010-07-05 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/GDK equivalent to UpdateWindow() ?

2010-07-05 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: 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: 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: Why GtkFontSelectionDialog doesn't implements GtkFontSelection?

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

 I was reading the documentation of the GtkFontSelectionDialog and see
 that it implements own methods to set and get the GtkFontSelection
 properties. Why it is at this way? Isn't more correct and standard use
 methods of GtkFontSelection just casting with GTK_FONT_SELECTION() the
 font selection dialog?

It may be tempting to simply cast GtkFontSelectionDialog to
GtkFontSelection since GtkFileChooserDialog and GtkFileChooser work
like this, but there is one major difference: GtkFileChooser is an
interface that widgets can implement while GtkFontSelection is real
widget, not an interface.

It is possible to get font selection widget from font selection dialog
using gtk_font_selection_dialog_get_font_selection() (one must like
that name;), but you'll need unstable GTK+-2.22 for this function.

There has been some work going on to bring font chooser widgets into
21st century, but nothing has come out of that yet (and I lost the
link to the page with some mockups).

Tadej

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


Re: dconf 0.4.1 is out

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

 but since that's only needed for 'make dist' (or compiling directly
 from git) I guess it's okay for your embedded use case?

 Why do you need vala on make dist? But in general, yes: that would be
 ok.

When using autotools with vala, end-user that only consumes
application doesn't need to have vala installed, since generated C
files are also distributed inside tarball. From user's perspective,
distributed vala applications are just normal C applications.

This is how normal flow looks like:

.-.
| ..  valac   .-. | compiler/linker   .-.
| | vala files | --- | C files | -- | app |
| ''  '-' |   '-'
| |
| This is dstributed inside tarball.  |
'-'

Tadej

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


Re: Use of Memory Slices in N-ary Trees

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

GLib uses slice allocator when allocating memory for new nodes which
makes preallocation quite useless.

Tadej

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


Re: Use of Memory Slices in N-ary Trees

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

 Ah perfect! So you mean that when I create a new node using GNode it will
 automatically use g_slice_alloc behind the covers?

Yes, nodes are allocated using g_slice_new0(GNode) (unless you have
G_SLICE env variable set to always-malloc).

Tadej

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


  1   2   3   4   >