static void
update_container_parent_informations (GstyleColorWidget *self)
{
  GtkWidget *parent;
  GtkWidget *grand_parent;
  GtkWidget *container;
  GstylePaletteWidget *palette_widget;

  g_assert (GSTYLE_IS_COLOR_WIDGET (self));

  parent = gtk_widget_get_parent (GTK_WIDGET (self));
  if (GTK_IS_LIST_BOX_ROW (parent) || GTK_IS_FLOW_BOX_CHILD (parent))
    {
      grand_parent = gtk_widget_get_parent (GTK_WIDGET (parent));
      if (grand_parent != NULL && g_str_has_prefix (gtk_widget_get_name (grand_parent), "palette"))
        {
          self->is_in_palette_widget = TRUE;
          container = gtk_widget_get_ancestor (grand_parent, GSTYLE_TYPE_PALETTE_WIDGET);
          if (container != NULL && GSTYLE_IS_PALETTE_WIDGET (container))
            {
              palette_widget = GSTYLE_PALETTE_WIDGET (container);
              self->container_view_mode = gstyle_palette_widget_get_view_mode (GSTYLE_PALETTE_WIDGET (palette_widget));

              return;
            }
        }
    }

  self->is_in_palette_widget = FALSE;
}
static GstylePaletteWidgetDndLockFlags
get_palette_widget_dnd_lock (GstyleColorWidget *self)
{
  GtkWidget *palette_widget;

  g_assert (GSTYLE_IS_COLOR_WIDGET (self));

  palette_widget = gtk_widget_get_ancestor (GTK_WIDGET (self), GSTYLE_TYPE_PALETTE_WIDGET);
  if (palette_widget != NULL)
    return gstyle_palette_widget_get_dnd_lock (GSTYLE_PALETTE_WIDGET (palette_widget));
  else
    return GSTYLE_PALETTE_WIDGET_DND_LOCK_FLAGS_NONE;
}
Beispiel #3
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);
    }
}