[RFC] Why GtkMenuItem hide_on_activate property is not taken into account?

2012-08-31 Thread Tomasz Bursztyka
---
Hi,

I just propose a patch below, on gtk core, to illustrate the issue I will talk 
about. I have probably missed
how to derivate from GtkMenuItem properly to fit my use case.

While playing around a GtkStatusIcon, so with GtkMenuShell/GtkMenu and 
GtkMenuItem afterwards, I wanted to
get a new widget as a derivative of GtkMenuItem, let's say: a menu item 
proposing GtkSwitch called GtkSwitchMenuItem.
The main difference is that, the control below is fully async: until a reply 
has not come up,
it would set it as non sensitive, and then: depending on reply would set the 
right active value for the switch. That works, it's easy.

But in addition to that I want such behavior so the menu itself does not 
popdown when I click on a GtkSwitchMenuItem.
Looking at GtkMenuItem I saw this property hide_on_activate. Ok, by default it 
is set to true: I set it to false in my GtkSwitchMenuItem code.
Still no luck.

Went further in the code, and in gtkmenushell.c: gtk_menu_shell_activate_item() 
is supposed to take into account hide_on_activate property if
force_deactivate is FALSE. But in gtk_menu_shell_button_release() which is the 
function called when an item is clicked: it always
call gtk_menu_shell_activate_item() with force_deactivate set to TRUE (when the 
item has no submenu like my GtkSwitchMenuItem).

Due to that, whatever is the value of hide_on_activate, whatever does a 
replacement of GtkMenuItem activate function: the menu is always poped down.

So I quickly changed this TRUE to FALSE in 
gtkmenushell.c:gtk_menu_shell_button_release () for 
gtk_menu_shell_activate_item () and then: hide_on_activate
is taken care of properly, and I got the behavior I was expecting in setting 
hide_on_activate to FALSE.

I don't think it is a valid bug, since doing so: would make all 
GtkCheckMenuItem behaving like my GtkSwitchMenuItem. (see the patch below, 
witch remove the
hide_on_activate set to FALSE, it was just for testing). As you can expect: 
changing such property on GtkCheckMenuItem makes gtk_menu_shell_activate_item() 
behaving
always the same, whatever force_deactivate is. Which is probably wrong then.

So my question is: how to get this behavior for my GtkSwitchMenuItem, properly 
done with existing GtkMenuShell/GtkMenuItem functions/signals?
What signals should I catch or which function should I override? 

Thanks,

Tomasz

 gtk/gtkcheckmenuitem.c |1 -
 gtk/gtkmenushell.c |2 +-
 2 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/gtk/gtkcheckmenuitem.c b/gtk/gtkcheckmenuitem.c
index 343565d..10bae0e 100644
--- a/gtk/gtkcheckmenuitem.c
+++ b/gtk/gtkcheckmenuitem.c
@@ -152,7 +152,6 @@ gtk_check_menu_item_class_init (GtkCheckMenuItemClass 
*klass)
   gtk_widget_class_set_accessible_type (widget_class, 
GTK_TYPE_CHECK_MENU_ITEM_ACCESSIBLE);
 
   menu_item_class-activate = gtk_check_menu_item_activate;
-  menu_item_class-hide_on_activate = FALSE;
   menu_item_class-toggle_size_request = 
gtk_check_menu_item_toggle_size_request;
   
   klass-toggled = NULL;
diff --git a/gtk/gtkmenushell.c b/gtk/gtkmenushell.c
index 5099179..0db79e5 100644
--- a/gtk/gtkmenushell.c
+++ b/gtk/gtkmenushell.c
@@ -827,7 +827,7 @@ gtk_menu_shell_button_release (GtkWidget  *widget,
 
   if (submenu == NULL)
 {
-  gtk_menu_shell_activate_item (menu_shell, menu_item, TRUE);
+  gtk_menu_shell_activate_item (menu_shell, menu_item, FALSE);
   deactivate = FALSE;
 }
   else if (GTK_MENU_SHELL_GET_CLASS 
(menu_shell)-submenu_placement != GTK_TOP_BOTTOM ||
-- 
1.7.8.6

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


Re: [RFC] Why GtkMenuItem hide_on_activate property is not taken into account?

2012-08-31 Thread Michael Cronenworth
Tomasz Bursztyka wrote:
[snip]
 So my question is: how to get this behavior for my GtkSwitchMenuItem, 
 properly done with existing GtkMenuShell/GtkMenuItem functions/signals?
 What signals should I catch or which function should I override? 

You're better off proposing this patch in a bug report on
https://bugzilla.gnome.org

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


compile multiple source file

2012-08-31 Thread Rudra Banerjee
I have two file:

#THE MAIN###
#include gtk/gtk.h

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

gtk_init (argc, argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
button = gtk_button_new_with_label (Hello World);
g_signal_connect (button, clicked,
  G_CALLBACK (hello), NULL);
gtk_container_add (GTK_CONTAINER (window), button);
gtk_widget_show (button);
gtk_widget_show (window);
gtk_main ();

return 0;
}


#hello.c
#include gtk/gtk.h
static void hello( GtkWidget *widget,
   gpointer   data )
{
g_print (Hello World\n);
}


If they are in separate file, then,
$ gcc `pkg-config --cflags --libs gtk+-3.0` hello.c main.c -c
main.c: In function ‘main’:
main.c:13:5: error: ‘hello’ undeclared (first use in this function)
main.c:13:5: note: each undeclared identifier is reported only once for
each function it appears in

But obviously, putting both of them together in a single file works.
How to compile while keeping them seperate
?


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

Re: compile multiple source file

2012-08-31 Thread Vlad Volodin
Hello,

You probably did not declare the 'hello' function in the main.c file. To do
this, just write a header of the function beforevthe main function.

Regards,
Vlad
On Aug 31, 2012 4:48 PM, Rudra Banerjee bnrj.ru...@yahoo.com wrote:

 I have two file:

 #THE MAIN###
 #include gtk/gtk.h

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

 gtk_init (argc, argv);
 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 gtk_container_set_border_width (GTK_CONTAINER (window), 10);
 button = gtk_button_new_with_label (Hello World);
 g_signal_connect (button, clicked,
   G_CALLBACK (hello), NULL);
 gtk_container_add (GTK_CONTAINER (window), button);
 gtk_widget_show (button);
 gtk_widget_show (window);
 gtk_main ();

 return 0;
 }


 #hello.c
 #include gtk/gtk.h
 static void hello( GtkWidget *widget,
gpointer   data )
 {
 g_print (Hello World\n);
 }


 If they are in separate file, then,
 $ gcc `pkg-config --cflags --libs gtk+-3.0` hello.c main.c -c
 main.c: In function ‘main’:
 main.c:13:5: error: ‘hello’ undeclared (first use in this function)
 main.c:13:5: note: each undeclared identifier is reported only once for
 each function it appears in

 But obviously, putting both of them together in a single file works.
 How to compile while keeping them seperate
 ?


 ___
 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

Re: compile multiple source file

2012-08-31 Thread Olivier Sessink
On 08/31/2012 04:48 PM, Rudra Banerjee wrote:
 If they are in separate file, then,
 $ gcc `pkg-config --cflags --libs gtk+-3.0` hello.c main.c -c
 main.c: In function ‘main’:
 main.c:13:5: error: ‘hello’ undeclared (first use in this function)
 main.c:13:5: note: each undeclared identifier is reported only once for
 each function it appears in
 
 But obviously, putting both of them together in a single file works.
 How to compile while keeping them seperate

first remove the 'static' keyword before function hello(), static
functions are only called from the file itself, they are not to be
called from other files.

now create a header file hello.h that contains:

void hello( GtkWidget *widget, gpointer   data );

and include that in main.c like #include hello.h

now you can compile each .c file, and then link the resulting .o files
to a binary.

Olivier


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

Re: compile multiple source file

2012-08-31 Thread Rudra Banerjee
Thanks Olivier and all,
The static was the culprit.



 
-- 
Rudra
JRF; SNBNCBS
http://www.bose.res.in/~rudra

A bus station is where a bus stops. A train station is where a train
stops. On my desk I have a work  station.

Please, if possible, don't  send me MS Word or PowerPoint attachments 
Why?See:  http://www.gnu.org/philosophy/no-word-attachments.html




 From: Olivier Sessink oliviersess...@gmail.com
To: gtk-app-devel-list@gnome.org 
Sent: Friday, 31 August 2012 4:02 PM
Subject: Re: compile multiple source file
 
On 08/31/2012 04:48 PM, Rudra Banerjee wrote:
 If they are in separate file, then,
 $ gcc `pkg-config --cflags --libs gtk+-3.0` hello.c main.c -c
 main.c: In function ‘main’:
 main.c:13:5: error: ‘hello’ undeclared (first use in this function)
 main.c:13:5: note: each undeclared identifier is reported only once for
 each function it appears in
 
 But obviously, putting both of them together in a single file works.
 How to compile while keeping them seperate

first remove the 'static' keyword before function hello(), static
functions are only called from the file itself, they are not to be
called from other files.

now create a header file hello.h that contains:

void hello( GtkWidget *widget, gpointer   data );

and include that in main.c like #include hello.h

now you can compile each .c file, and then link the resulting .o files
to a binary.

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

GtkDrawingArea cursor flicker

2012-08-31 Thread Roger Davis

Hi all,

I am experiencing some very annoying mouse cursor flicker on a particular
computer system which does not occur on any other machine. I am using a
GTK+3 GtkDrawingArea widget, and am listening for GDK_POINTER_MOTION_MASK
events on that widget. When I get such an event, I do some redrawing to
a private Cairo surface based on the current cursor location, then
queue an expose event with gtk_widget_queue_draw_area(drawarea, ...). 
When my GtkDrawingArea widget receives the 'draw' signal it copies the 
redrawn area of interest from my private Cairo surface using this draw 
handler:

gboolean
canvasdrawevt(GtkWidget *w, cairo_t *cr, gpointer gp)
{
MyCairoCanvas *c;

c= (MyCairoCanvas *) gp;

cairo_set_source_surface(cr, c-surface, 0, 0);
cairo_rectangle(cr, 0, 0, (double) c-width, (double) c-height);
cairo_fill(cr);

return TRUE;
}

After my redraw is done, on the problematic machine the mouse cursor
actually disappears from view completely. If I move the mouse around
quickly, generating lots of these redraws, I can see the cursor flickering
until I stop moving it, after which it again disappears. There are certain
areas of the widget where I do *not* handle these motion events and thus
there is no redrawing done -- in these areas the mouse cursor behaves
normally and is always visible.

This is happening on a CentOS 6 system that is several (maybe about 8)
years old. This problem does not occur on any of the other CentOS 6 systems
I have which are newer hardware. It also does not occur on the older system
if I run my app remotely via a VNC server, displaying on newer hardware.

Any idea on what is causing this or how I might work around it? Unfortunately
I really do need to run this app on the old machine. I have looked around
GDK for some type of cursor flush/redraw routine but can't seem to find
any such thing. If there was a way to force a cursor redraw I might be able
to work around this, although I'm not sure how I could guarantee that the
cursor redraw would happen after the expose event is actually handled by
my draw handler.

Thanks!

Roger Davis
Univ. of Hawaii
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list