* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
+
#include "gtkcombobox.h"
+
+#include "gtkadjustment.h"
#include "gtkcellareabox.h"
#include "gtktreemenu.h"
#include "gtkarrow.h"
#include "gtktogglebutton.h"
#include "gtktreeselection.h"
#include "gtkseparator.h"
+#include "gtkwidgetpath.h"
+#include "gtkwidgetprivate.h"
#include "gtkwindow.h"
#include "gtktypebuiltins.h"
#include "gtkprivate.h"
gtk_widget_queue_draw (widget);
}
+static void
+gtk_combo_box_invalidate_order_foreach (GtkWidget *widget)
+{
+ _gtk_widget_invalidate_style_context (widget, GTK_CSS_CHANGE_POSITION | GTK_CSS_CHANGE_SIBLING_POSITION);
+}
+
static void
gtk_combo_box_invalidate_order (GtkComboBox *combo_box)
{
gtk_container_forall (GTK_CONTAINER (combo_box),
- (GtkCallback) gtk_widget_reset_style,
+ (GtkCallback) gtk_combo_box_invalidate_order_foreach,
NULL);
}
GtkWidgetPath *sibling_path;
int pos;
- path = gtk_widget_path_copy (gtk_widget_get_path (GTK_WIDGET (container)));
+ path = _gtk_widget_create_path (GTK_WIDGET (container));
if (gtk_widget_get_visible (child))
{
return TRUE;
}
+static gboolean
+gtk_combo_box_grab_broken_event (GtkWidget *widget,
+ GdkEventGrabBroken *event,
+ gpointer user_data)
+{
+ GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
+
+ if (event->grab_window == NULL)
+ gtk_combo_box_popdown (combo_box);
+
+ return TRUE;
+}
+
/**
* gtk_combo_box_popup:
* @combo_box: a #GtkComboBox
gtk_device_grab_add (priv->popup_window, pointer, TRUE);
priv->grab_pointer = pointer;
priv->grab_keyboard = keyboard;
+
+ g_signal_connect (priv->popup_window,
+ "grab-broken-event",
+ G_CALLBACK (gtk_combo_box_grab_broken_event),
+ combo_box);
}
static void
if (!gtk_widget_get_realized (GTK_WIDGET (combo_box)))
return;
+ if (priv->grab_keyboard)
+ gdk_device_ungrab (priv->grab_keyboard, GDK_CURRENT_TIME);
+ gdk_device_ungrab (priv->grab_pointer, GDK_CURRENT_TIME);
+
gtk_device_grab_remove (priv->popup_window, priv->grab_pointer);
gtk_widget_hide (priv->popup_window);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button),
priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
gtk_container_add (GTK_CONTAINER (priv->box), priv->arrow);
+ gtk_widget_add_events (priv->button, GDK_SCROLL_MASK);
gtk_widget_show_all (priv->button);
}
priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
gtk_container_add (GTK_CONTAINER (priv->button), priv->arrow);
+ gtk_widget_add_events (priv->button, GDK_SCROLL_MASK);
gtk_widget_show_all (priv->button);
}
gint font_size, arrow_size;
PangoContext *context;
PangoFontMetrics *metrics;
- const PangoFontDescription *font_desc;
GtkWidget *child;
gint minimum_width = 0, natural_width = 0;
gint child_min, child_nat;
- GtkStyleContext *style_context;
- GtkStateFlags state;
GtkBorder padding;
gfloat arrow_scaling;
"arrow-scaling", &arrow_scaling,
NULL);
- style_context = gtk_widget_get_style_context (widget);
- state = gtk_widget_get_state_flags (widget);
-
get_widget_padding_and_border (widget, &padding);
- font_desc = gtk_style_context_get_font (style_context, state);
context = gtk_widget_get_pango_context (GTK_WIDGET (widget));
- metrics = pango_context_get_metrics (context, font_desc,
+ metrics = pango_context_get_metrics (context,
+ pango_context_get_font_description (context),
pango_context_get_language (context));
font_size = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
pango_font_metrics_get_descent (metrics));