Re: Ruler Class in GTK+ 3

2015-01-09 Thread Carlos Pereira
This is really unfortunate, my application also has a ruler... GTK is 
really moving away from its users,

C

none. GtkRuler was deprecated in GTK+ 2.x and removed in GTK+ 3.x.
it's a*very*  niche widget, and most applications that use one in
their UI ended up having their own class.

my suggestion is to look at ruler widgets in GIMP and Inkscape.

if you want to draw your own, you can use a GtkDrawingArea subclass
with a custum draw() virtual function.

ciao,
  Emmanuele.
   


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


Re: button background color in gtk3

2012-08-29 Thread Carlos Pereira
Quite often widget colors are just a question of style but sometimes 
this is not the case. I can think of medical applications, for example, 
where colors can be critical.


In my case, I have a chemical periodic table made with GTK buttons, each 
one representing a chemical element, with its default color. Users can 
change these chemical element default colors directly from the interface 
or from XML config files:


http://www.gamgi.org/screenshots/screenshot13_5.html

Rewritting an entire CSS file and downloading it everytime users change 
the default color of a chemical element looks really depressing... I am 
sure button colors can be changed directly from the code in GTK 3??


Carlos

On Sun, August 26, 2012 1:39 pm, Giuseppe Penone wrote:
   

Hi, I faced the same problem some time ago in gtkmm3.
I asked a question and then replied myself in this post:
http://stackoverflow.com/questions/8952679/gtkmm-3-button-background-color-change
You have to use a CSS file (a working example in my code) and import from
code
to override the gtk3 theme that you are using on your distribution.
Cheers,
Giuseppe.

 

I had a similar problem and it seems that even with Priority = Application
the default theme is overriding override_background_color(). I would
like to know if this is a bug as I wasted several hours trying to find the
work around and ended up having to use the css method with the applicable
config from the default theme which seems a little excessive when a 1
liner in code should be possible.


   

On Sun, Aug 26, 2012 at 1:44 PM, Rudra Banerjee
bnrj.ru...@yahoo.comwrote:

 

I will be grateful if someone please show me the way.
On Sun, 2012-08-26 at 00:20 +0100, Rudra Banerjee wrote:
   

Friends,
I am putting gtkbuttons inside a grid with modify_bg. I am getting an
odd case that when the window is focused, all buttons are showing
 

white,
   

not what suggested by modify_bg. The same structure was working fine
 

in
   

gtk2 (while I was using table instead of grid).
I am posting the complete minimal code(60 line only) for your
 

reference.
   

I have seen that the gtk_widget_modify_bg is deprecated in gtk 3 so I
tried the suggested method with gtk_widget_override_background_color
 

but
   

there it seems that declaration of GdkColor colorRed2 = {0x,
 

65535,
   

29555, 24158} has changed to something like GdkRGBA.
I tried to change to

GdkRGBA colorRed = {1,0,0,1};
yeilding error:

‘const struct GdkRGBA *’ but argument is of type ‘GdkRGBA’

Please Help.
here is the complete code:

#includegtk/gtk.h
int main(int argc,
 char *argv[]) {
 GtkWidget *window;
 GtkWidget *grid;
 GtkWidget *menubar;
 GtkWidget *filemenu;
 GtkWidget *quit;
 GtkAccelGroup *accel_group = NULL;

 gtk_init(argc,argv);
 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 gtk_window_set_title(GTK_WINDOW(window), Try Grid);
 gtk_container_set_border_width(GTK_CONTAINER(window), 05);

 grid = gtk_grid_new();
 gtk_container_add(GTK_CONTAINER(window), grid);
  gtk_grid_set_column_homogeneous(GTK_GRID(grid),TRUE);
  gtk_grid_set_row_homogeneous(GTK_GRID(grid),TRUE);
 menubar = gtk_menu_bar_new();
 filemenu = gtk_menu_new();

 accel_group = gtk_accel_group_new();
 gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);

 GtkWidget *file = gtk_menu_item_new_with_mnemonic(_File);
 quit = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT,
accel_group);

 gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), filemenu);
 gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), quit);
 gtk_menu_shell_append(GTK_MENU_SHELL(menubar), file);

 g_signal_connect(G_OBJECT(quit), activate,
G_CALLBACK(gtk_main_quit), NULL);

 gtk_grid_attach(GTK_GRID(grid), menubar, 0, 0, 2, 1);


 /* Color Scheme */
 GdkColor colorRed2 = {0x, 65535, 29555, 24158};
 GdkColor colorBlue = {0x, 3598, 57054, 61937};
 GdkColor colorWht = {0x, 65535, 65535, 65535};


 GtkWidget *Abutton = gtk_button_new_with_label(A);
 gtk_grid_attach(GTK_GRID(grid), Abutton, 0, 1, 1, 1);
 gtk_widget_modify_bg(Abutton, GTK_STATE_NORMAL,colorBlue);
 gtk_widget_modify_bg(Abutton, GTK_STATE_PRELIGHT,colorWht);

 /* Create second button */
 GtkWidget *Bbutton = gtk_button_new_with_label(B);
 gtk_grid_attach(GTK_GRID(grid), Bbutton, 10, 1, 1, 1);
 gtk_widget_modify_bg(Bbutton, GTK_STATE_NORMAL,colorRed2);
 gtk_widget_modify_bg(Bbutton, GTK_STATE_PRELIGHT,colorWht);


 gtk_widget_show_all(window);
 gtk_main();

 return 0;
}


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


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org

Re: button background color in gtk3

2012-08-29 Thread Carlos Pereira

Thanks Olivier,

ugly as hell, but definitely an improvement... :-(

Carlos

On 08/29/2012 05:17 PM, Carlos Pereira wrote:
   

Quite often widget colors are just a question of style but sometimes
this is not the case. I can think of medical applications, for example,
where colors can be critical.

In my case, I have a chemical periodic table made with GTK buttons, each
one representing a chemical element, with its default color. Users can
change these chemical element default colors directly from the interface
or from XML config files:

http://www.gamgi.org/screenshots/screenshot13_5.html

Rewritting an entire CSS file and downloading it everytime users change
the default color of a chemical element looks really depressing... I am
sure button colors can be changed directly from the code in GTK 3??
 

you can modify bits of the CSS from your code like this (taken from
Bluefish code bftextview.c):

GString *str = g_string_new();
GtkStyleContext *stc;
GtkCssProvider *cssp = gtk_css_provider_new();
str = g_string_append_printf(str, GtkTextView.view {background-color:
%s;}, colors);
gtk_css_provider_load_from_data(cssp, str-str, -1, NULL);
stc = gtk_widget_get_style_context(GTK_WIDGET(mywidget));
gtk_style_context_add_provider(stc, GTK_STYLE_PROVIDER(cssp),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);


regards,
Olivier

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

   


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


GtkStatusbar and DGSEAL_ENABLE

2011-04-09 Thread Carlos Pereira

Hi there,

In order to conform with -DGSEAL_ENABLE, I replaced this old code:
gtk_misc_set_alignment (GTK_MISC (GTK_STATUSBAR (statusbar)-label), 
0.5, 0.5);


by this new one:
hbox = gtk_statusbar_get_message_area (GTK_STATUSBAR (statusbar));
label = GTK_WIDGET (gtk_container_get_children (GTK_CONTAINER 
(hbox))-data);

gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5);

It compiles and runs fine, and it does what is expected to do.

Of course this code only works because the label is the first children 
of the statusbar hbox container (the first node of the statusbar hbox 
GList). If that changes in the future, this code will get broken...


Perhaps we could have a function:
label = gtk_statusbar_get_label (GTK_STATUSBAR (statusbar));

This way GTK developers could futurely change the inner workings of 
GtkStatusbar without affecting user code that needs access to the Label.


Regards,
Carlos


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


GTK 3.0 / OpenGL

2011-02-20 Thread Carlos Pereira

Hi all,

Are there significant changes regarding OpenGL integration with GTK 3.* 
and Cairo,

when compared with GTK 2.*?

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


Re: Memory leaks

2011-02-09 Thread Carlos Pereira

P.S I will say though that in all my life I don't think I've ever written a 
programwhere it was either impractical (or too difficult) to fix its leaks.  IMHO 
ignoringleaks is a bad habit to get into and one whose consequences usually get 
worse over time.


I could not agree more with this. It seems obvious to me that the GTK 
team should write code without mem leaks. It's a sad day we even need to 
argue this. There is no such a thing as good and bad mem leaks, in the 
long-term they are all plain wrong and promoting buggy code.


Carlos

On 02/09/11 17:27, John Emmas wrote:

On 9 Feb 2011, at 17:01, James Morris wrote:

   

Not only do we have to write our own code, we have to put work into
making other peoples code ignore the errors in other peoples code so
we can see the errors in our own code. It's a bloody outrage!
 

I think I'd agree with you if I'd ever used Valgrind but at least having the option of a 
suppressions file is better than not having it (as seems to be the case with VC++).  It's 
a double edged sword of course because there's a danger that Valgrind's ability to work 
with a suppressions file might be seen by those other programmers as carte blanche for 
them to delay fixing their memory leaks or even not to bother fixing them at all, or (as 
we have here) to reclassify them as not being genuine leaks.

Which brings us neatly back to where we all started off.

John
P.S I will say though that in all my life I don't think I've ever written a 
program where it was either impractical (or too difficult) to fix its leaks.  
IMHO ignoring leaks is a bad habit to get into and one whose consequences 
usually get worse over time.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

   


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


Re: Memory leaks

2011-02-09 Thread Carlos Pereira



something), but aside from that it's a pure waste of CPU cycles.
   

Dear Allin,
I am sorry, I totally disagree.

I can only see two cases. Either fixing these hundreds and hundreds of 
mem leaks is easy or difficult.
In the first case, is just a question of plain laziness and bad 
programming practises. The second case is much worse, it means the code 
is badly designed.


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


Re: Memory leaks

2011-02-09 Thread Carlos Pereira



I think Allin's point is that even though I deleted the object in my example 
app, the gtk shared library code is still technically available to be used by 
some other part of my program (without needing to be re-initialized).  In my 
example, I just happened to not use it.
   
Yes, I accept Allin's argument here, if you still have access to the 
pointer is not a leak,


I just don't agree with the pure waste of CPU cycles argument...

But to go back to some of the earlier suggestions, maybe it would be beneficial 
to have some kind of unload() / finish() / cleanup() functionality that could 
be invoked by users who need it.  That's what seems to be missing at present.
   
You mean a OPTIONAL gtk_end () function, that could be added in the end, 
at the programmers's will, after a gtk_main (), to clean everything 
before going back to the OS?


gtk_main ();
gtk_end ();

I completely agree. Being optional, I suppose both sides would be happy...

Carlos


John

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

   


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


Re: Porting a GTK 1.x application to current version

2010-07-14 Thread Carlos Pereira

Hi Fabian,

1) In the beginning, you may wish to use:

#define GTK_ENABLE_BROKEN

to allow GTK 1* widgets to run with GTK 2* libs. This makes the 
transition much easier, because you can port all your GTK 1* widgets 
little by little, until one fine day you will be able to get rid of 
#define GTK_ENABLE_BROKEN...


2) When you reach that stage, you might wish to add the following lines 
to your makefiles:


override CFLAGS += -DG_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED \
-DGDK_PIXBUF_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED \
#   -DGSEAL_ENABLE \
#   -DG_DISABLE_SINGLE_INCLUDES -DATK_DISABLE_SINGLE_INCLUDES \
#   -DGDK_PIXBUF_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_SINGLE_INCLUDES

When your app compiles with the uncommented lines, you have essentially 
a GTK 2* app. When you manage to compile your app with the DGSEAL and 
INCLUDES directives, then you have essentially a GTK 3* app.


Cheers,
Carlos


2010/7/11 Fabian Schreyerfabianschre...@gmail.com:
   

Hi there,

I have to port an old GTK 1.x application from around 2000 to a
current version. The goal is simply making it work on the current
version of Ubuntu.
So I searched Google for a general porting guide, but was unable to
find anything useful, only a hint that there was one around in 2001. I
was finally able to locate this old guid via archive.org, but I'm
unsure, if it still applies to current versions of GTK+.

Does anyone know if there is a more recent guide on the net, or if the
old one from archive.org is still usable?
 

Take a look here: http://library.gnome.org/devel/gtk/2.21/migrating.html


   


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


DGSEAL_ENABLE: replace direct addressing in statusbar

2010-07-03 Thread Carlos Pereira

Hi,
How can I rewrite the following code, to be GTK 3.0 ready (without
addressing directly the label, forbidden by the -DGSEAL_ENABLE mechanism)?

statusbar = gtk_statusbar_new ();
gtk_misc_set_alignment (GTK_MISC (GTK_STATUSBAR (statusbar)-label), 
0.5, 0.5);


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


Re: DGSEAL_ENABLE: replace direct addressing in statusbar

2010-07-03 Thread Carlos Pereira

On 07/04/10 06:17, Nader Morshed wrote:

statusbar = gtk_statusbar_new ();
label = gtk_statusbar_get_message_area (GTK_STATUSBAR (statusbar));
gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5);
   
Thanks Nader, I believe you are in the right path (although the 
documentation actually says this returns a box, not a label):


http://library.gnome.org/devel/gtk/stable/GtkStatusbar.html#gtk-statusbar-get-message-area

Anyway this has been added in Gtk 2.20, I am still running 2.18.3, lots 
of users also, it might be better to wait...


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


Re: How I can do Double Buffer whether OpenGl Ext?

2010-02-10 Thread Carlos Pereira

And then you will have a expose callback similar to this:

int my_expose (GtkWidget *widget, GdkEventExpose *event, void *data)
{
GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (widget);
GdkGLContext *glcontext = gtk_widget_get_gl_context (widget);
app_window *my_window = APP_CAST_WINDOW data;

/*
* draw only last expose
*/

if (event-count  0) return TRUE;

if (gdk_gl_drawable_gl_begin (gldrawable, glcontext) == TRUE)
 {
 draw_my_window (my_window);

 if (gdk_gl_drawable_is_double_buffered (gldrawable) == TRUE)
   gdk_gl_drawable_swap_buffers (gldrawable);
 else
   glFlush ();

 glGetError ();

 gdk_gl_drawable_gl_end (gldrawable);
 }

return TRUE;
}

Regards,
Carlos

From the logo example:


/*

 * Configure OpenGL-capable visual.
 */

/* Try double-buffered visual */

glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB|
  GDK_GL_MODE_DEPTH  |
  GDK_GL_MODE_DOUBLE);
if (glconfig == NULL)
{
g_print (*** Cannot find the double-buffered visual.\n);
g_print (*** Trying single-buffered visual.\n);

/* Try single-buffered visual */

glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB   |
  GDK_GL_MODE_DEPTH);
if (glconfig == NULL)
{
g_print (*** No appropriate OpenGL-capable visual found.\n);
exit (1);
}
}

..


/* Set OpenGL-capability to the widget. */
gtk_widget_set_gl_capability (drawing_area,
  glconfig,
  NULL,
  TRUE,
  GDK_GL_RGBA_TYPE);




This function first tries to create a glconfig using double buffered, if fails, uses single buffer). This works on OS X 10.6 Snow Leopard. 





 EMAILING FOR THE GREATER GOOD
Join me

  

Date: Tue, 9 Feb 2010 04:41:12 -0300
Subject: How I can do Double Buffer whether OpenGl Ext?
From: grojas@gmail.com
To: gtk-app-devel-list@gnome.org

Hi,

I'm trying to do a double buffer with pixbuf and draw area, whether to use
OpenGL Ext, but i don't know if it is posible or not.

Any idea?

Thanks.

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

 		 	   		  
___

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

  


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


Re: tree view question / hightlighting rows

2010-01-24 Thread Carlos Pereira

Alexander Nagel wrote:

Hi,

i have a treeview which displays a list of filenames in one column and 
other things in other columns. I can iterate successfully through the 
list.
How can I highlight the current row? With highlight I mean that the 
row looks like selected by the user.
For example, this code selects the first row, exactly as if the user had 
clicked with the mouse:


GtkWidget *treeview;
GtkTreeSelection *selection;
GtkTreeModel *model;
GtkTreeIter iter;

selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
gtk_tree_model_get_iter_first (model, iter);
gtk_tree_selection_select_iter (selection, iter);
My next question/problem then is: if the list is longer than the 
current scrolledwindow, how can I autoscroll the hightlighted row is 
always visible to the user?

Hope you understand what I mean.
I am almost sure this was already discussed (several times) in this 
list... did you look into the arquives?

Carlos

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



___
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-20 Thread Carlos Pereira

Hi Tadej,
1) you were right, titles in combobox submenus can be easily removed 
calling gtk_cell_layout_set_cell_data_func, as demonstrated in gtk-demo.


2) I also found that the width of submenus can be easily set, with the 
property width-chars, applied to the cell_renderer.


I posted the relevant code below, in case it helps someone else.

Many thanks to Tadej Borovšak and Matthias Clasen, for clarifying this,
Carlos

renderer = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer, 
text, 0, NULL);

/* set the same width in chars for all submenus */
g_object_set (renderer, width-chars, 12, NULL);

/* hide the submenu titles */
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo),
renderer, hide_titles, NULL, NULL);

void hide_titles (GtkCellLayout *layout, GtkCellRenderer *renderer, 
GtkTreeModel *model, GtkTreeIter *iter, void *data)

{
int sensitive;

sensitive = TRUE;
if (gtk_tree_model_iter_has_child (model, iter) == TRUE)
 sensitive = FALSE;

g_object_set (renderer, sensitive, sensitive, NULL);
}



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


ComboBox submenus

2010-01-19 Thread Carlos Pereira
My ComboBox submenus are working fine. There are however a couple of 
visual details that could be improved, in my opinion.


I am sending as attachement a small (70 lines) working example  (C + 
makefile) showing my points:


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.


2) All pop up menus should have the same width. Currently this deppends 
entirely of the size of the label strings. The submenus for Main 1 and 
Main 2 have entirely different widths, and I think this looks 
unprofessional. The workaround I know is: add whitespaces at the end of 
the label strings.


3) The main menu has a large space between the labels and the  submenu 
arrows, I guess this is probably related with accelerators (which I am 
not using here) but it looks a bit ugly. I don't know any workaround for 
this. Pop up menus have the same issue.


I am planning to fill a bug report about this. If someone can prove me 
wrong or knows a solution for any of the three points discussed above, I 
would be glad to know.


Thanks!
Carlos

store = gtk_tree_store_new (1, G_TYPE_STRING);
gtk_tree_store_append (store, iter, NULL);
gtk_tree_store_set (store, iter, 0, Main 0, -1);

gtk_tree_store_append (store, iter, NULL);
gtk_tree_store_set (store, iter, 0, Main 1, -1);
gtk_tree_store_append (store, child, iter);
gtk_tree_store_set (store, child, 0, Short 1:0, -1);
gtk_tree_store_append (store, child, iter);
gtk_tree_store_set (store, child, 0, Short 1:1, -1);
gtk_tree_store_append (store, child, iter);
gtk_tree_store_set (store, child, 0, Short 1:2, -1);

gtk_tree_store_append (store, iter, NULL);
gtk_tree_store_set (store, iter, 0, Main 2, -1);
gtk_tree_store_append (store, child, iter);
gtk_tree_store_set (store, child, 0, Very very long 2:0, -1);
gtk_tree_store_append (store, child, iter);
gtk_tree_store_set (store, child, 0, Very very long 2:1, -1);

___
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 Carlos Pereira
It seems the mailling list is filtering even small tar.gz files as mine, 
so I posted it here:


http://www.gamgi.org/combo.tar.gz

Regards,
Carlos
My ComboBox submenus are working fine. There are however a couple of 
visual details that could be improved, in my opinion.


I am sending as attachement a small (70 lines) working example  (C + 
makefile) showing my points:


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.


2) All pop up menus should have the same width. Currently this 
deppends entirely of the size of the label strings. The submenus for 
Main 1 and Main 2 have entirely different widths, and I think this 
looks unprofessional. The workaround I know is: add whitespaces at the 
end of the label strings.


3) The main menu has a large space between the labels and the  submenu 
arrows, I guess this is probably related with accelerators (which I am 
not using here) but it looks a bit ugly. I don't know any workaround 
for this. Pop up menus have the same issue.


I am planning to fill a bug report about this. If someone can prove me 
wrong or knows a solution for any of the three points discussed above, 
I would be glad to know.


Thanks!
Carlos

store = gtk_tree_store_new (1, G_TYPE_STRING);
gtk_tree_store_append (store, iter, NULL);
gtk_tree_store_set (store, iter, 0, Main 0, -1);

gtk_tree_store_append (store, iter, NULL);
gtk_tree_store_set (store, iter, 0, Main 1, -1);
gtk_tree_store_append (store, child, iter);
gtk_tree_store_set (store, child, 0, Short 1:0, -1);
gtk_tree_store_append (store, child, iter);
gtk_tree_store_set (store, child, 0, Short 1:1, -1);
gtk_tree_store_append (store, child, iter);
gtk_tree_store_set (store, child, 0, Short 1:2, -1);

gtk_tree_store_append (store, iter, NULL);
gtk_tree_store_set (store, iter, 0, Main 2, -1);
gtk_tree_store_append (store, child, iter);
gtk_tree_store_set (store, child, 0, Very very long 2:0, -1);
gtk_tree_store_append (store, child, iter);
gtk_tree_store_set (store, child, 0, Very very long 2:1, -1);



___
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 Carlos Pereira

Hi Tadej,

many thanks for responding!
I saw your bug report, will study gtk-demo to understand how this can be 
achieved


Best regards,
Carlos


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

  


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


Re: Forcing GtkScrolledWindow to sroll

2010-01-11 Thread Carlos Pereira



Then I want to implement a drag scrolling.  The user will click and drag the 
image to make it scroll.

To write drag code in GTK you basically need to handle signals 
button_press_event and motion_notify_event, as exemplified below. 
Essentially drag operations depend of the difference between current x,y 
coordinates and old begin_x, begin_y coordinates (that you need to save 
yourself).


my_bool my_callback_notify (GtkWidget *widget,
GdkEventMotion *event, void *data)
{
my_structure = (cast to my_structure) data;
...
if (event-is_hint) gdk_window_get_pointer (event-window, x, y, state);
else
 {
 x = event-x;
 y = event-y;
 state = event-state;
 }

if (state != 0)
 {
 dx = y - my_structure-begin_x;
 dy = y - my_structure-begin_y;

 /* drag code: do something with dx, dy */
  ...
 }
my_structure-begin_x = x;
my_structure-begin_y = y;

return TRUE;
}

my_bool my_callback_press (GtkWidget *widget,
GdkEventButton *event, void *data)
{
my_structure = (cast to my_structure) data;
...
my_structure-begin_x = event-x;
my_structure-begin_y = event-y;

return TRUE;
}


Generally, you don't want to do this because it is inefficient if the
image is large.  Do not allocate a larger drawing area than the visible
part, do not use a viewport and, instead, just draw the visible part of
the image according to the scrollbar positions in the expose event.
  
I agree. By the way, do you need scrollbars at all? they might be 
usefull, to tell users how far are the image limits, but if they are 
cumbersome to use, it might be reasonable to discard them at all. An 
example of this is Google Maps, where you drag a drawing area with no 
scrollbars (of course this is an ideal example, because there are no 
image limits...). That would be easy to implement in GTK, you would use 
(dx,dy) to know what part of the image you want to show. And if you 
really need to tell users about the limits, perhaps you could use rulers 
on the side. My point is, 1-D scrolling becomes redundant when you have 
2-D dragging, more user-friendly...


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


Re: GtkNotebook switch-page Signal

2010-01-09 Thread Carlos Pereira

This is a typical callback for the switch-page signal:

void my_callback (GtkNotebook *notebook,
GtkNotebookPage *notebook_page, int page, void *data)
{
GtkWidget* vbox_page;

vbox_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), page);

1) page is the number (0 = first page, etc.) of the NEW notebook page.

2) vbox_page is the container that you used to build that NEW page, 
using code such as this:


vbox_page = gtk_vbox_new (FALSE, 0);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox_page, label);

3) if you really need the old page, just save it yourself (for example, 
a static variable (C) in the callback will do). I have some extensive 
experience with GTK notebooks, they work quite well. I don't remember a 
single case where I needed the old page (what a notebook page shows or 
does should not depend of the page previously selected by the user...)


Regards,
Carlos

David Nečas wrote:
  

On Fri, Jan 08, 2010 at 05:59:27PM -0500, dhk wrote:


When changing from one tab to another in a GtkNotebook I often need to
know the tab that was selected.  It seems the switch-page signal just
tells the current page and there are functions that tell the current
page and will navigate through the page, but I don't see anything that
will tell tell the destination page or the tab that received the signal.

Does anyone know how to determine this?
  

switch-page gives you the new page (i.e. the page the notebook is
switching to).  What is `destination' page if not this?

Yeti





It looks like it gives the page I switched from, but I want the page I
switched to.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


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

GtkComboBox submenus

2009-12-17 Thread Carlos Pereira

Is there a way to create GtkComboBox menus with submenus?

The logical way to achieve this would be to use a GtkTreeStore model, 
and indeed it works as expected,
except that each first level item appears also as a second level title, 
that can be selected...


disabling a first level item disables the whole subtree, so this cannot 
be used to disable the second level titles...


Or the only solution is to use
gtk_combo_box_set_wrap_width (GTK_COMBO_BOX (combo), width)
with width  1? My data has some nice structure, so the submenus 
approach looks slightly better...


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


Re: Clearing GtkComboBoxEntry

2009-12-08 Thread Carlos Pereira

David is right,

you should get the entry pointer with gtk_bin_get_child, and after that 
you handle this entry as any other entry:


entry = gtk_bin_get_child (GTK_BIN (combo_entry));
gtk_entry_set_text (GTK_ENTRY (entry), );

In GTK 2.0 you can also use this:
gtk_entry_set_text (GTK_ENTRY (GTK_BIN (combo_entry)-child), );
but this is not going to work in Gtk 3.0, as these objects will be 
sealed from outside access.


In my opinion, you should forget about redundant functions such as 
gtk_combo_box_get_active_text, having direct access to the entry pointer

is much better.

Regards,
Carlos

On Mon, Dec 07, 2009 at 07:52:02PM -0800, Steve Harrington wrote:
  
I have an application using GtkComboBoxEntry with a simple 2-column  
int/char * ListEntry model.  If the user enters data in the box (as  
opposed to using a pull-down selector) I can access the index with

  gtk_combo_box_get_active( GTK_COMBO_BOX(W) );
and the text with
  gtk_combo_box_get_active_text (GTK_COMBO_BOX(W));

The index is -1 as expected and the text is the text that what was entered.
The question is:  How do I clear the text field when I have finished  
with it.
From the FAQ and other documentation it seems that I should be able to  
access the actual GtkEntry widget within the GtkComboBoxEntry widget,  
get the GtkEntryBuffer, and clear it with  
gtk_entry_buffer_delete_text().  None of these buffer functions/headers  
are marked as depreciated but also none of them are my version of the  
gtk headers (/usr/include/gtk-2.0/gtk/gtkentry.h) or anywhere else in  
the gtk headers.



You can get the entry with gtk_bin_get_child().  At least that's what
the reference docs say.

Yeti

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

  


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


Re: GtkGLExt (was Re: Gtk 3.0)

2009-12-05 Thread Carlos Pereira

Dear Emmanuele,

yes. and that, apart from games and scientific/technical applications, it's not 
at all common.
  


the amount of code using OpenGL is relatively limited (hence niche) compared 
to the rest of applications in the GNOME stack (or even in the whole Linux ecosystem); 
it's *usage* is limited, not the size of the codebase.
  
If you go to Amazon and search for OpenGL books, you get this  list with 
2607 (!!!) results:


http://www.amazon.com/s/ref=nb_ss?url=search-alias%3Dstripbooksfield-keywords=openglx=20y=19

Many of these books have been published in the last 5 years, some in 
2008 and even 2009.


The fact is, the OpenGL community is much larger than our GTK community. 
If scientific/engineering applications are a niche in the GTK world, 
that is not a OpenGL weakness, that is a GTK weakness.


We must atract more scientifc/engineering applications for Linux and 
GTK, because this is exactly the kind of stuff that enterprises and 
universities are demanding.


If we have fantastic operating systems and desktop environments in the 
free software world, but most of the scientific/engineering aplications 
only run in Windows/Mac OS X, people will be forced to use them, even if 
they would rather prefer to use Linux/BSD... I have many friends in this 
situation...


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


Re: GtkGLExt (was Re: Gtk 3.0)

2009-12-04 Thread Carlos Pereira

Thanks Javier,
it's good to know that EmmanueleBassi 
http://live.gnome.org/EmmanueleBassi is now taking care of GtkGLExt 
integration with GTK...


Regards,
Carlos

Hello Carlos,

2009/12/3 Carlos Pereira jose.carlos.pere...@ist.utl.pt:
  

That's why I asked in the first message of this thread, what are the plans
regarding GtkGLExt. To the best of my knowledge, GtkGLExt is still the
official way to bridge GTK and OpenGL:

http://gtkglext.sourceforge.net/

are there plans to integrate this via Cairo and discard GtkGLExt? that was
mentioned in this list years ago...



OpenGL integration into GTK+ is part of project Ridley [1].
Here the bug report: [2]
The project was recently moved to gnome git too [3] and seems to be
quite active.

[1] http://live.gnome.org/ProjectRidley
[2] https://bugzilla.gnome.org/show_bug.cgi?id=119189
[3] http://mail.gnome.org/archives/gtkglext-list/2009-October/msg5.html
  


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


Re: GtkGLExt (was Re: Gtk 3.0)

2009-12-04 Thread Carlos Pereira

Hi Emmanuele,

I'm really not working on it - mainly for three reasons: 1) if you want to
use GL, GtkGlExt is good enough and integrating it into gtk+ it's not a
good idea;
1) If you think GtkGlExt should not be integrated with GTK+ that's fine 
for me.


2) GtkGlExt is good enough for GTK-2.0, I never had a single problem with 
GTKGLExt.

3) However GtkGlExt is not GTK-3.0 ready, because it cannot be compiled with 
SEAL_ENABLE and SINGLE_INCLUDES...

4) Scientific/engineering applications often use OpenGL, which is a well 
established, well documented, industry-standard with a large, vibrant 
community, as these foruns clearly show:

http://www.opengl.org/discussion_boards/

So all I am asking the GTK team is, please find a solution regarding OpenGL 
support for GTK-3.0... with or without GtkGLExt...

Regards,
Carlos


2) cairo should get GPU acceleration for 2D drawing, which is
what most of users really care about; 3) if you want a 3D canvas you should
be using Clutter.

Integrating raw GL inside a gtk+ application is a niche requirement enough
that I'm not at all sure it should be moved to gtk+ itself. And if you're
dropping into raw GL there is no way you are not a niche use case.

On 4 Dec 2009 18:13, Carlos Pereira jose.carlos.pere...@ist.utl.pt
wrote:

Thanks Javier,
it's good to know that EmmanueleBassi http://live.gnome.org/EmmanueleBassi
is now taking care of GtkGLExt integration with GTK...

Regards,
Carlos

  

Hello Carlos,   2009/12/3 Carlos Pereira 
  

jose.carlos.pere...@ist.utl.pt:  That's w...

___ gtk-app-devel-list mailing
list gtk-app-devel-l...@g...

  


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


Re: Gtk 3.0

2009-12-03 Thread Carlos Pereira

Thanks David,

It seems gtkglext does not work yet with SINGLE_INCLUDES. When I compile 
my app I get the following error message (gtkgkext is including 
gdkgltypes.h and this is flagged down):


In file included from /usr/include/gtkglext-1.0/gdk/gdkgltypes.h:22,
from /usr/include/gtkglext-1.0/gdk/gdkgl.h:27,
from /usr/include/gtkglext-1.0/gtk/gtkgl.h:22,
from ./engine/my_app_engine.h:28,
from ./engine/my_app_engine_array.c:12:
/usr/include/gtk-2.0/gdk/gdktypes.h:28:2: error: #error Only 
gdk/gdk.h can be included directly.


I am compiling on Ubuntu 9.10 (Gtk 2.18.3, I think) with:
CFLAGS = -g -O3 -Wall -ansi
override CFLAGS += -DG_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED \
   -DGDK_PIXBUF_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED \
   -DGSEAL_ENABLE \
   -DG_DISABLE_SINGLE_INCLUDES -DATK_DISABLE_SINGLE_INCLUDES \
   -DGDK_PIXBUF_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_SINGLE_INCLUDES

Carlos


FOO_DISABLE_SINGLE_INCLUDES prevents inclusion of indvidual headers (as
opposed to library-level headers such as glib.h).  It does not affect
what symbols are defined.

Yeti

  


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


Re: Gtk 3.0

2009-12-03 Thread Carlos Pereira
That's why I asked in the first message of this thread, what are the 
plans regarding GtkGLExt. To the best of my knowledge, GtkGLExt is still 
the official way to bridge GTK and OpenGL:


http://gtkglext.sourceforge.net/

are there plans to integrate this via Cairo and discard GtkGLExt? that 
was mentioned in this list years ago...


Regards,
Carlos
It seems gtkglext does not work yet with SINGLE_INCLUDES. When I compile  
my app I get the following error message (gtkgkext is including  
gdkgltypes.h and this is flagged down):



GtkGLExt is not Gtk+ 3.0 ready.  There are more problems in the demos
(some still use GtkFileSelection and they fail to receive pointer motion
events in Gtk+ 2.18+).  I'm not sure how much/if GtkGLExt is mainatained
at present.

Yeti


  


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


Re: Gtk 3.0

2009-12-02 Thread Carlos Pereira

Thanks Javier, thanks David,

Compiling with -DGSEAL_ENABLE these macros are flagged as errors:

1) GTK_WIDGET_SET_FLAGS (removed)
2) GTK_WIDGET_SENSITIVE (replaced by gtk_widget_is_sensitive or 
gtk_widget_get_sensitive)


However, apparently they are not in the list of deprecated symbols. 
Should that be changed?


could you point me to a documentation page listing macros and other 
things made obsolete with -DGSEAL_ENABLE, -DG_DISABLE_SINGLE_INCLUDES, 
-DGTK_DISABLE_SINGLE_INCLUDES, etc. and its replacements?


Thanks,
Carlos

You should try to compile your application with:

make CFLAGS+=-DGSEAL_ENABLE



and with -DG_DISABLE_SINGLE_INCLUDES, -DGTK_DISABLE_SINGLE_INCLUDES, etc.
  


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


Gtk 3.0

2009-11-30 Thread Carlos Pereira

Dear all,

1) My app is currently compiling without warnings, with Gtk 2.18.3 I 
believe (Ubuntu 9.10), at the compilation level:


CFLAGS = -g -O3 -Wall -ansi
override CFLAGS += -DG_DISABLE_DEPRECATED \ -DGDK_DISABLE_DEPRECATED \
-DGDK_PIXBUF_DISABLE_DEPRECATED \
-DGTK_DISABLE_DEPRECATED

This means that my app is (mostly) ready for Gtk 3.0?

2) GtkGLExt works on Windows?

3) It was planned long time ago, to replace entirely GtkGLExt by Cairo 
functionality. Is this going to happen in time for Gtk 3.0?


Many thanks,
Carlos
___
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 Carlos Pereira
Let's say you would like to retrieve some information for the selected 
row, not just the string name. You could add a (hidden) column to your 
store, with that information, and then get it back with 
gtk_tree_model_get. Let's say you would like to have a pointer to a 
function, for each of your rows, you would have something like this:


treeview = gtk_tree_view_new ();
...
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes (My_Title, renderer, 
text, 0, NULL);

gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);

/* treeview has 1 column, list_store has 2 columns */
store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
...
gtk_list_store_append (store, iter);
gtk_list_store_set (store, iter, 0, label0, 1, function, -1);
...
gtk_tree_view_set_model (treeview, store);
g_object_unref (store);

}
and then your callback would look like this:

void my_callback (GtkTreeView *treeview,
GtkTreePath *path, GtkTreeViewColumn *col, void *data)
{
model = gtk_tree_view_get_model (treeview);
if (gtk_tree_model_get_iter (model, iter, path) == FALSE) return;

/* get and execute pointer to function */
gtk_tree_model_get (model, iter, 1, function, -1);
(* function) (data);
}

Carlos

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 



Works. Thanks for your help
  

___
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 Carlos Pereira
As Tor already said, you can disable locale settings (and then 
everything will work as 15.00 in every country, not  15,00) 
with  gtk_disable_setlocale (), before starting gtk:


gtk_disable_setlocale ();
gtk_init (argc, argv);

Carlos

After i updated my system my previously working gtk+ application start to print 
wrong result.The problem is atof() i used in the program.The code is working as 
expected in a standart c console version.(Program reads some datas from file 
and make some calculations)The code i used is;

suppose that at line 62 the file have data;
10   5  15 B   15.031103

the code;

gchar *temp,cm[11];
gfloat m;
gint l00;
.

while(!feof(in)){
fgets(temp,30,in);



for(i=0;i10;i++) cm[i]=temp[i+15];

cm[10]='\0';
if(l==62) g_print(mass=%s\n,cm);/*prints 15.031103  */

m=atof(cm);

if(l==62) g_print(mass=%f\n,m);/*prints 15,00 notice that not   15.00
 it prints with the comma 15,00 */
l++;
}

I also tried sscanf(cm,%f,m) and m=strtof(cm,NULL);
always gives 15,00 When i try exactly the same code in a standart c program 
it is working as expected.


  
___

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

  


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


Re: Ctrl-Click keyboard mouse event

2009-11-11 Thread Carlos Pereira

Hi Emmanuel,
thank you very much, that's exactly what I needed,

Best regards,
Carlos


When a button press event is triggered, what is the proper way to know if
the user is pressing down the Ctrl key?



I think that this is what you need:

if (event-button == 1  (event-state  GDK_CONTROL_MASK) != 0)
{
  /* Button 1 with contro clicked */
}

  

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


SOLVED: Re: Problem with gtk_tree_selection_select_path: background color does not change

2009-11-10 Thread Carlos Pereira
This is nicely working for me now, I should have been doing something 
wrong before,

Carlos

Hi list,
I need to select multiple rows in a treeview,
directly from my code, in MULTIPLE selection mode.
This is a very simple treemodel, only one column
with a string.

Unfortunately, although gtk_tree_selection_select_path()
seems to select the indicated rows, the background color
of the rows do not change.

For example, running this code:
path = gtk_tree_path_new_from_string (1);
gtk_tree_selection_select_path (selection, path);
path = gtk_tree_path_new_from_string (3);
gtk_tree_selection_select_path (selection, path);

and then:
gtk_tree_selection_selected_foreach (selection,
static_foreach_list, data);

shows that the second (1) and fourt (3) rows have indeed
been selected, but the background color remains unchanged...

So my question is: how can I force GTK to change the background color 
of the selected rows?


Many thanks for your help, I searched the archives for
this mailling list, I did see this question posted, but
not a working answer... the same for the web...

Carlos




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


Problem with gtk_tree_selection_select_path: background color does not change

2009-11-05 Thread Carlos Pereira

Hi list,
I need to select multiple rows in a treeview,
directly from my code, in MULTIPLE selection mode.
This is a very simple treemodel, only one column
with a string.

Unfortunately, although gtk_tree_selection_select_path()
seems to select the indicated rows, the background color
of the rows do not change.

For example, running this code:
path = gtk_tree_path_new_from_string (1);
gtk_tree_selection_select_path (selection, path);
path = gtk_tree_path_new_from_string (3);
gtk_tree_selection_select_path (selection, path);

and then:
gtk_tree_selection_selected_foreach (selection,
static_foreach_list, data);

shows that the second (1) and fourt (3) rows have indeed
been selected, but the background color remains unchanged...

So my question is: how can I force GTK to change the 
background color of the selected rows?


Many thanks for your help, I searched the archives for
this mailling list, I did see this question posted, but
not a working answer... the same for the web...

Carlos

___
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-11-01 Thread Carlos Pereira

Tadej Borovšak wrote:

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.

  

Thanks Tadej,

so I will use the timeout method, which according to your explanation 
(and my testing) should work fine in all systems,


Cheers,
Carlos

Tadej


  


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

GtkTextView padding

2009-10-31 Thread Carlos Pereira

Hi all,

what is the standard, simple, way to add some padding inside a GtkTextView?

These functions work nice:
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (text), 10);
gtk_text_view_set_right_margin (GTK_TEXT_VIEW (text), 10);

but no equivalent functions seem to exist for top, bottom
(gtk_text_view_set_border_window_size adds space outside, not inside as 
I wish).


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


GtkTreeView: g_signal_handlers_unblock_by_func

2009-10-31 Thread Carlos Pereira

Hi all,

To avoid some reentrant callbacks, in a few cases I have to use code 
such as:


g_signal_handlers_block_by_func (widget, func, data);
do_stuff;
g_signal_handlers_unblock_by_func (widget, func, data);

Usually this works fine, but I have a Treeview where unblock
seems to be done too early, before GTK finnishes handling do_stuff, 
resulting in undesired callbacks. I solved the problem using a timer 
such as (to delay the unblock):


g_signal_handlers_block_by_func (widget, func, data);
do_stuff;
g_timeout_add (0, my_timer, data);

int my_timer (void *data)
{
g_signal_handlers_unblock_by_func (widget, func, data);
return FALSE;
}

As I said, this seems to work fine in all systems I tested (even with 
the timer delay set to 0...).


My questions are: 1) is there a better, more elegant, more robust, way 
of doing this? 2) why the bock/unblock mechanism does not work as 
expected in treeview?


Best regards,
Carlos
___
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 Carlos Pereira

Tadej Borovšak wrote:

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?

  

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...


I can prepare and send to you a working example, if you are interested.

Thank you very much,
Carlos

Tadej

  


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

Re: why do constructors return GtkWidget?

2009-09-09 Thread Carlos Pereira

Tristan Van Berkom wrote:

On Wed, Sep 9, 2009 at 2:53 AM, Emmanuel
Touzeryemmanuel.touz...@free.fr wrote:
  

Hi,


[...]
  

You know what I'm thinking... I think that this is from times where people
used to build GUIs in the code... When they were writing all the container
embedding and all, in C, building their dialogs. At that time that
convention surely helped, you were constantly adding widgets to containers
and so on. Today this is done in gtkbuilder and so what we have left is code
not doing so much embedding in code (though obviously it happens) but



Yes I would say its a historical thing, and I certainly hope that using
GtkBuilder can be the standard in the end (I guess we still have lots of
ground to cover).
  

Only over my dead body ;-)

Carlos

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

  


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


Re: GDK + GLib main loop

2009-08-12 Thread Carlos Pereira

Mihai Draghicioiu wrote:

I have found the way. Here is my code. Any idea where I can post it as a
tutorial?
  
Gtk Forums? they have a section specifically for Gtk example code: 
http://www.gtkforums.com/forum-15.html

http://www.gtkforums.com/
Carlos

#include stdlib.h
#include glib.h
#include gdk/gdk.h
#include gdk/gdkgl.h
#include GL/gl.h

GdkGLWindow *glwin = NULL;
GdkGLContext *glcontext = NULL;
GMainLoop *mainloop;

static void event_func(GdkEvent *ev, gpointer data) {
printf(event func\n);
switch(ev-type) {
case GDK_MAP:
break;
case GDK_DELETE:
g_main_loop_quit(mainloop);
break;
case GDK_KEY_PRESS:
printf(key pressed\n);
break;
case GDK_EXPOSE:
printf(got expose\n);
break;
case GDK_CONFIGURE:

if(gdk_gl_drawable_gl_begin(gdk_window_get_gl_drawable(ev-configure.window),
glcontext)) {
glViewport(0, 0, ev-configure.width,
ev-configure.height);

if(gdk_gl_drawable_is_double_buffered(gdk_window_get_gl_drawable(ev-configure.window)))
{

gdk_gl_drawable_swap_buffers(gdk_window_get_gl_drawable(ev-configure.window));
} else
glFlush();

gdk_gl_drawable_gl_end(gdk_window_get_gl_drawable(ev-configure.window));
}
break;
}

if(gdk_gl_drawable_gl_begin(gdk_window_get_gl_drawable(ev-any.window),
glcontext)) {
glClearColor(1.0, .5, .2, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 800, 600, 0, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glBegin(GL_QUADS);
glVertex2i(100, 100);
glVertex2i(400, 100);
glVertex2i(400, 500);
glVertex2i(100, 500);
glEnd();


if(gdk_gl_drawable_is_double_buffered(gdk_window_get_gl_drawable(ev-any.window)))
{

gdk_gl_drawable_swap_buffers(gdk_window_get_gl_drawable(ev-any.window));
} else
glFlush();

gdk_gl_drawable_gl_end(gdk_window_get_gl_drawable(ev-any.window));
}
}

int main(int argc, char **argv) {
gdk_init(argc, argv);
gdk_gl_init(argc, argv);

int config_attributes[] = {
GDK_GL_DOUBLEBUFFER,
GDK_GL_RGBA,
GDK_GL_RED_SIZE,1,
GDK_GL_GREEN_SIZE,  1,
GDK_GL_BLUE_SIZE,   1,
GDK_GL_DEPTH_SIZE,  12,
GDK_GL_ATTRIB_LIST_NONE
};
GdkGLConfig *glc = gdk_gl_config_new(config_attributes);

GdkWindowAttr attr;
attr.title = argv[0];
attr.event_mask = GDK_KEY_PRESS_MASK | GDK_STRUCTURE_MASK |
GDK_EXPOSURE_MASK;
attr.window_type = GDK_WINDOW_TOPLEVEL;
attr.wclass = GDK_INPUT_OUTPUT;
attr.width = 800;
attr.height = 600;
GdkWindow *win = gdk_window_new(NULL, attr, 0);

gdk_window_show(win);

glwin = gdk_window_set_gl_capability(win, glc, NULL);
glcontext = gdk_gl_context_new(GDK_GL_DRAWABLE(glwin), NULL, true,
GDK_GL_RGBA_TYPE);

gdk_event_handler_set(event_func, NULL, NULL); // this is used by GTK+
internally. We just use it for ourselves here

mainloop = g_main_loop_new(g_main_context_default(), FALSE);
g_main_loop_run(mainloop);

gdk_gl_window_destroy(glwin);
gdk_window_destroy(win);

return 0;
}



On Thu, Jul 23, 2009 at 8:07 AM, Emmanuel Rodriguez 
emmanuel.rodrig...@gmail.com wrote:

  

On Thu, Jul 23, 2009 at 5:33 AM, Mihai Draghicioiu 
mihai.draghici...@gmail.com wrote:



Hi all! I'm making an OpenGL application based on GDK + GtkGLArea. My code
so far works, but it has two issues:
  

Do you really need to have your application based on GDK? Can't you use GTK
instead?
By using GTK you can simply connect to the wanted signals and start a main
loop. This is going to be easier.

The tar.gz of gtkglext has an examples directory and you should be able to
start from one of their sample programs.

You should consider modifying your code to use GTK instead of GDK:

#include stdlib.h
#include gtk/gtk.h
#include gtk/gtkgl.h
#include GL/gl.h


static void
realize (GtkWidget *widget,
 gpointer   data)
{
  GdkGLContext *glcontext = gtk_widget_get_gl_context (widget);
  GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (widget);

  if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext)) {
return;
  }

  glClearColor(1.0, .5, .2, 1.0);
  glClear(GL_COLOR_BUFFER_BIT);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glOrtho(0, widget-allocation.width, widget-allocation.height, 0, -1,
1);
  glMatrixMode(GL_MODELVIEW);
  

Re: drawing area and motion hint mask

2009-07-29 Thread Carlos Pereira

Emmanuel Touzery wrote:

Hello,

I'm trying to detect mouse moves in a drawing area. The default 
behaviour without the GDK_POINTER_MOTION_HINT_MASK is as expected 
flooding me with events which I can't handle.
Perhaps you could have something as the code below (it works for me. It 
is based in GtkGlArea / GtkGLExt examples and discussions in this list 
with Havoc Pennington years ago)


I strongly suggest you to have a look in the examples coming with GtkGlExt,

Carlos Pereira
-
g_signal_connect (area, motion_notify_event,
G_CALLBACK (callback_area_notify), window);

int callback_area_notify (GtkWidget *widget,
GdkEventMotion *event, void *data)
{
my_structure *structure = (my_structure *) data;
GdkModifierType state;
int width = widget-allocation.width;
int height = widget-allocation.height;
int x, y;

if (event-is_hint) gdk_window_get_pointer (event-window, x, y, state);
else
 {
 x = event-x;
 y = event-y;
 state = event-state;
 }

if (state  structure-mask_button1)
 {
 }

else if (state  structure-mask_button2)
 {
 }

else if (state  structure-mask_button3)
 {
 }

/* save x,y as initial values, preparing to next scan:
difference between initial and current x, y values control speed */

structure-begin_x = x;
structure-begin_y = y;

return TRUE;
}





So I added that flag, but I still get way too many events.

In my handler I put this at the top:

printf (got mouse move (%d)!\n, event-is_hint);

And when I don't set the HINT_MASK then is_hint is 0, if I set the 
HINT_MASK then it's 1.

So it seems I'm setting the hint properly.

That I'm getting more events (not just one, because I never call 
gdk_event_request_motions() or gdk_window_get_pointer() anywhere in my 
code) it seems somehow someone else is calling 
gdk_event_request_motions() or gdk_window_get_pointer() (the examples 
on internet are not really clear on which one to call, or both, maybe 
this changed in the past?).


So I put a breakpoint on both those methods in GDB. And indeed I'm 
hitting very often this call:


#0  IA__gdk_window_get_pointer (window=0x88bdde8, x=0xbff3aef8, 
y=0xbff3aef4,

mask=0x0) at /build/buildd/gtk+2.0-2.16.1/gdk/gdkwindow.c:3315
#1  0xb7c300f0 in IA__gdk_device_get_state (device=0x849c840,
window=0x88bdde8, axes=0x0, mask=0x0)
at /build/buildd/gtk+2.0-2.16.1/gdk/x11/gdkinput-x11.c:788
#2  0xb7be5db4 in IA__gdk_event_request_motions (event=0x849c840)
at /build/buildd/gtk+2.0-2.16.1/gdk/gdkevents.c:889
#3  0xb7e657d0 in _gtk_tooltip_handle_event (event=0x887b0c0)
at /build/buildd/gtk+2.0-2.16.1/gtk/gtktooltip.c:1287
#4  0xb7d8720d in IA__gtk_main_do_event (event=0x887b0c0)
at /build/buildd/gtk+2.0-2.16.1/gtk/gtkmain.c:1643
#5  0xb7c1434a in gdk_event_dispatch (source=0x849c358, callback=0,
user_data=0x0) at 
/build/buildd/gtk+2.0-2.16.1/gdk/x11/gdkevents-x11.c:2364

#6  0xb78a7b88 in IA__g_main_context_dispatch (context=0x849c3a0)
at /build/buildd/glib2.0-2.20.1/glib/gmain.c:1814
#7  0xb78ab0eb in g_main_context_iterate (context=0x849c3a0, block=1,
dispatch=1, self=0x8483b80)
at /build/buildd/glib2.0-2.20.1/glib/gmain.c:2448
#8  0xb78ab5ba in IA__g_main_loop_run (loop=0x8611fb0)
at /build/buildd/glib2.0-2.20.1/glib/gmain.c:2656
#9  0xb7d877d9 in IA__gtk_main ()
at /build/buildd/gtk+2.0-2.16.1/gtk/gtkmain.c:1205

Something about tooltips. I don't have any tooltips for now in the 
application and certainly not in this drawing area...
So I don't understand how come that tooltip code is getting 
called. It prevents me from completely controlling when I'm getting 
mouse move events. That said, I'm surely getting much less events than 
before and maybe it's expected. It does complicate my life though. 
Is there a way to avoid this? What am I doing wrong?


I can't send the complete source of that program for now, it's 
already bigger. I'm hoping that it's obvious enough that someone can 
answer it without me having to extract the problem in a test program.


Thank you!

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



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


Re: gtk gis

2009-06-11 Thread Carlos Pereira

Andrea Zagli wrote:
do you know some widget that can display maps (from shp or postgis) 
and also allows very simple editing?



Perhaps GtkDrawingArea?
http://library.gnome.org/devel/gtk/stable/GtkDrawingArea.html

I use myself OpenGL areas, with GtkGLExt and Mesa, it works great. If 
you need more information on this please let me know.


Carlos

on google i found only (old) widgets without editing

thanks in advance

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



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


Re: GtkCombo events

2009-05-29 Thread Carlos Pereira
Actually it is a ComboBoxEntry that you need, which is derived from a 
ComboBox:

http://library.gnome.org/devel/gtk/stable/GtkComboBoxEntry.html

This is just a combination of a Entry with a ComboBox, so if you know 
how Entry and ComBox works, changing a Combo to a ComboBoxEntry should 
be relatively simple.


Carlos


frederico schardong wrote:

Hi,

I search, but not find the answer of my question..

What event is going on when the string selected of a GtkCombo is 
chenged?
  

From Gtk documentation:

|GtkCombo| has been deprecated since version 2.4 and should not be 
used in newly-written code. Use GtkComboBox 
http://library.gnome.org/devel/gtk/stable/GtkComboBox.html instead.


When using GtkComboBox, you can cast the combo box to a entry widget:

entry = GTK_ENTRY (GTK_BIN (combo)-child);

and now you can use the changed signal to detect when the contents 
of the entry widget has changed.


I had to convert a couple of GtkCombos to GtkComboBoxes myself, some 
time ago, so if you need some help please let me know.


Carlos

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



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


Re: Treeview CRITICAL Error

2009-04-27 Thread Carlos Pereira

dhk wrote:
only seems to compile when the -O (Optimization) option is present.  
However the options is set as -O0 (that's Dash-Oh-Zero) which should 
turn optimization off. I'd like to be able to compile the program 
without optimization, but so far this has just been an annoyance.
In my opinion every application should try to compile without warnings 
AND run fine with -O0, -O2, -O3. If your app does not compile AND run 
fine with -O0 to -O3 then you should stop and try to understand why. 
Think about it as an opportunity to know better your application!


Sometime ago, my app was behaving in a strange way when compiling with 
-O3, although it worked fine with -O2. I tracked down the problem to 
just 2, 3 lines of complex, cheesy code, separated by commas. Replacing 
these 2, 3 lines by 4, 5 lines of simple, robust code, solved the issue.
Third - the problem.  The application window has a notebook with a 
handful of tabs, each with different tree views on them.  The program 
seems to run fine.  However, when the second tab is selected, no 
matter what the previous tab was, the following three error lines get 
printed about three times.
I use a lot of notebooks and treeviews myself and they work fine. 
Probably this is a problem of compatibility between your TreeViews and 
TreeStores.


Are you sure the number of columns and their type is right? the 
treeviews are visible? the tree stores are visible? there is no 
confusion between them when you change from one Treeview to another? do 
you understand well the Treeview/TreeStore model?
Now the strange part.  The functions that call 
gtk_tree_store_prepend() and gtk_tree_view_set_cursor() get a tree 
view pasted in as a gpointer and then it's cast to a GtkWidget.  In 
the debugger when the tree view is printed it says value optimized 
out and when printed with a star '*' preceding the tree view it 
displays 0x0:  NULL.
You can print the memory address of your treeviews, when you create 
them, and then in a few selected places, for example:


printf (treeview in callback: %d\n, my_tree_view); /* ignore the 
warning */

fflush (stdout);

to assert if you get always the memory address you expect. Otherwise 
something is wrong.


If you get NULL when you expected your treeview address, this is usually 
an error easy to track down.


Carlos



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


Re: MenuItem activate signal

2009-02-06 Thread Carlos Pereira
I am fairly experienced with sensitive/insensitive states in Menuitems 
in old Option Menus and new Combo Boxes, but I am not sure in which 
context your Menuitem appears...


Could you explain what is the parent of your MenuItems? perhaps with a 
very small bit of code showing how they are created?


Regards,
Carlos

I have a callback that is called when a MenuItem is selected, but in the
callback the paramenter is which is suppose to be the MenuItem is NULL.
 The callback signature is void user_function (GtkMenuItem *menuitem,
gpointer user_data).

What I want to do is set menuitem to be insensitive when sellected and
then sensitive when the task it calls is done.

Any ideas?

Thanks,

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

  


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


Re: Full Screen mode behaves differently on two identical systems

2009-01-27 Thread Carlos Pereira
I have found myself some weird behaviour with fullscreen mode and modal 
windows in Gnome. I would suggest:


1) try a decent window manager, such as Enlightenment. This solved my 
issues. Of course this is not a good solution, but at least tells you 
where the problem is.
2) I guess you are using Gtk dialog widgets for your child dialogs. Try 
replacing one by a Gtk window widget, just to see if you get the same 
behavior. Using window widgets gives you 5 min more of work but in 
compensation you get a lot more control over your dialog.


Cheers,
Carlos

On Tue, Jan 27, 2009 at 9:20 AM, Marshall Lake ml...@mlake.net wrote:

  

 I have 2 computers, both running Ubuntu 8.10 (kernel2.6.27-9-generic).


When my gtkmm application goes to full screen mode, and the user brings up
any modal dialog (which is a child of the application main window), on one
system everything looks fine.  On the other, I get the System menu
(Applications Places System) appearing instead of the application menu. When
the dialog closes, the Application menu comes back.  This is somewhat
disconcerting to my users *grin*.

Clearly, the systems are different somehow, but I'm at a loss as to
exactly where and why it would make a difference.  I have multiple examples
of each behavior.  So far, it seems that older PCs and newer netbooks have
the bad behavior, while my development laptops and some newer desktop PCs
work flawlessly.

The same bad/good behavior happened when all my machines were running
Ubuntu 8.04 with multiple kernels.

Any ideas?

  

Are you moving executables or recompiling from machine to machine?  Are the
compiler versions the same across the machines?

--
Marshall Lake -- ml...@mlake.net -- http://mlake.net




Both.  I've tried building on the good machine and moving to the bad as
well as building on the bad.  In either case, the bad machines exhibit the
bad behavior.  And yes, the compiler versions are the same.  I can really
take 2 machines, install Ubuntu 8.10 on each, get all the build-essentials
etc. that I need, and build up 2 executables that work differently on each
machine.

  


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


Re: An 'oldie' question... GtkCList anyone?

2009-01-27 Thread Carlos Pereira
I have changed recently my CList widgets to TreeView. I suggest you 
implement a small test case, learn everything you need to your own 
purposes, and then (and only then) replace everything. I am almost in 
the end of replacing 119 option menus to combo boxes, so I understand 
how you feel...


Carlos

first of all I warmly suggest you to update your code to
GtkTreeView.

Yes - I'm planning on doing that. But the application has _lots_ of

CLists.


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


Re: grep

2008-10-03 Thread Carlos Pereira
Well, the list yes... the posts, aparently not... :-)

Best regards
carlos

2008/10/2 Ruben Safir [EMAIL PROTECTED]:
 is this working?
 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




-- 
=
Carlos José de Almeida Pereira
Ilhéus - Bahia - Brasil

BLOG:
  http://starfightercarlao.blogspot.com
  http://starfightercarlaoenglish.blogspot.com (english version)


Felicidade se acha é em horinhas de descuido.

Qualquer amor já é um pouquinho de saúde, um descanso na loucura.

  (Guimarães Rosa, ambas)
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: gtkmm and autoconf

2008-10-03 Thread Carlos Pereira
Hello Ruben,

I cannot help with this issue, sorry.

But I suggest you post it on the main list at

[EMAIL PROTECTED]

In this list there are allways many messagens, I think it will be
easier to find someone to help you.

Best regards1

Carlos




On Thu, Oct 2, 2008 at 1:31 PM, Ruben Safir [EMAIL PROTECTED] wrote:

 Hello

 I'm really a novice at autoconf and automake and trying to learn some
 gtkmm but I'm running into a problem that I just don't have the
 familiarity to solve and I'd like to request some help

 I've done a google search for a solution and came up blank so I hope
 someone can help me here.

 I'm working from documentation here
 http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/sec-headers-and-linking.html
 http://www.openismus.com/documents/linux/automake/automake.shtml#ExampleFiles
 http://www.elitecoders.de/mags/cscene/CS2/CS2-10.html
 http://www.openismus.com/documents/linux/automake/automake.shtml
 and of course the GNU manual and http://sources.redhat.com/autobook/

 I need to include the include and library flags into autoconf and
 automake and it seems to fail to pickup the gtkmm and gtk library

 I'm using this autogen.sh script
 -
 #! /bin/sh

 # $Id: autogen.sh,v 1.4 2002/12/02 01:39:49 murrayc Exp $
 #
 # Copyright (c) 2002  Daniel Elstner  [EMAIL PROTECTED]
 #
 # This program is free software; you can redistribute it and/or modify
 dir=`echo $0 | sed 's,[^/]*$,,'`
 echo $dir
 test x${dir} = x  dir='.'

 if test x`cd ${dir} 2/dev/null  pwd` != x`pwd`
 then
echo This script must be executed directly from the source
 directory.
exit 1
 fi

 rm -f config.cache acconfig.h

 echo - libtoolize. \
 libtoolize --force   \
 echo - aclocal.\
 aclocal  \
 echo - autoconf.   \
 autoconf \
 echo - autoheader. \
 autoheader   \
 echo - automake.   \
 automake --add-missing --gnu \
 echo \
 ./configure $@ exit 0

 exit 1
 



 This is my top level configure.ac
 
 AC_INIT(src/one_window.cc)

 AM_INIT_AUTOMAKE(one_window,0.1)
 AM_CONFIG_HEADER(config.h)

 AC_PROG_CC
 AC_PROG_CXX

 AC_PROG_INSTALL
 AC_PROG_LIBTOOL

 PKG_CHECK_MODULES([MYAPP], [gtkmm-2.4 = 2.4.0])
 AC_OUTPUT(Makefile src/Makefile)
 --




 This is my toplevel Makefile.am
 

 SUBDIRS = src
 EXTRA_DIST=autogen.sh
 




 This is my src directory Makefile.am
 ___

 bin_PROGRAMS = onewindow
 onewindow_SOURCES = one_window.cc

 __


 and the C++ code is very simple
 one_window.cc
 _
 #include gtkmm.h

 int main(int argc, char *argv[])
 {
Gtk::Main kit(argc, argv);

Gtk::Window window;

Gtk::Main::run(window);

return 0;
 }
 _



 Everything seems to work except for the make command

 [EMAIL PROTECTED]:~/cplus/pharm/gmm make
 make  all-recursive
 make[1]: Entering directory `/home/ruben/cplus/pharm/gmm'
 Making all in src
 make[2]: Entering directory `/home/ruben/cplus/pharm/gmm/src'
  cd ..  /bin/sh /home/ruben/cplus/pharm/gmm/missing --run automake-1.9
 --gnu
 src/Makefile
  cd ..  /bin/sh ./config.status src/Makefile depfiles
 config.status: creating src/Makefile
 config.status: executing depfiles commands
 make[2]: Leaving directory `/home/ruben/cplus/pharm/gmm/src'
 make[2]: Entering directory `/home/ruben/cplus/pharm/gmm/src'
 if g++ -DHAVE_CONFIG_H -I. -I. -I.. -g -O2 -MT one_window.o -MD -MP
 -MF .de
 ps/one_window.Tpo -c -o one_window.o one_window.cc; \
 then mv -f .deps/one_window.Tpo .deps/one_window.Po; else rm -f
 .deps/one_w
 indow.Tpo; exit 1; fi
 one_window.cc:1:19: gtkmm.h: No such file or directory
 one_window.cc: In function `int main(int, char**)':
 one_window.cc:5: error: `Gtk' undeclared (first use this function)
 one_window.cc:5: error: (Each undeclared identifier is reported only
 once for
   each function it appears in.)
 one_window.cc:5: error: syntax error before `::' token
 make[2]: *** [one_window.o] Error 1
 make[2]: Leaving directory `/home/ruben/cplus/pharm/gmm/src'
 make[1]: *** [all-recursive] Error 1
 make[1]: Leaving directory `/home/ruben/cplus/pharm/gmm'
 make: *** [all] Error 2


 The resulting Makefile.in has

 MYAPP_CFLAGS = @MYAPP_CFLAGS@
 MYAPP_LIBS = @MYAPP_LIBS@


 and the src level Makefile has

 MYAPP_CFLAGS = -DXTHREADS -D_REENTRANT -DXUSE_MTSAFE_API
 -I/opt/gnome/include/gtkmm-2.4 -I/opt/gnome/lib/gtkmm-2.4/include
 -I/opt/gnome/include/glibmm-2.4 -I/opt/gnome/lib/glibmm-2.4/include
 -I/opt/gnome/include/gdkmm-2.4 

Re: Windows verses Dialogs

2008-06-15 Thread Carlos Pereira

dhk wrote:
When should a dialog be used instead of a window?  Can't a window 
always be used?  Do you give anything up when using a dialog?  What's 
the difference?



I have more than 100 task dialogs in my app.

I NEVER use dialogs... always windows! you have much more flexibility,
your code is simpler, all this at the price of adding a few widgets and 
signals yourself...


I am sure you will get different opinions on this subject... ;-)

Carlos

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



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


g_signal_connect

2008-06-15 Thread Carlos Pereira

For the sake of elegance, which version people like more?

1) g_signal_connect (widget, signal,
G_CALLBACK (callback), data);

2) g_signal_connect (G_OBJECT (widget), signal,
G_CALLBACK (callback), data);

3) g_signal_connect (GTK_OBJECT (widget), signal,
G_CALLBACK (callback), data);

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


Re: g_signal_connect

2008-06-15 Thread Carlos Pereira

Brian J. Tarricone wrote:

On Sun, 15 Jun 2008 19:40:22 +0100 Carlos Pereira wrote:

  

For the sake of elegance, which version people like more?

1) g_signal_connect (widget, signal,
G_CALLBACK (callback), data);



I think this was the intended use -- the first param is of type
gpointer so you don't have to use a cast macro like in #2.

  

Most code (but not all) in gtk-demo uses this version...

2) g_signal_connect (G_OBJECT (widget), signal,
G_CALLBACK (callback), data);



... but out of (probably stupid) habit, I tend to use this one most of
the time...

  
but most of the code in the examples directory, come with the G_OBJECT  
cast...

3) g_signal_connect (GTK_OBJECT (widget), signal,
G_CALLBACK (callback), data);



Definitely not this one...  *waves arms* GtkObject doesn't exist! *waves
arms*
  
Excellent, one less to choose from... I am coming from GTK 1, that's 
why... ;-)


It's interesting anyway, that compiling with
   -DG_DISABLE_DEPRECATED  \
   -DGDK_DISABLE_DEPRECATED\
   -DGDK_PIXBUF_DISABLE_DEPRECATED \
   -DGTK_DISABLE_DEPRECATED
activated, no warning is reported, and the signal works just fine,
that's why I didn't notice that this was a no no

Anyway, GtkObject still exists (I supose mostly because of GtkAdjustment
and other old structures?): 
http://library.gnome.org/devel/gtk/stable/GtkAdjustment.html

http://library.gnome.org/devel/gtk/stable/GtkObject.html

pkg-config --modversion gtk+-2.0:
Gtk 2.12.8

Thanks a lot,
Carlos

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

  


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


Re: How do I use the fullscreen in a gtkmm app?

2008-06-11 Thread Carlos Pereira

Garth's KidStuff wrote:

Hi All,

   I notice that quite a few apps (firefox, gimp, terminal, etc. -- but not
   gedit, huh?) have the option to toggle fullscreen mode in their view menu
   using the F11 key.  How would I implement this in my Gtkmm app?
  

Connect the key_press_event to your top window, ot to a drawing area,
and then prepare a callback along these lines (sorry, C code):

#include gdk/gdkkeysyms.h

void function_handle_key_press (GtkWidget *widget,
GdkEventKey *event, void *data)
{
GtkWidget *window = (GtkWindow *) data; /* this is just a simple example */
static int fullscreen = FALSE;

switch (event-keyval)
 {
 case GDK_F11:
 if (fullscreen == FALSE)
   {
   gdk_window_raise (window-window);
   hide decorations;
   gtk_window_fullscreen (GTK_WINDOW (window));
   fullscreen = TRUE;
   }
 else
   {
   show decorations;
   gtk_window_unfullscreen (GTK_WINDOW (window));
   fullscreen = FALSE;
   }
 break;
 }



Thanks in advance

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

  


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


changing properties in a Treemodel in a Combobox

2008-06-09 Thread Carlos Pereira

Hullo,

Is there a way to easily change a property in a GtkTreeModel,
when something else changes in the interface?

I need to disable/enable specific rows (change the sensitivity) in a 
GtkComboBox, depending on users actions.


gtk-demo shows how to set the sensitivity of a specific row, when the 
tree model is created. To change this sensitivity, the only way I know 
is to create a new renderer, with code as this:


gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo));
renderer = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer, 
text, 0, NULL);
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo), renderer, 
set_sensitivity, NULL, NULL);


Different functions set_sensitivity, can then be used
to set different sensitivity states for the whole treemodel.

Is this the right way to change properties in a treemodel,
at least in a combobox, or is there a simpler way to achieve
the same thing?

something like this?
gtk_combo_box_set_sensitive (combo, row, state);

Thanks for all your help!
Carlos
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: gtk_combo_box with a specialized top line

2008-05-06 Thread Carlos Pereira

  Is it possible to 
 retrieve the entry widget of the combo box so I can call 
 gtk_entry_set_text with it?

   
entry = GTK_ENTRY (GTK_BIN (combo_box)-child;

Carlos

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


sensitive state in ComboBox menus

2008-04-27 Thread Carlos Pereira
Hi!

How can I set a row in a combobox menu as insensitive/sensitive
and know the current sensitive state, for:

1) a combo box created with gtk_combo_box_new_text

2) a more general combo box created with a tree model

In option menus, I used:
gtk_widget_set_sensitive (item, FALSE);

but this does not work here, as rows are not widgets anymore...
Many thanks for your help!

Carlos|| 
http://library.gnome.org/devel/gtk/stable/GtkComboBox.html#gtk-combo-box-new-text
|| 
http://library.gnome.org/devel/gtk/stable/GtkComboBox.html#gtk-combo-box-new-text
 

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


Going fullscreen and back

2008-04-27 Thread Carlos Pereira
Hi there,

The small working code below shows
how my app goes fullscreen and back.

1) Is there a better way of doing this?

2) This code works fine in Enlightenment,
KDE, BlackBox, IceWM, etc. In Gnome and XFCE
it works, but the desktop bars are still visible
(I suppose it should be possible to change this?).

However, in GNOME and only in GNOME, I have to
subtract 1 pixel, on width or height, for this to work.
In other words, if I replace this:

gdk_window_move_resize (window-window,
0, 0, gdk_screen_width (), gdk_screen_height () - 1);

by this:
gdk_window_move_resize (window-window,
0, 0, gdk_screen_width (), gdk_screen_height ());

poor Gnome WM gets confused, indeed goes fullscreen,
but does not come back... :-(

What is the best way to handle this?
going fullscreen is a very useful feature
in many scientific/engineering apps.

Many thanks,
Carlos

*** working code: going fullscreen and back ***
#include gtk/gtk.h
#include gdk/gdkkeysyms.h

int x, y, w, h;

int press_event (GtkWidget *widget, GdkEventKey *event, GtkWidget *window)
{
static int fullscreen = FALSE;

switch (event-keyval)
  {
  case GDK_Escape:
  if (fullscreen == FALSE)
{
gtk_window_get_position (GTK_WINDOW (window), x, y);
gtk_window_get_size (GTK_WINDOW (window), w, h);

gtk_window_set_decorated (GTK_WINDOW (window), FALSE);
gdk_window_raise (window-window);
gdk_window_move_resize (window-window,
0, 0, gdk_screen_width (), gdk_screen_height () - 1);
fullscreen = TRUE;
}
  else
{
gtk_window_set_decorated (GTK_WINDOW (window), TRUE);
gdk_window_move_resize (window-window, x, y, w, h);
fullscreen = FALSE;
}
  }

return FALSE;
}

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

gtk_init (argc, argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_set_size_request (window, 200, 200);
g_signal_connect_after (G_OBJECT (window),
key_press_event, G_CALLBACK (press_event), window);
gtk_widget_show (window);

gtk_main ();
return 0;
}

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


Re: Going fullscreen and back

2008-04-27 Thread Carlos Pereira
Jim George, Kevin DeKorte wrote:
 Why not use gtk_window_fullscreen? I've only tried it on a Gnome desktop, it 
 works well.
 Why don't you just use
 gtk_window_fullscreen  / gtk_window_unfullscreen?
   
Jim, Kevin, Thanks!

It works fantastically well, I just tried it on GNOME, XFCE, KDE, 
Enlightenment, Blackbox, IceWM, always with correct results.

Moreover, is is much faster than my version and all the annoying
flashing effects are gone!

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


Re: Learning Glade

2008-04-26 Thread Carlos Pereira

 However, I feel it will be easier for me to write graphical applications
 with an interface designer. The GNOME Library
 (http://library.gnome.org/ ) wasn't very useful and I haven't been able
 to find any decent, up-to-date tutorials on Glade.
   
GTK Forums have several examples with C and Glade:
http://www.gtkforums.com/forum-15.html

Carlos
 Links and/or sample code will be appreciated :)

 ~The Unix Geek
 http://theunixgeek.blogspot.com/

   

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


Re: Location entry in GtkFileChooser

2008-04-16 Thread Carlos Pereira
Hi,
You were right,  gtk_file_chooser_get_uri () gives me
correctly the contents in the Location GtkEntry. Sort off:

If I write http://www.app.org/, I get the same.
However, if I write http://www.app.org (without the final slash) I get:

http%3A%2F%2Fwww.app.org

Other problems still remain. When I write, say,
ftp://ftp.my_site.org/my_path/my_file.xml

too clever GTK immediately prompts a dialog of his own, asking me for
a user/password combination, or a click for anonymous... even when
I explicitly said, to disable Gtk network code:

gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (filechooser), TRUE);

I don't want that dialog at all, the anonymous ftp is chosen automatically
(as in any browser...) the question is, how can I disable it? GTk is 
obviously
connecting the GtkEntry changed signal... but how can I accees it? :-(

Other question, GTK always, show at least to me, a default file, (the 
first one)
in the File List and as a consequence, in the Location Entry, which in 
my opinion
is wrong. This seems related with the equivalent issue I reported weeks 
ago about GtkTreeView: a default is always shown, even when it makes no 
sense.

I still think the best solution for most problems, not all :-(, I have 
with Gtkfilechooser
is to get acess to the Location GtkEntry... How can I do that?

Actually this is a matter of principle: as a GTK user, I should be able 
to access
ALL the relevant, visble widgets in ANY Gtk dialog... let's say I want 
to change
the base color of that Entry, light yellow, to signal some secure 
connection.
How can I possibly do that, if I have no access to the GtkEntry in the 
first place?

Thank you very much, for your interest in this matter
Carlos
 The reason is, in my app, I accept local and remote addresses as
 well. It works
 
 I've never used this function, so I may be wrong, but you may try
 gtk_file_chooser_get_uri() instead of gtk_file_chooser_get_filename()
 to retrieve the entry value.

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


Re: Location entry in GtkFileChooser

2008-04-15 Thread Carlos Pereira
Martin (OPENGeoMap) wrote:

 Hullo,

 In a GTkFilechooser, how can I acess the information
 on the Location entry? I only find functions to get
 the full filename and uri but not the actual short
 filename...

  

 I don´t understand well??

 are you talking about filters???

No,
I am talking about the GtkEntry that is next to the GtkLabel that
says Location:, the place where the file shortname is written.

So if I write foo.xml, I want to get that shortname back, not just the 
fullname,

Carlos
 Something like this??

 GtkFileFilter *filter;
 filter = gtk_file_filter_new ();
 gtk_file_filter_add_pattern (filter, *.doc);
 gtk_file_filter_set_name(filter, microsoft word);
 gtk_file_chooser_add_filter (dialog,filter);





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


Re: Location entry in GtkFileChooser

2008-04-15 Thread Carlos Pereira
Luis Menina wrote:
 Hi Carlos.

 Well, I'm not familiar with GtkFileChooser, but I think you should 
 retrieve the full filename, and then use g_path_get_basename to get 
 the short filename.

Thanks, that is a good suggestion, unfortunately it fails in my case. I 
really need
to have access to the GtkEntry next to Location, to get the information 
in there.

The reason is, in my app, I accept local and remote addresses as well. 
It works
like this:

If the user writes:
http://www.my_site.org/my_path/my_file.xml
my app tries to fetch that file by HTTP (and ignores the GTK fullname).

If the users writes:
ftp://ftp.my_site.org/my_path/my_file.xml
my app tries to fetch that file by anonymous FTP (and ignores the GTK 
fullname).

Otherwise, my app will consider the file as an ordinary file,
and then normal procedure applies: get the GTK fullname, etc...

Unfortunatly GTK tries to parse the GtkEntry before sending it to me,
and gtk_file_chooser_get_filename returns NULL when the shortname
starts with http:// or ftp:// which in turn makes it impossible to use
g_path_get_basename :-(

So I really must have access to the Location GtkEntry,
Carlos
 Cheers,

 Luis

 Carlos Pereira a écrit :
 Hullo,

 In a GTkFilechooser, how can I acess the information
 on the Location entry? I only find functions to get
 the full filename and uri but not the actual short
 filename...

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



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


Re: Preventing Multiple instance of GTK application

2008-04-14 Thread Carlos Pereira
Liam R E Quin wrote:
 On Sat, 2008-04-12 at 15:16 +0100, Carlos Pereira wrote:

   
I agree with everything you said.

But in some cases lock files can be useful... this is the way
vim checks if other instances of the same file are open,
so the new instance is open in read-only mode... of course
you need to remove the .filename.swp file yourself, if your machine
crashs... as you said...

I suppose it depends of the specific needs... but in general
I agree with your advices, thank you!

Carlos
 You can write a .lock file everytime you start and then remove it when 
 you close. To know if other instance is running, you just have to check 
 if your .lock file exists.
 

 Please don't do this.

 If you must, take into account
 (1) multiple instances may create the file -- especially if it is
 on a network file system.  You can use O_CREAT|E_EXCL but it
 is not guaranteed to work over a network and neither in
 practice.

 (2) after a system crash, or if your application crashes, the lock
 file will not be removed.
 A way round this is to make the lock file by a symbolic link
 to a non-existant file with your process ID in it, and then on
 startup to check if that process name exists use kill(the_proc, 0),
 but this will fail on a network drive if the program is running on
 another machine.
 A way round this is to include your machine's IP address in the
 link, but this fails on a laptop (say) that gets a new IP address
 each time it starts and which might get shut down quickly.

 (3) if your application was run as root, or as another user, you might
 not be able to delete the lock file.

 (4) the above 3 items don't have portable solutions between operating
 systems.

 It is much better to use dbus, or an X Windows property..

 and even better to use a library that packages all this stuff,
 as was suggested by others.

 If you do end up making a lock file, consider making it a directory,
 as there are generally fewer locking problems.

 best,

 Liam

   

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


Location entry in GtkFileChooser

2008-04-14 Thread Carlos Pereira
Hullo,

In a GTkFilechooser, how can I acess the information
on the Location entry? I only find functions to get
the full filename and uri but not the actual short
filename...

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


Re: Preventing Multiple instance of GTK application

2008-04-12 Thread Carlos Pereira
Ajax John wrote:
 Hi,

 I have written a gtk application on my Linux system.
 At present I can open or start multiple instances of my application.
 how can I modify my code such that at a time only one instance of my
 application is running on my system.


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

   
You can write a .lock file everytime you start and then remove it when 
you close. To know if other instance is running, you just have to check 
if your .lock file exists.

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


GtkTreeView Size Issue

2008-04-10 Thread Carlos Pereira
Hi,
The working code below shows a two-column list, where the second
title, Pages, is partially overwritten by the scrolled window:

http://www.gamgi.org/treeview.png

When the scrolled window is inactive, or when gtk_widget_set_size_request
is commented out, the title Pages looks fine.

A simple workaround is to add three spaces to the last title,
Pagesinstead of Pages, but this is not elegant...

I am doing something wrong? actually this is a old issue,
GtkCList had exactly the same problem, five years ago...

According to pkg-config --modversion gtk+-2.0, I am running GTK 2.12.5

Thanks!
Carlos

 working code **
#include gtk/gtk.h

int main (int argc, char **argv)
{
GtkWidget *window;
GtkWidget *scrolled;
GtkWidget *treeview;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
GtkListStore *store;
GtkTreeIter iter;
GtkRequisition size;
int i, max;

gtk_init (argc, argv);

window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

scrolled = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (window), scrolled);

treeview = gtk_tree_view_new ();
gtk_container_add (GTK_CONTAINER (scrolled), treeview);

renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes (Subject, renderer, 
text, 0, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
column = gtk_tree_view_column_new_with_attributes (Pages, renderer, 
text, 1, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);

/*
 * When the scrolled window is hideen (max = 10) the title Pages is fine.
 */

max = 50;
store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
for (i = 0; i  max; i++)
  {
  gtk_list_store_append (store, iter);
  gtk_list_store_set (store, iter, 0, Documentation, 1, 1, -1);
  }
gtk_tree_view_set_model (GTK_TREE_VIEW (treeview),
GTK_TREE_MODEL (store));
g_object_unref (store);

/*
 * when gtk_widget_set_size_request is commented,
 * the title Pages looks fine.
 */

gtk_widget_size_request (treeview, size);
if (size.height  100) size.height = 100;
if (size.height  200) size.height = 200;
gtk_widget_set_size_request (treeview, -1, size.height);

gtk_widget_show_all (window);

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


Re: GtkTreeView: GTK_SELECTION_SINGLE not working?

2008-04-04 Thread Carlos Pereira
Thanks for replying!

I certainly would be glad if proved wrong, but I see three problems here,
two are human interface issues, the other is a technical issue.


1) In GtkTreeview with GtkListStore, show always the first item as default,
when selection is SINGLE or BROWSE

Sometimes it makes sense to have a default, sometimes it doesn't.

If you are selecting fonts, it makes sense to show medium as default.

If you are selecting hotels for vacations, it makes no sense to have
a default. The first hotel for default? why? users will suspect that
you are pushing that hotel on them!

One of my lists contains crystallographic space groups. When showing
all of them they are 230. The first ones are not common in Nature. The
most found in metals, ceramics, minerals are, say the hexagonal and
cubic ones, which are the last ones in the list. Which group should I show
as default? The number 1, as GTK wants? it is a triclinic group, seldom used
in crystallographic work... most important in metals are groups 194, 
225, 229...
Clearly the best choice is: show no default, the user chooses!

In GTK_SELECTION_SINGLE there is always a default, for a GtkListStore,
and this default is the first item on the list. This is wrong! If I 
think that a default
should be set, I should be able to easily do it myself, not GTK for me!

Interestingly enough, when GtkTreeStore is used, then no default is set...
even for GTK_SELECTION_BROWSE! even when the tree nodes have no
child, so they behave exactly as list nodes (so the SAME lists produced
with TreeStore and ListStore behave differently...)

only when the user clicks, something is selected...

A simple workaround is to start with GTK_SELECTION_NONE,
and then change to GTK_SELECTION_BROWSE, after the window is shown.
This way no default is shown initialliy.

***
2) Click to select, Ctr Click to unselect

In computer interfaces, everytime we have two-state choices (up-down, 0-1,
yes-no, true-false), the solution should be: click to change the state. 
So if you are in
state 0, clicking takes you to state 1, clicking again takes you to 
state 0, and so on...

This is the way toogle and check buttons work. When you want to maximize a
window you click on the WM decorations, to restore the window you click 
again
on the same WM decorations. There are many examples of this...

Select/Unselect rows is clearly a two-state operation, from the point of 
view
of users, so it should work in the usual way: click to select, click 
again to
unselect, click again to select, exactly as in toogle and check buttons...

Clicking to select rows and Ctrl Clicking to unselect them, makes as 
much sense
as Clicking to toggle buttons, and Ctrl Clicking to untoggle them...
this is exactly the opposite of HIG common-sense guidelines...

*
3) In both GTK_SELECTION_SINGLE and GTK_SELECTION_BROWSE modes,
with a GtkListStore, this code gets the correct selection, when clicking 
on a row,
if you are NOT pressing Ctrl or Shift keys:

GtkTreeSelection *selection;
GtkTreeModel *model;
GtkTreeIter iter;
char *name;

selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
if (gtk_tree_selection_get_selected (selection, model, iter))
  {
  gtk_tree_model_get (model, iter, 0, name, -1);
  printf (Selected: %s\n, name);
  free (name);
  }
else printf (Selected: None\n);

However, if you are pressing Ctrl or Shift, when selecting a different 
item, this code returns the PREVIOUS item, not the current one.

Please check this working example (as simple as possible, to show my point):
http://www.gamgi.org/treeview.c

If you click on Apples, the selection gets Apples. If you click on 
Bananas, the selection gets Bananas. But if you then do Ctrl click on 
Apples, the selection gets Bananas, not Apples!

Carlos

Kristian Rietveld wrote:
 Could you more precisely describe what you think is wrong?  I quickly
 tested with GTK+ trunk and I do not see any problems.  It is indeed the
 case that one row is basically always selected (both with single and
 browse mode) and the main difference between browse and single mode is
 that in browse mode you cannot use ctrl+click to unselect a row.  And
 this is something that does work and is possible in single selection
 mode.
   

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


GtkGlext pedantic warning

2008-03-31 Thread Carlos Pereira
When compiling with -pedantic, gtkglext produces
this warning (all the other libraries come clean):

/usr/include/gtkglext-1.0/gdk/gdkgltokens.h:146: warning: ISO C 
restricts enumerator values to range of ‘int’
/usr/include/gtkglext-1.0/gdk/gdkgltokens.h:158: warning: ISO C 
restricts enumerator values to range of ‘int’

It would be nice to clean this.
Carlos
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


GtkTextView issue

2008-03-31 Thread Carlos Pereira
Hi,
This is to report an issue with gtk_text_buffer_create_tag,
affecting Gtk 2.10.0 (Fedora 8, amd64):

gtk_text_buffer_create_tag (buffer, my_tag, scale, 1, NULL);

When the scaling factor is 1.0 (or 2.0 or PANGO_SCALE_MEDIUM or 
PANGO_SCALE_LARGE, etc.) everything works fine. However,
when scaling is 1 (or 2 or something that looks as an integer),
GTK crashes immediately, even if this tag is not actually used.
(The 20-line code working example below shows the issue).

This is not a real problem for users, but perhaps it could be
cleaned anyway? (assuming it was not fixed yet).

Cheers,
Carlos

#include gtk/gtk.h

int main (int argc, char **argv)
{
GtkWidget *window, *text;
GtkTextBuffer *buffer;
GtkTextIter iter;

gtk_init (argc, argv);

window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);

text = gtk_text_view_new ();
gtk_container_add (GTK_CONTAINER (window), text);
gtk_widget_show (text);

buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
gtk_text_buffer_create_tag (buffer, my_tag, scale, 1, NULL);

gtk_text_buffer_get_iter_at_offset (buffer, iter, 0);
gtk_text_buffer_insert_with_tags_by_name (buffer, iter, Hello World!, 
-1, my_tag, NULL);

gtk_widget_show (window);

gtk_main ();
return 0;
}
*
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


GtkTreeView: GTK_SELECTION_SINGLE not working?

2008-03-25 Thread Carlos Pereira
Hi,
For some strange reason GtkTreeview is not working in 
GTK_SELECTION_SINGLE mode, here (Fedora 8, Gtk 2.10, I believe).

GTK_SELECTION_NONE, GTK_SELECTION_BROWSE,
GTK_SELECTION_MULTIPLE work as expected, but GTK_SELECTION_SINGLE always 
behaves as GTK_SELECTION_BROWSE... so one row is always selected...

I am including a simple 40-line working example below, that shows this.

What am I missing?
Carlos

-- working treeview example---
#include gtk/gtk.h

int main (int argc, char **argv)
{
GtkWidget *window;
GtkWidget *treeview;
GtkTreeSelection  *selection;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
GtkListStore *store;
GtkTreeIter iter;

gtk_init (argc, argv);

window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 280, 150);

treeview = gtk_tree_view_new ();
gtk_container_add (GTK_CONTAINER (window), treeview);

selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);

renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes (Fruit, renderer, 
text, 0, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
column = gtk_tree_view_column_new_with_attributes (Color, renderer, 
text, 1, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);

store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
gtk_list_store_append (store, iter);
gtk_list_store_set (store, iter, 0, Apples, 1, Red, -1);
gtk_list_store_append (store, iter);
gtk_list_store_set (store, iter, 0, Bananas, 1, Yellow, -1);
gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), GTK_TREE_MODEL (store));
g_object_unref (store);

gtk_widget_show_all (window);
gtk_main ();
}

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


Gtktextview: sharing text tags

2008-03-19 Thread Carlos Pereira
Hi,
Is it possible to share text tags between different GtkTextviews?
Is it worth the increase in complexity?

My Help dialogs are notebooks, each page has a GtkTextview,
covering a different topic, but the styles are the same

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


GtkTextView: inserting text with different styles

2008-03-17 Thread Carlos Pereira
Hi,
Let's say I have a GtkTextView, with two color tags, red and blue:

text_view = gtk_text_view_new ();
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
gtk_text_buffer_create_tag (buffer, my_red, foreground, #ff, 
NULL);
gtk_text_buffer_create_tag (buffer, my_blue, foreground, #00ff00, 
NULL);

Now I want too insert Hello World:
gtk_text_buffer_insert_at_cursor (buffer, Hello , -1);
gtk_text_buffer_insert_at_cursor (buffer, World, -1);

but I want Hello to be red and World to be blue.

What is the usual procedure to achieve this?
(perhaps get the iterators for the last insertion? it should be quite
easy but apparently I could not find information about this...)

Thanks,
Carlos


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


Re: Locale definitions, dots and commas

2008-03-13 Thread Carlos Pereira
Andrew W. Nosenko wrote:
 What you need to do indeed:
 1. use locale-dependent formatting in the UI (both for input and output)
 2. use locale-INDEPENDENT formatting when you read and save your data files.
So you are saying that interfaces should use dots, commas, whatever is
locally defined, but files should always be in dots. I am not sure I 
agree with this.

My users are actively encouraged to read and modify XML and other text-based
formats, and it looks quite odd to force users to edit files in dots, 
while at the
same time they are allowed to use whatever they like in the interface.

Or are you advocating that text file editors should show dot decimal 
separators
as commas, when locale is comma-based? apparently that is not the case with
Vim and Xemacs, in Gnome, in Fedora 8, I just checked.

Carlos

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


Re: Locale definitions, dots and commas

2008-03-13 Thread Carlos Pereira
Andrew W. Nosenko wrote:
 On Thu, Mar 13, 2008 at 5:12 PM, Carlos Pereira
 [EMAIL PROTECTED] wrote:
   
 Andrew W. Nosenko wrote:
   What you need to do indeed:
   1. use locale-dependent formatting in the UI (both for input and output)
   2. use locale-INDEPENDENT formatting when you read and save your data 
 files.
  So you are saying that interfaces should use dots, commas, whatever is
  locally defined, but files should always be in dots. I am not sure I
  agree with this.

  My users are actively encouraged to read and modify XML and other text-based
  formats, and it looks quite odd to force users to edit files in dots,
  while at the
  same time they are allowed to use whatever they like in the interface.
 

 For case of XML you just have no chiose, at least if XML Schema is used.
 http://www.w3.org/TR/xmlschema-2/#decimal
 just mandates dots for decimal and, as consequence, for float and 
 double.

 For another formats text-based formats...  Using of the one and the
 same notation will reduce errors.  I remember case when I misread
 12,345 (US notation) as 12.345 instead of 12 tousands 345 just
 because my native locale (Russian) uses comma as decimal separator.
 And I expect that nearly to all US people just don't recognize
 12 345 as an _one_ decimal number at all (Russian uses space as
 tousand separator).

 Therefore, cross locale data transfer in an locale dependent format is
 a bad thing.
   
Thank you very much for your opinion,
and for pointing the XML schema specification on this,

they were certainly quite useful,
Carlos
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Locale definitions, dots and commas

2008-03-12 Thread Carlos Pereira
Tomas Carnecky wrote:
 Carlos Pereira wrote:
 Hi,
 I received a message (see below) complaining about using dots instead 
 of commas in decimal numbers. What are the best solutions for this, 
 from the gtk point of view?

 What happens is that in my French locale, the decimal symbol is ',' 
 not '.' !
 Have a nice day, (and good luck with the bug).



$ man 1p locale
- ENVIRONMENT VARIABLES


   This is the typical problem in engineering.
   you only puthis this method before gtk_main();
   gtk_disable_setlocale ();

Thanks for your answers, I realize this is not Gtk stuff,
but certainly affects every GTK app involving decimal numbers...

After setting in my .bashrc, for example (the same with portuguese, 
russian, etc.):

LC_ALL=french; export LC_ALL

Everything automatically works in my GTK app, with commas instead of 
dots, including exporting and importing files (involving for example the 
Expat XML library).

However, a problem remains: my app is distributed with several hundreds 
of example data files, ready to be imported. If these files are 
dot-based, comma people cannot import them. If these files are 
comma-based, dot people cannot import them... Unless I have two versions 
for each file (which seems odd), or I supply a script to automatically 
convert dot- to comma-based files...

If I use gtk_disable_setlocale, then dots are always used, but that does 
not seem quite right... basically I am ignoring user's preference for 
commas...

Is there a good solution for this? am I missing something?
What is the standard procedure in Gnome to handle this problem?

Thanks,
Carlos


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


Re: Locale definitions, dots and commas

2008-03-12 Thread Carlos Pereira
Andrew W. Nosenko wrote:
 On Wed, Mar 12, 2008 at 6:09 PM, Carlos Pereira
 [EMAIL PROTECTED] wrote:
   
  Thanks for your answers, I realize this is not Gtk stuff,
  but certainly affects every GTK app involving decimal numbers...

  After setting in my .bashrc, for example (the same with portuguese,
  russian, etc.):

  LC_ALL=french; export LC_ALL

  Everything automatically works in my GTK app, with commas instead of
  dots, including exporting and importing files (involving for example the
  Expat XML library).

  However, a problem remains: my app is distributed with several hundreds
  of example data files, ready to be imported. If these files are
  dot-based, comma people cannot import them. If these files are
  comma-based, dot people cannot import them... Unless I have two versions
  for each file (which seems odd), or I supply a script to automatically
  convert dot- to comma-based files...

  If I use gtk_disable_setlocale, then dots are always used, but that does
  not seem quite right... basically I am ignoring user's preference for
  commas...

  Is there a good solution for this? am I missing something?
  What is the standard procedure in Gnome to handle this problem?
 

 Please, consider some rewirtting of your application to do not write
 locale-dependent values (floating point numbers, month abbrevs,
 day-of-week abbrevs, and so on...) in the data files, or your files
 will become unreadable after changing of locale (and, if I understand
 correctly, you already hit this problem).  Use some locale-independent
 variant instead.

 For case of the floating point values it could be dot-based variant as
 in the C locale.

   
Fortunately the only locale dependent values I have issues with
are decimal numbers.

If I follow Martin's suggestion, inserting gtk_disable_setlocale ()
before gtk_init (), everything is consistent and works fine, XML 
importing/exporting, GTK interfaces, etc. I just tested it.

Unfortunately this means always using dot-based decimals. I always
use dots myself, so this is not an issue for me. But I understand that
other people might wish to use commas instead.

I think the ideal solution is: when importing files, accept both
dots and commas, so for example this XML line should be acceptable:

element x=1.0 y=2,0/

Then do all the work in the locale chosen decimal separator. So a US
user would work and export with dots, send the file to his french friend,
who reads the dots and then works with commas, export with commas,
send the file back to the US user who reads the commas without problems.

In fact I suspect this is how programs tend to work these days (I tested
Origin, I believe Excell does this also, etc.). Unfortunately it also means
that comma cannot be easily used as a separator in txt files.

I tried to read a file test.txt with only this line inside:
1.0 2,0
Gnumeric thinks the comma is a separator. OOCalc
asks for a separator, and after chosing space separators
reads 1.0 and 2,0 in two different cells, but changing the
number of decimal figures works only for 1.0 ...

Even if I use:
1,0 2,0
with LC_ALL set to french, gnumeric still ignores the commas
and reads this as 1 followed by 02 followed by 0 ...

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


Locale definitions, dots and commas

2008-03-11 Thread Carlos Pereira
Hi,
I received a message (see below) complaining about using dots instead of commas 
in decimal numbers. What are the best solutions for this, from the gtk point of 
view?

What happens is that in my French locale, the decimal symbol is ',' not '.' !
Have a nice day, (and good luck with the bug).

Carlos



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


Re: OpenGL, GtkGlArea, GtkGLExt

2008-03-05 Thread Carlos Pereira
Jon Harrop wrote:
 On Tuesday 04 March 2008 18:14:39 Behdad Esfahbod wrote:
   
 On Tue, 2008-03-04 at 17:04 +, Carlos Pereira wrote:
 
 2) change the name, for example to Gtkglarea 2.0*, the legitimate
 sucessor to Gtkglarea 1 (the last version of Gtkglarea that I downloaded
 last week is 1.99 and still comes with gtk_signal_connect and other Gtk
 1.2* functions deprecated long ago)
   
 No, gtkglarea is dead.
 

 GlArea still has many users and is the defacto standard for some languages.

   
 We don't want a new widget.  We want being able 
 to render to widgets using OpenGL as an alternative to using cairo.
 That is, the GtkGlExt approach.
 

 I'm not sure who you are referring to as we but many people need little 
 beyond GlArea. I have no desire to create Gtk-compatible widgets. I only want 
 to render general graphics quickly and easily using OpenGL.

   
 I believe this would make Gtk more appealing, particularly for
 scientific/engineering/architecture applications.
 Carlos
   

 I am a scientist writing software for scientists and engineers using Gtk from 
 OCaml via the LablGTK2 bindings. There are OCaml bindings for GlArea but not 
 GlExt because GlExt is considered too complicated to be worth binding.

 If anyone is interested in improving the situation for scientists and 
 engineers then I would recommend taking this into account: keep it simple to 
 bind.

   
Hi,
I just ported my app (more than 200,000 lines, totally independent and 
unlimited number of OpenGL areas, sharing pre-compiled OpenGL lists, 
etc.) last night from Gtkglarea to Gtkglext, so I am in a good position 
to highlight the differences, from the user's point of view. What 
follows is a manual of everything I had to change (I assume GTK 2.0 is 
used, for example g_signal_connect instead of gtk_signal_connect):

1) in headers, replace this:
#include gtkgl/gtkglarea.h

by this:
#include gtk/gtkgl.h

2) in makefiles, replace this:
-lgtkgl

by this:
-lgtkglext-x11-1.0

3) in makefiles, replace this (distribution-dependent, Fedora 8 here):
-I/usr/include/gtkgl-2.0
by this:
-I/usr/include/gtkglext-1.0 -I/usr/lib64/gtkglext-1.0/include

4) in drawing code, replace this:
if (gtk_gl_area_make_current (GTK_GL_AREA (area)))
  {
  /* OpenGL here */
  }
by these:
GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (area);
GdkGLContext *glcontext = gtk_widget_get_gl_context (area);
if (gdk_gl_drawable_gl_begin (gldrawable, glcontext))
  {
  /* OpenGL here */
  gdk_gl_drawable_gl_end (gldrawable);
  }

5) in starting code, replace this:
gdk_gl_query();

by this:
gtk_gl_init (argc, argv);
GdkGLContext *glcontext = NULL;
GdkGLDrawable *gldrawable = NULL;

6) in creating area code, replace this:
GtkWidget *area;
int attribute[] = { GDK_GL_RGBA, GDK_GL_DOUBLEBUFFER, GDK_GL_DEPTH_SIZE, 
1, GDK_GL_NONE };
area = gtk_gl_area_share_new (attribute, (GtkGLArea *) area);

by this:
GtkWidget *area;
if (glconfig == NULL)
  {
  glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB | 
GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE);
  if (glconfig == NULL)
{
glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB | 
GDK_GL_MODE_DEPTH);
if (glconfig == NULL) exit (1);
}
  }
area = gtk_drawing_area_new ();
gtk_widget_set_gl_capability (area, glconfig, glcontext, TRUE, 
GDK_GL_RGBA_TYPE);

7) Initially, both glconfig and glcontext point to NULL. BEFORE the 
first drawing area is created, glconfig is obtained, with a double- or 
single-buffer, and used for all drawing areas. AFTER the first drawing 
area is realized (shown), glcontext must be obtained, and reused for all 
the other drawing areas, with this command (when creating the first 
area, glcontext is NULL):

glcontext = gtk_widget_get_gl_context (area);

Usually, throughout the application, there is ONE glconfig and ONE 
glcontext, even if there are unlimited, independent, OpenGL areas. 
OpenGL pre-compiled lists are shared only if glcontext is the same. 
Conceivably, users could have some areas sharing some lists (with one 
glcontext) and other areas sharing other lists, (with a different 
glcontext), but this not usual. Conceivably, users could also create 
areas with different capabilities, for example with or without depth 
buffer, using different glconfigs, but this is not usual.

This is ALL that is needed, to port applications from Gtkglarea to Gtkglext!

Gtkglext looks slightly more lower level and flexible than Gtkglarea, 
closer to the (X) metal as they say, but for users differences are small 
indeed...
Carlos







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


Re: OpenGL, GtkGlArea, GtkGLExt

2008-03-04 Thread Carlos Pereira
Mikael Hallendal wrote:
 3 mar 2008 kl. 22.48 skrev Carlos Pereira:

 Hi Carlos,

 GtkGLext seems to be the most popular GL Area to use these days. You 
 might also want to look at Clutter [1] or Pigment [2] which are 
 canvases offering some higher level abstractions for 2D/3D usages. It 
 depends a bit on what you need, if you just want an area for pure GL 
 I'd go with GtkGLext.

 Regarding future inclusion of GL in GTK+ there is an open bug about it 
 in the Bugzilla [3], I started looking into it a while back but didn't 
 have time to get anything off my hard drive. There are some open 
 issues in that you can read about in the bug tracker.

Thanks Michael,

I have red a few times that thread, that Owen started five years ago, 
and apparently there is agreement in the essentials:

1) remove all the fat from Gtkglext, namely the wrapper functions 
discussed in that thread, make it a small library that cares only for  
opengl integration, that works in the X window system but also in 
Windows and Mac OS X, exactly as Gtk.

2) change the name, for example to Gtkglarea 2.0*, the legitimate 
sucessor to Gtkglarea 1 (the last version of Gtkglarea that I downloaded 
last week is 1.99 and still comes with gtk_signal_connect and other Gtk 
1.2* functions deprecated long ago)

3) make it an official (but optional) Gtk library, downloadble from 
www.gtk.org.

I believe this would make Gtk more appealing, particularly for 
scientific/engineering/architecture applications.
Carlos
 Good luck,
   Mikael Hallendal

 [1] http://www.clutter-project.org/
 [2] https://code.fluendo.com/pigment/trac
 [3] http://bugzilla.gnome.org/show_bug.cgi?id=119189

 Hi,
 What is the currently recommended way to link GTK with OpenGL graphic
 areas? GtkGLarea? GtkGLext? other?

 What are the future plans for GTK regarding OpenGL? is GTK planning to
 support OpenGL directly without need for another library? I am not
 particularly interested in fancy arbitrary widget rendering with OpenGL,
 only rendering to graphic drawing areas,

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



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


OpenGL, GtkGlArea, GtkGLExt

2008-03-03 Thread Carlos Pereira
Hi,
What is the currently recommended way to link GTK with OpenGL graphic 
areas? GtkGLarea? GtkGLext? other?

What are the future plans for GTK regarding OpenGL? is GTK planning to 
support OpenGL directly without need for another library? I am not 
particularly interested in fancy arbitrary widget rendering with OpenGL, 
only rendering to graphic drawing areas,

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


short-cut accelerators

2008-03-02 Thread Carlos Pereira
Hi,
Could someone show me how to create a shortcurt to a menuitem, using an 
accelerator group? on GTK 1.2* I used the code below. What is the 
equivalent in GTK 2.12?

accel_group = gtk_accel_group_new ();
gtk_accel_group_attach (accel_group, GTK_OBJECT (window));
gtk_widget_add_accelerator (menu_item, activate,
accel_group, 'c', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

Carlos

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