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

2005-01-10 Thread Matthias Clasen
On Mon, 2005-01-10 at 01:17 -0600, Greg Breland wrote:
 Did a bug ever get filed on this?  I can't seem to find it if there was.
 
 I have a pretty good usage scenario that is quite common with database
 applications.  
 
 The combo control is the most common control used with DB apps and 
 contains values pulled from a different database table than the data
 being displayed.  Populating all the combo controls on a form when it is
 created would result in dozens of DB queries that are not needed since
 most of the time the user is just looking at the data and not actively
 editing.
 
 Anyone writing an app where populating a combo control isn't just a
 static list but has some overhead will need a popup event for the
 combo control.

Thats bug 162531

Matthias

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


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

2005-01-09 Thread Greg Breland
Did a bug ever get filed on this?  I can't seem to find it if there was.

I have a pretty good usage scenario that is quite common with database
applications.  

The combo control is the most common control used with DB apps and 
contains values pulled from a different database table than the data
being displayed.  Populating all the combo controls on a form when it is
created would result in dozens of DB queries that are not needed since
most of the time the user is just looking at the data and not actively
editing.

Anyone writing an app where populating a combo control isn't just a
static list but has some overhead will need a popup event for the
combo control.

On Sun, 2004-11-21 at 12:19, 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.
 
 Jan-Marek


___
gtk-list mailing list
gtk-list@gnome.org
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 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: 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: 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


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

2004-11-19 Thread Egon Andersen
Hi,
During my migration from GtkCombo() I experienced that I miss a signal 
when the 'arrow' at the right of the GtkComboBoxEntry() is pressed.
I can't seem to find the relevant signal.
When GtkCombo() was used I used set-focus-child, but that doesn't do 
the trick any more.
I've searched and experimented with a number of possible (and 
impossible) signals without luck.

Best regards
Egon Andersen
(This is used to trigger the re-build I was mentioning in an earlier 
post today on this list.)
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list