Esempio n. 1
0
static void
gstyle_slidein_add_child (GtkBuildable *buildable,
                          GtkBuilder   *builder,
                          GObject      *child,
                          const gchar  *type)
{
  GstyleSlidein *self = (GstyleSlidein *)buildable;

  g_assert (GSTYLE_SLIDEIN (self));
  g_assert (GTK_IS_BUILDER (builder));
  g_assert (G_IS_OBJECT (child));

  if (!GTK_IS_WIDGET (child))
    {
      g_warning ("Attempt to add a child of type \"%s\" to a \"%s\"",
                 G_OBJECT_TYPE_NAME (child), G_OBJECT_TYPE_NAME (self));
      return;
    }

  if (type != NULL && g_strcmp0 (type, "slide") == 0)
    gstyle_slidein_add_slide (GSTYLE_SLIDEIN (buildable), GTK_WIDGET (child));
  else if (type == NULL)
    GTK_CONTAINER_CLASS (gstyle_slidein_parent_class)->add (GTK_CONTAINER (buildable), GTK_WIDGET (child));
  else
    GTK_BUILDER_WARN_INVALID_CHILD_TYPE (buildable, type);
}
static void
gstyle_color_panel_actions_toggle_page (GSimpleAction *action,
                                        GVariant      *variant,
                                        gpointer       user_data)
{
  GstyleColorPanel *self = (GstyleColorPanel *)user_data;
  g_autoptr (GVariant) value = NULL;
  g_autofree gchar *page_name = NULL;
  const gchar *name;
  gboolean state;

  g_assert (GSTYLE_IS_COLOR_PANEL (self));

  value = g_action_get_state (G_ACTION (action));
  state = g_variant_get_boolean (value);
  name = g_action_get_name(G_ACTION (action));
  if (!g_str_has_prefix (name, "toggle-"))
    return;

  page_name = g_strdup (&name [7]);
  g_simple_action_set_state (action, g_variant_new_boolean (!state));
  if (!state)
    {
      _gstyle_color_panel_update_prefs_page (self, page_name);
      gtk_stack_set_visible_child_name (self->prefs_stack, page_name);
    }

  gstyle_slidein_reveal_slide (GSTYLE_SLIDEIN (self->prefs_slidein),
                               !gstyle_slidein_get_revealed (GSTYLE_SLIDEIN (self->prefs_slidein)));
}
Esempio n. 3
0
static void
gstyle_slidein_set_property (GObject      *object,
                             guint         prop_id,
                             const GValue *value,
                             GParamSpec   *pspec)
{
  GstyleSlidein *self = GSTYLE_SLIDEIN (object);

  switch (prop_id)
    {
    case PROP_DIRECTION_TYPE:
      gstyle_slidein_set_direction_type (self, g_value_get_enum (value));
      break;

    case PROP_DURATION:
      gstyle_slidein_set_duration (self, g_value_get_double (value));
      break;

    case PROP_INTERPOLATE_SIZE:
      gstyle_slidein_set_interpolate_size (self, g_value_get_boolean (value));
      break;

    case PROP_SLIDE_FRACTION:
      gstyle_slidein_set_slide_fraction (self, g_value_get_double (value));
      break;

    case PROP_SLIDE_MARGIN:
      gstyle_slidein_set_slide_margin (self, g_value_get_uint (value));
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
    }
}