Exemple #1
0
static void
gstyle_color_widget_actions_rename (GSimpleAction *action,
                                    GVariant      *variant,
                                    gpointer       user_data)
{
  GstyleColorWidget *self = (GstyleColorWidget *)user_data;
  GtkWidget *popover;
  GstyleColor *color;
  const gchar *name;

  g_assert (GSTYLE_IS_COLOR_WIDGET (self));
  g_assert (G_IS_SIMPLE_ACTION (action));

  color = gstyle_color_widget_get_color (self);
  name = gstyle_color_get_name (color);

  popover = g_object_new (GSTYLE_TYPE_RENAME_POPOVER,
                          "label", _("Color name"),
                          "name", name,
                          "message", _("Enter a new name for the color"),
                          NULL);

  gtk_popover_set_relative_to (GTK_POPOVER (popover), GTK_WIDGET (self));
  g_signal_connect_swapped (popover, "closed", G_CALLBACK (contextual_popover_closed_cb), self);
  g_signal_connect_swapped (popover, "renamed", G_CALLBACK (rename_popover_entry_renamed_cb), self);
  gtk_popover_popup (GTK_POPOVER (popover));
}
static void
gstyle_color_widget_get_property (GObject    *object,
                                  guint       prop_id,
                                  GValue     *value,
                                  GParamSpec *pspec)
{
  GstyleColorWidget *self = GSTYLE_COLOR_WIDGET (object);

  switch (prop_id)
    {
    case PROP_COLOR:
      g_value_set_object (value, gstyle_color_widget_get_color (self));
      break;

    case PROP_DND_LOCK:
      g_value_set_flags (value, self->dnd_lock);
      break;

    case PROP_NAME_VISIBLE:
      g_value_set_boolean (value, gstyle_color_widget_get_name_visible (self));
      break;

    case PROP_FALLBACK_NAME_KIND:
      g_value_set_enum (value, gstyle_color_widget_get_fallback_name_kind (self));
      break;

    case PROP_FALLBACK_NAME_VISIBLE:
      g_value_set_boolean (value, gstyle_color_widget_get_fallback_name_visible (self));
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
    }
}
Exemple #3
0
static void
rename_popover_entry_renamed_cb (GstyleColorWidget *self,
                                 const gchar       *name)
{
  GstyleColor *color;

  g_assert (GSTYLE_IS_COLOR_WIDGET (self));

  color = gstyle_color_widget_get_color (self);
  gstyle_color_set_name (color, name);
}
Exemple #4
0
static void
gstyle_color_widget_actions_remove (GSimpleAction *action,
                                    GVariant      *variant,
                                    gpointer       user_data)
{
  GstyleColorWidget *self = (GstyleColorWidget *)user_data;
  GtkWidget *ancestor;
  GstylePalette *selected_palette;
  GstyleColor *color;

  g_assert (GSTYLE_IS_COLOR_WIDGET (self));
  g_assert (G_IS_SIMPLE_ACTION (action));

  ancestor = gtk_widget_get_ancestor (GTK_WIDGET (self), GSTYLE_TYPE_PALETTE_WIDGET);
  if (ancestor != NULL)
    {
      color = gstyle_color_widget_get_color (self);
      selected_palette = gstyle_palette_widget_get_selected_palette (GSTYLE_PALETTE_WIDGET (ancestor));
      if (selected_palette != NULL && color != NULL)
        gstyle_palette_remove (selected_palette, color);
    }
}
/**
 * gstyle_color_widget_copy:
 * @self: A #GstyleColorWidget
 *
 * Copy the given ##GstyleColorWidget.
 * Notice that the underlaying #GstyleColor is shared
 * between the two widgets (the copy increase the ref count)
 *
 * Returns: (transfer full): a new #GstyleColorWidget.
 *
 */
GstyleColorWidget *
gstyle_color_widget_copy (GstyleColorWidget *self)
{
  GstyleColorWidget *color_widget;
  GstyleColor *color;
  gboolean name_visible;
  GstyleColorKind fallback_name_kind;
  gboolean fallback_name_visible;

  g_return_val_if_fail (GSTYLE_IS_COLOR_WIDGET (self), NULL);

  color = gstyle_color_widget_get_color (self);
  name_visible = gstyle_color_widget_get_name_visible (self);
  fallback_name_visible = gstyle_color_widget_get_name_visible (self);
  fallback_name_kind = gstyle_color_widget_get_fallback_name_kind (self);

  color_widget = gstyle_color_widget_new_with_color (color);
  gstyle_color_widget_set_name_visible (color_widget, name_visible);
  gstyle_color_widget_set_name_visible (color_widget, fallback_name_visible);
  gstyle_color_widget_set_fallback_name_kind (color_widget, fallback_name_kind);

  return color_widget;
}