[gtk+] Bug 69872 - GTK_WIDGET_SET_FLAGS should be deprecated



commit b81079d898050dec2211abc96a0dcad332a7cb59
Author: Michael Natterer <mitch gimp org>
Date:   Fri Sep 4 14:50:35 2009 +0200

    Bug 69872 - GTK_WIDGET_SET_FLAGS should be deprecated
    
    Add gtk_widget_set_receives_default() and
    gtk_widget_get_receives_default() as accessors for
    GTK_RECEIVES_DEFAULT.

 gtk/gtk.symbols |    2 ++
 gtk/gtkwidget.c |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gtk/gtkwidget.h |    4 ++++
 3 files changed, 60 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index 5d5cbec..841780b 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -4990,6 +4990,7 @@ gtk_widget_get_pango_context
 gtk_widget_get_parent
 gtk_widget_get_parent_window
 gtk_widget_get_pointer
+gtk_widget_get_receives_default
 gtk_widget_get_root_window
 gtk_widget_get_screen
 gtk_widget_get_sensitive
@@ -5078,6 +5079,7 @@ gtk_widget_set_name
 gtk_widget_set_no_show_all
 gtk_widget_set_parent
 gtk_widget_set_parent_window
+gtk_widget_set_receives_default
 gtk_widget_set_redraw_on_allocate
 gtk_widget_set_scroll_adjustments
 gtk_widget_set_sensitive
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 9ee2218..98e9149 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -5472,6 +5472,60 @@ gtk_widget_grab_default (GtkWidget *widget)
 }
 
 /**
+ * gtk_widget_set_receives_default:
+ * @widget: a #GtkWidget
+ * @receives_default: whether or not @widget can be a default widget.
+ *
+ * Specifies whether @widget will be treated as the default widget
+ * within its toplevel when it has the focus, even if another widget
+ * is the default.
+ *
+ * See gtk_widget_grab_default() for details about the meaning of
+ * "default".
+ *
+ * Since: 2.18
+ **/
+void
+gtk_widget_set_receives_default (GtkWidget *widget,
+                                 gboolean   receives_default)
+{
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+
+  if (receives_default != gtk_widget_get_receives_default (widget))
+    {
+      if (receives_default)
+        GTK_WIDGET_SET_FLAGS (widget, GTK_RECEIVES_DEFAULT);
+      else
+        GTK_WIDGET_UNSET_FLAGS (widget, GTK_RECEIVES_DEFAULT);
+
+      g_object_notify (G_OBJECT (widget), "receives-default");
+    }
+}
+
+/**
+ * gtk_widget_get_receives_default:
+ * @widget: a #GtkWidget
+ *
+ * Determines whether @widget is alyways treated as default widget
+ * withing its toplevel when it has the focus, even if another widget
+ * is the default.
+ *
+ * See gtk_widget_set_receives_default().
+ *
+ * Return value: %TRUE if @widget acts as default widget when focussed,
+ *               %FALSE otherwise
+ *
+ * Since: 2.18
+ **/
+gboolean
+gtk_widget_get_receives_default (GtkWidget *widget)
+{
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+  return (GTK_WIDGET_FLAGS (widget) & GTK_RECEIVES_DEFAULT) != 0;
+}
+
+/**
  * gtk_widget_has_grab:
  * @widget: a #GtkWidget
  *
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index d00beeb..c148875 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -561,6 +561,10 @@ gboolean   gtk_widget_get_can_default     (GtkWidget           *widget);
 gboolean   gtk_widget_has_default         (GtkWidget           *widget);
 void       gtk_widget_grab_default        (GtkWidget           *widget);
 
+void      gtk_widget_set_receives_default (GtkWidget           *widget,
+                                           gboolean             receives_default);
+gboolean  gtk_widget_get_receives_default (GtkWidget           *widget);
+
 gboolean   gtk_widget_has_grab            (GtkWidget           *widget);
 
 void                  gtk_widget_set_name               (GtkWidget    *widget,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]