Esempio n. 1
0
/* FIXME: this doesn't work */
static gboolean
draw_cb_activity (GtkWidget *widget, cairo_t *cr)
{
  GtkStyleContext *context;
  GtkWidgetPath *path;

  context = gtk_widget_get_style_context (widget);
  gtk_style_context_notify_state_change (context,
                                         gtk_widget_get_window (widget),
                                         NULL,
                                         GTK_STATE_FLAG_ACTIVE,
                                         TRUE);

  gtk_style_context_save (context);

  path = gtk_widget_path_new ();
  gtk_widget_path_append_type (path, GTK_TYPE_SPINNER);
  gtk_widget_path_iter_add_class (path, 0, "spinner");
  gtk_style_context_set_path (context, path);
  gtk_widget_path_free (path);

  gtk_style_context_set_state (context, GTK_STATE_FLAG_ACTIVE);
  gtk_render_activity (context, cr, 12, 12, 12, 12);

  gtk_style_context_restore (context);

  return TRUE;
}
Esempio n. 2
0
/**
 * gtk_switch_set_active:
 * @sw: a #GtkSwitch
 * @is_active: %TRUE if @sw should be active, and %FALSE otherwise
 *
 * Changes the state of @sw to the desired one.
 *
 * Since: 3.0
 */
void
gtk_switch_set_active (GtkSwitch *sw,
                       gboolean   is_active)
{
  GtkSwitchPrivate *priv;

  g_return_if_fail (GTK_IS_SWITCH (sw));

  is_active = !!is_active;

  priv = sw->priv;

  if (priv->is_active != is_active)
    {
      AtkObject *accessible;
      GtkWidget *widget;
      GtkStyleContext *context;

      widget = GTK_WIDGET (sw);
      priv->is_active = is_active;

      g_object_notify_by_pspec (G_OBJECT (sw), switch_props[PROP_ACTIVE]);

      if (priv->action)
        gtk_action_activate (priv->action);

      accessible = gtk_widget_get_accessible (GTK_WIDGET (sw));
      atk_object_notify_state_change (accessible, ATK_STATE_CHECKED, priv->is_active);

      if (gtk_widget_get_realized (widget))
        {
          context = gtk_widget_get_style_context (widget);
          gtk_style_context_notify_state_change (context,
                                                 gtk_widget_get_window (widget),
                                                 NULL, GTK_STATE_ACTIVE, is_active);
        }

      gtk_widget_queue_draw (GTK_WIDGET (sw));
    }
}