Re: Which signal is emitted when the arrow in GtkComboBoxEntry() is pressed?

2004-11-21 Thread Jan-Marek Glogowski
Hi Egon

This is a hack, but I it should work:

static void combo_toggle_func( GtkToggleButton
*togglebutton, gpointer user_data )
{
// Do your menu stuff
}

static void scan_children( GtkWidget *w,  gpointer data )
{
if( GTK_IS_TOGGLE_BUTTON( w ) ) {
g_print( Found Button!\n );
g_signal_connect( w, toggled,
G_CALLBACK( combo_toggle_func ), NULL );
}
}

gtk_container_forall( GTK_CONTAINER( my_combo ), scan_children, NULL );

I have also attached a patch to add a popup event (diff against v2.5.5).
Maybe you can try it and report results to the list, so it could be
included in the 2.6 release.

HTH

Jan-Marek

GtkComboBox popup patch:

--- gtkcombobox.c.old   2004-11-09 17:38:57.0 +0100
+++ gtkcombobox.c   2004-11-21 10:44:58.0 +0100
@@ -181,6 +181,7 @@

 enum {
   CHANGED,
+  POPUP,
   LAST_SIGNAL
 };

@@ -522,6 +523,15 @@
   g_cclosure_marshal_VOID__VOID,
   G_TYPE_NONE, 0);

+  combo_box_signals[POPUP] =
+g_signal_new (popup,
+  G_OBJECT_CLASS_TYPE (klass),
+  G_SIGNAL_RUN_LAST,
+  G_STRUCT_OFFSET (GtkComboBoxClass, popup),
+  NULL, NULL,
+  _gtk_marshal_BOOLEAN__VOID,
+  G_TYPE_BOOLEAN, 0);
+
   /* properties */
   g_object_class_install_property (object_class,
PROP_MODEL,
@@ -1490,12 +1500,20 @@
 {
   gint x, y, width, height;
   GtkTreePath *path, *ppath;
+  gboolean do_popup = TRUE;

   g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));

   if (GTK_WIDGET_MAPPED (combo_box-priv-popup_widget))
 return;

+  g_signal_emit_by_name (combo_box, popup, do_popup);
+  if (do_popup == FALSE) {
+gtk_toggle_button_set_active
+  (GTK_TOGGLE_BUTTON (combo_box-priv-button), FALSE);
+return;
+  }
+
   if (GTK_IS_MENU (combo_box-priv-popup_widget))
 {
   gtk_combo_box_menu_popup (combo_box, 0, 0);
@@ -2593,10 +2611,18 @@
  gpointeruser_data)
 {
   GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
+  gboolean do_popup = TRUE;

   if (GTK_IS_MENU (combo_box-priv-popup_widget) 
   event-type == GDK_BUTTON_PRESS  event-button == 1)
 {
+  g_signal_emit_by_name (combo_box, popup, do_popup);
+  if (do_popup == FALSE) {
+gtk_toggle_button_set_active
+  (GTK_TOGGLE_BUTTON (combo_box-priv-button), FALSE);
+return TRUE;
+  }
+
   if (combo_box-priv-focus_on_click 
  !GTK_WIDGET_HAS_FOCUS (combo_box-priv-button))
gtk_widget_grab_focus (combo_box-priv-button);
--- gtkcombobox.h.old   2004-08-16 07:43:50.0 +0200
+++ gtkcombobox.h   2004-11-21 08:50:29.0 +0100
@@ -51,12 +51,12 @@

   /* signals */
   void (* changed)  (GtkComboBox *combo_box);
+  gboolean (* popup)(GtkComboBox *combo_box);

   /* Padding for future expansion */
   void (*_gtk_reserved0) (void);
   void (*_gtk_reserved1) (void);
   void (*_gtk_reserved2) (void);
-  void (*_gtk_reserved3) (void);
 };


___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Which signal is emitted when the arrow in GtkComboBoxEntry() is pressed?

2004-11-21 Thread Egon Andersen
Jan-Marek Glogowski wrote:
Hi Egon
This is a hack, but I it should work:
static void combo_toggle_func( GtkToggleButton
*togglebutton, gpointer user_data )
{
// Do your menu stuff
}
static void scan_children( GtkWidget *w,  gpointer data )
{
if( GTK_IS_TOGGLE_BUTTON( w ) ) {
g_print( Found Button!\n );
g_signal_connect( w, toggled,
G_CALLBACK( combo_toggle_func ), NULL );
}
}
gtk_container_forall( GTK_CONTAINER( my_combo ), scan_children, NULL );
I have also attached a patch to add a popup event (diff against v2.5.5).
Maybe you can try it and report results to the list, so it could be
included in the 2.6 release.
HTH
Jan-Marek
Thanks Jan-Marek,
I've experimented with the above 'hack'.
Unfortunately no toggle_button is found during the child-scan.
Actually the scan found only one widget in the gtkcomboboxentry, which 
to me seems quite strange as I would have expected at least two.
(Checke by setting another print-statement in the scan_children())

I haven't been able to determine which widget it actually detected, as I 
hevent found any good way of getting the type extracted from the widget 
in a human readable way.

Do you have any clue on what is going on here?
Best regards
Egon Andersen
(Also things like the GTK_IS_TOGGLE_BUTTON() macro is not found in the 
documents - okay, it is defined in the header-file, but it is missing in 
the GTK+ Reference Manual for GtkToggleButton)
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Accessing GtkComboBoxEntry's toggle button

2004-11-21 Thread Jan-Marek Glogowski
Hi

Look for the subject Which signal is emitted when the arrow in
GtkComboBoxEntry() is pressed? (21. Nov)

Jan-Marek
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Problem in displaying Dialog

2004-11-21 Thread Jan-Marek Glogowski
Hi

GtkWindow *my_app ...
GtkWindow *my_about ...

gtk_window_set_transient_for( my_about, my_app );
gtk_window_set_position( my_about, GTK_WIN_POS_CENTER_ON_PARENT );

HTH

Jan-Marek
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Which signal is emitted when the arrow in GtkComboBoxEntry() is pressed?

2004-11-21 Thread Jan-Marek Glogowski
Just checked the source for 2.4.13 and 2.5.5. Both use a
GtkToggleButton...

Check the following scan function - should print a list of found object
types:

static void scan_children( GtkWidget *w,  gpointer data )
{
g_print( %s\n, G_OBJECT_TYPE_NAME( w ) );
}

For me it finds:

GtkToggleButton
GtkEntry

About GTK_IS_... macro:

There are six std macros defined by every Gtk+ class. They are used for:
2* type checks (GTK_IS_...[_CLASS])
2* obj casts (GTK_...[_CLASS]), e.g. GTK_BIN( my_combo )-child
1* the type system internal type (GTK_TYPE_...)
1* get the objs class (GTK_..._GET_CLASS)

E.g. if you look into the code, you will find a lot of

g_return_if_fail( GTK_IS_...( combo ) );

For more information read the Gtk+ tutorial and
http://www.le-hacker.org/papers/gobject/

And be sure you use gtk_container_forall not gtk_container_foreach!

Jan-Marek

___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: columned list

2004-11-21 Thread Jan-Marek Glogowski
Hi

The idea is to emulate the mouse behaviour. If you have a large list you
can scroll with the mouse, without selecting an item. Same with the
cursor: you scroll the list (change focus) and then select an item (press
space).

To move the selection with the focus:

gtk_clist_set_selection_mode( clist, GTK_SELECTION_BROWSE );

Now you need to follow the focus row - maybe connect button_press and
check, if clist-focus_row has changed. Then gtk_clist_select_row( clist,
focus_row, 0 );

HTH

Jan-Marek
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Which signal is emitted when the arrow in GtkComboBoxEntry() is pressed?

2004-11-21 Thread Egon Andersen
Jan-Marek Glogowski wrote:
Just checked the source for 2.4.13 and 2.5.5. Both use a
GtkToggleButton...
Check the following scan function - should print a list of found object
types:
static void scan_children( GtkWidget *w,  gpointer data )
{
g_print( %s\n, G_OBJECT_TYPE_NAME( w ) );
}
For me it finds:
GtkToggleButton
GtkEntry
Unfortunately I only get GtkEntry :-(
I've checked that the first argument to gtk_container_forall() is a 
GtkComboBoxEntry
And according to printout from the callback it has only one child which 
in an GtkEntry.

According to the documentation on my machine it should be 2.4.13 I have 
on my FC3 - this is really strange!

The test you ran was that on a 2.4.13 or 2.5.5 or both?
About GTK_IS_... macro:
There are six std macros defined by every Gtk+ class. They are used for:
2* type checks (GTK_IS_...[_CLASS])
2* obj casts (GTK_...[_CLASS]), e.g. GTK_BIN( my_combo )-child
1* the type system internal type (GTK_TYPE_...)
1* get the objs class (GTK_..._GET_CLASS)
Thanks for the explanation.
E.g. if you look into the code, you will find a lot of
g_return_if_fail( GTK_IS_...( combo ) );
For more information read the Gtk+ tutorial and
http://www.le-hacker.org/papers/gobject/
I think these six macros should also be in the reference manual.
I expect to be able to find any (public) available function/macro in the 
reference manual.

And be sure you use gtk_container_forall not gtk_container_foreach!
I checked in the reference manual before use - and know the difference! 
But thanks for pointing it out.

Best regards
Egon Andersen
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Which signal is emitted when the arrow in GtkComboBoxEntry() is pressed?

2004-11-21 Thread Jan-Marek Glogowski
I checked my program with 2.5.5.

And had a look at the ComboBox code: the toggle button is created when
setting the style, so I think the box must be (at least) realized, maybe
even shown.

HTH

Jan-Marek
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Which signal is emitted when the arrow in GtkComboBoxEntry() is pressed?

2004-11-21 Thread Owen Taylor
On Sun, 2004-11-21 at 16:46 +0100, Egon Andersen wrote:
 Jan-Marek Glogowski wrote:
  I checked my program with 2.5.5.
  
  And had a look at the ComboBox code: the toggle button is created when
  setting the style, so I think the box must be (at least) realized, maybe
  even shown.
  
 
 Thanks!
 
 I just made an extra callback function.
 The callback function just contains the gtk_container_forall()
 The callback function is connected by g_signal_connect_after() to the 
 realize signal on the gtkcomboboxentry.
 
 Now that part is working

Note that if this breaks, segfaults, whatever with a future version of
GTK+, we won't care. Digging into the internal implementation guts of a 
widget in this fashion never supported.

Sometimes you have to accept that certain things aren't possible with
GTK+. At that point:

 - File a bug in bugzilla making a good case why notification on
   popup is a good thing
 - Design your user interface a different way for now.

Regards,
Owen



signature.asc
Description: This is a digitally signed message part
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Which signal is emitted when the arrow in GtkComboBoxEntry() is pressed?

2004-11-21 Thread Jan-Marek Glogowski
Hi

I added a patch for a popup event to my first reply. I wanted to file a
bug report, but didn't really come up with a good case.

There was a similar request a few days ago: Accessing GtkComboBoxEntry's
toggle button.

The patch is very simple - just two gtk_signal_emit, a return value to
cancel popup and the signal definition ~20 lines of code.

Jan-Marek
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Which signal is emitted when the arrow in GtkComboBoxEntry() is pressed?

2004-11-21 Thread Egon Andersen
Jan-Marek Glogowski wrote:
Hi
I added a patch for a popup event to my first reply. I wanted to file a
bug report, but didn't really come up with a good case.
There was a similar request a few days ago: Accessing GtkComboBoxEntry's
toggle button.
The patch is very simple - just two gtk_signal_emit, a return value to
cancel popup and the signal definition ~20 lines of code.
In my case it is a list of elements taken from a database. The list can 
be changed while the application is running.
At the time I click on the combobox it is determined if the list in the 
db has changed and update the combobox list if required.

Best regards
Egon Andersen
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


GtkToggleButton signals question

2004-11-21 Thread Neil Zanella
Hello,

I would like to know whether the following behavior is reliable, since
it is not documented
in the API reference:

When I press a GtkToggleButton (suppose the button goes from being
pressed out to
pressed in), I notice that the toggled signal is emitted _AFTER_ the
button becomes
pressed in, not before.

Can I rely on this behavior?

Also, how is the toggled signal different from the clicked signal
pertaining to the
GtkButton widget from which GtkToggleButton inherits?

Thanks,

Neil
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


another GtkToggleButton signal question

2004-11-21 Thread Neil Zanella
Hello,

Can I also rely on the fact that if a GtkToggleButton is active then a
function call
to set its active state to TRUE is not going to trigger a signal. In
general, is it true
that signal handlers are invoked when properties are CHANGED BY A FUNCTION
OR USER ACTION, and not when a function causes the given property to remain
the same?

In particular, if a toggle button state is true, then setting it to
true via a function
does not generate a signal. Is this concept true for GTK signals in general?

Thanks,

Neil
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: GtkToggleButton signals question

2004-11-21 Thread James M. Cape
On Sun, 2004-11-21 at 19:27 -0700, Neil Zanella wrote:
 Hello,
 
 I would like to know whether the following behavior is reliable, since
 it is not documented
 in the API reference:
 
 When I press a GtkToggleButton (suppose the button goes from being
 pressed out to
 pressed in), I notice that the toggled signal is emitted _AFTER_ the
 button becomes
 pressed in, not before.
 
 Can I rely on this behavior?

Probably yes, because the toggled signal is emitted from the clicked
handler inside of gtktogglebutton.c, though why do you *need* to rely on
this behavior?

 Also, how is the toggled signal different from the clicked signal
 pertaining to the
 GtkButton widget from which GtkToggleButton inherits?

toggled is emitted whenever the active property changes (which may
happen as a result of user interaction or calls to
gtk_toggle_button_set_active/g_object_set), whereas clicked is only
emitted when the user actually clicks on a button (or, I think, uses
mnemonic shortcuts).

-- 
Peace,

Jim Cape
http://esco.mine.nu
http://ignore-your.tv

If even one reporter had stood up during a pre-Iraq Bush press
 conference last year and shouted, `Bullshit!' it might have made a
 difference.
-- Matt Taibbi, New York Press



signature.asc
Description: This is a digitally signed message part
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: another GtkToggleButton signal question

2004-11-21 Thread James M. Cape
On Sun, 2004-11-21 at 19:49 -0700, Neil Zanella wrote:
 Hello,
 
 Can I also rely on the fact that if a GtkToggleButton is active then a
 function call
 to set its active state to TRUE is not going to trigger a signal. In
 general, is it true
 that signal handlers are invoked when properties are CHANGED BY A FUNCTION
 OR USER ACTION, and not when a function causes the given property to remain
 the same?

 In particular, if a toggle button state is true, then setting it to
 true via a function
 does not generate a signal. Is this concept true for GTK signals in general?

It depends entirely on the signal and property in question. For signals
in GTK+ itself, generally yes (I don't know of a counter-example within
libgdk/libgdk-pixbuf/libgtk offhand). Outside of GTK+ it depends
entirely on the code given. GObject's notify signal, for example, is
always emitted when set_property() is called (so toggled will only be
fired when the active property has changed, whereas notify::active
will be fired anytime someone calls 'g_object_set (button, active,
someval, NULL);'

-- 
Peace,

Jim Cape
http://esco.mine.nu
http://ignore-your.tv

If even one reporter had stood up during a pre-Iraq Bush press
 conference last year and shouted, `Bullshit!' it might have made a
 difference.
-- Matt Taibbi, New York Press



signature.asc
Description: This is a digitally signed message part
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list