* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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 <cairo-gobject.h>
#include "gtkcontainer.h"
-#include "gtkaccelmap.h"
+#include "gtkaccelmapprivate.h"
#include "gtkclipboard.h"
#include "gtkiconfactory.h"
#include "gtkintl.h"
*/
gchar *name;
+ /* The list of attached windows to this widget.
+ * We keep a list in order to call reset_style to all of them,
+ * recursively. */
+ GList *attached_windows;
+
/* The style for the widget. The style contains the
* colors the widget should be drawn in for each state
* along with graphics contexts used to draw with and
{
guint flags : GTK_STATE_FLAGS_BITS;
guint operation : 2;
- guint use_forall : 1;
};
/* --- prototypes --- */
gtk_widget_queue_compute_expand (old_parent);
}
- /* Unset window-unfocused since we are no longer inside a toplevel window */
- gtk_widget_unset_state_flags (widget, GTK_STATE_FLAG_WINDOW_UNFOCUSED);
+ /* Unset BACKDROP since we are no longer inside a toplevel window */
+ gtk_widget_unset_state_flags (widget, GTK_STATE_FLAG_BACKDROP);
+ if (priv->context)
+ gtk_style_context_set_parent (priv->context, NULL);
g_signal_emit (widget, widget_signals[PARENT_SET], 0, old_parent);
if (toplevel)
g_signal_emit (widget, widget_signals[DRAW],
0, cr,
&result);
+
+ if (cairo_status (cr) &&
+ _gtk_cairo_get_event (cr))
+ {
+ /* We check the event so we only warn about internal GTK calls.
+ * Errors might come from PDF streams having write failures and
+ * we don't want to spam stderr in that case.
+ * We do want to catch errors from
+ */
+ g_warning ("drawing failure for widget `%s': %s",
+ G_OBJECT_TYPE_NAME (widget),
+ cairo_status_to_string (cairo_status (cr)));
+ }
}
context = gtk_widget_get_style_context (widget);
data.flags = flags;
data.operation = operation;
- data.use_forall = FALSE;
gtk_widget_propagate_state (widget, &data);
gboolean sensitive)
{
GtkWidgetPrivate *priv;
- GtkStateData data;
g_return_if_fail (GTK_IS_WIDGET (widget));
if (priv->sensitive == sensitive)
return;
- data.flags = GTK_STATE_FLAG_INSENSITIVE;
+ priv->sensitive = sensitive;
- if (sensitive)
- {
- priv->sensitive = TRUE;
- data.operation = STATE_CHANGE_UNSET;
- }
- else
+ if (priv->parent == NULL
+ || gtk_widget_is_sensitive (priv->parent))
{
- priv->sensitive = FALSE;
- data.operation = STATE_CHANGE_SET;
- }
+ GtkStateData data;
- data.use_forall = TRUE;
+ data.flags = GTK_STATE_FLAG_INSENSITIVE;
- gtk_widget_propagate_state (widget, &data);
+ if (sensitive)
+ data.operation = STATE_CHANGE_UNSET;
+ else
+ data.operation = STATE_CHANGE_SET;
- gtk_widget_queue_resize (widget);
+ gtk_widget_propagate_state (widget, &data);
+
+ gtk_widget_queue_resize (widget);
+ }
g_object_notify (G_OBJECT (widget), "sensitive");
}
data.flags |= priv->state_flags;
data.operation = STATE_CHANGE_REPLACE;
- data.use_forall = gtk_widget_is_sensitive (parent) != gtk_widget_is_sensitive (widget);
gtk_widget_propagate_state (widget, &data);
+ if (priv->context)
+ gtk_style_context_set_parent (priv->context,
+ gtk_widget_get_style_context (parent));
gtk_widget_reset_style (widget);
g_signal_emit (widget, widget_signals[PARENT_SET], 0, NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
reset_style_recurse (widget, NULL);
+
+ g_list_foreach (widget->priv->attached_windows,
+ (GFunc) reset_style_recurse, NULL);
}
#ifdef G_ENABLE_DEBUG
GtkWidget *widget = GTK_WIDGET (object);
GtkWidgetPrivate *priv = widget->priv;
+ if (GTK_WIDGET_GET_CLASS (widget)->priv->accessible_type != GTK_TYPE_ACCESSIBLE)
+ {
+ GtkAccessible *accessible = g_object_steal_qdata (G_OBJECT (widget), quark_accessible_object);
+
+ if (accessible)
+ {
+ gtk_accessible_set_widget (accessible, NULL);
+ g_object_unref (accessible);
+ }
+ }
+
/* wipe accelerator closures (keep order) */
g_object_set_qdata (G_OBJECT (widget), quark_accel_path, NULL);
g_object_set_qdata (G_OBJECT (widget), quark_accel_closures, NULL);
if (!gtk_widget_is_sensitive (widget) && gtk_widget_has_grab (widget))
gtk_grab_remove (widget);
+ gtk_style_context_set_state (gtk_widget_get_style_context (widget), new_flags);
+
g_signal_emit (widget, widget_signals[STATE_CHANGED], 0, old_state);
g_signal_emit (widget, widget_signals[STATE_FLAGS_CHANGED], 0, old_flags);
- if (!priv->shadowed)
+ if (!priv->shadowed &&
+ (new_flags & GTK_STATE_FLAG_INSENSITIVE) != (old_flags & GTK_STATE_FLAG_INSENSITIVE))
{
GList *event_windows = NULL;
GList *devices, *d;
if (!gtk_widget_is_sensitive (widget))
_gtk_widget_synthesize_crossing (widget, NULL, d->data,
GDK_CROSSING_STATE_CHANGED);
- else if (old_flags & GTK_STATE_FLAG_INSENSITIVE)
+ else
_gtk_widget_synthesize_crossing (NULL, widget, d->data,
GDK_CROSSING_STATE_CHANGED);
/* Make sure to only propate the right states further */
child_data.flags &= GTK_STATE_FLAGS_DO_PROPAGATE;
- if (child_data.use_forall)
- gtk_container_forall (GTK_CONTAINER (widget),
- (GtkCallback) gtk_widget_propagate_state,
- &child_data);
- else
- gtk_container_foreach (GTK_CONTAINER (widget),
- (GtkCallback) gtk_widget_propagate_state,
- &child_data);
+ gtk_container_forall (GTK_CONTAINER (widget),
+ (GtkCallback) gtk_widget_propagate_state,
+ &child_data);
}
/* Trigger state change transitions for the widget */
}
else
{
- accessible = g_object_new (priv->accessible_type, NULL);
+ accessible = g_object_new (priv->accessible_type,
+ "widget", widget,
+ NULL);
if (priv->accessible_role != ATK_ROLE_INVALID)
atk_object_set_role (accessible, priv->accessible_role);
}
g_object_unref (relation_set);
- g_slist_foreach (atk_relations, (GFunc)free_relation, NULL);
- g_slist_free (atk_relations);
+ g_slist_free_full (atk_relations, (GDestroyNotify) free_relation);
g_object_set_qdata (G_OBJECT (buildable), quark_builder_atk_relations,
NULL);
}
else
g_warning ("accessibility action on a widget that does not implement AtkAction");
- g_slist_foreach (a11y_data->actions, (GFunc)free_action, NULL);
- g_slist_free (a11y_data->actions);
+ g_slist_free_full (a11y_data->actions, (GDestroyNotify) free_action);
}
if (a11y_data->relations)
return NULL;
}
+void
+_gtk_widget_add_attached_window (GtkWidget *widget,
+ GtkWindow *window)
+{
+ widget->priv->attached_windows = g_list_prepend (widget->priv->attached_windows, window);
+}
+
+void
+_gtk_widget_remove_attached_window (GtkWidget *widget,
+ GtkWindow *window)
+{
+ widget->priv->attached_windows = g_list_remove (widget->priv->attached_windows, window);
+}
+
/**
* gtk_widget_path_append_for_widget:
* @path: a widget path
* where style properties might be retrieved on that
* situation.
*/
- widget->priv->path = gtk_widget_path_new ();
+ GtkWidget *attach_widget = NULL;
+
+ if (GTK_IS_WINDOW (widget))
+ attach_widget = gtk_window_get_attached_to (GTK_WINDOW (widget));
+
+ if (attach_widget != NULL)
+ widget->priv->path = gtk_widget_path_copy (gtk_widget_get_path (attach_widget));
+ else
+ widget->priv->path = gtk_widget_path_new ();
gtk_widget_path_append_for_widget (widget->priv->path, widget);
}
gtk_style_context_set_screen (priv->context, screen);
gtk_style_context_set_path (priv->context, path);
+ if (priv->parent)
+ gtk_style_context_set_parent (priv->context,
+ gtk_widget_get_style_context (priv->parent));
}
return widget->priv->context;