background: Add "swap" button for gradients
https://bugzilla.gnome.org/show_bug.cgi?id=34498
This commit is contained in:
parent
2066d456ab
commit
dd1b9d8336
2 changed files with 64 additions and 2 deletions
|
@ -241,11 +241,18 @@
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkColorButton" id="style-scolor">
|
<object class="GtkButton" id="swap-color-button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="color">#000000000000</property>
|
<property name="use_action_appearance">False</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="image1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="icon_name">object-flip-horizontal-symbolic</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
|
@ -269,6 +276,20 @@
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">False</property>
|
<property name="fill">False</property>
|
||||||
<property name="pack_type">end</property>
|
<property name="pack_type">end</property>
|
||||||
|
<property name="position">3</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkColorButton" id="style-scolor">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<property name="use_action_appearance">False</property>
|
||||||
|
<property name="color">#000000000000</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">False</property>
|
||||||
<property name="position">2</property>
|
<property name="position">2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
|
|
@ -250,6 +250,12 @@ source_update_edit_box (CcBackgroundPanelPrivate *priv,
|
||||||
else
|
else
|
||||||
gtk_widget_show (WID ("style-pcolor"));
|
gtk_widget_show (WID ("style-pcolor"));
|
||||||
|
|
||||||
|
if (gtk_widget_get_visible (WID ("style-pcolor")) &&
|
||||||
|
gtk_widget_get_visible (WID ("style-scolor")))
|
||||||
|
gtk_widget_show (WID ("swap-color-button"));
|
||||||
|
else
|
||||||
|
gtk_widget_hide (WID ("swap-color-button"));
|
||||||
|
|
||||||
if (flags & CC_BACKGROUND_ITEM_HAS_PLACEMENT ||
|
if (flags & CC_BACKGROUND_ITEM_HAS_PLACEMENT ||
|
||||||
cc_background_item_get_uri (priv->current_background) == NULL)
|
cc_background_item_get_uri (priv->current_background) == NULL)
|
||||||
gtk_widget_hide (WID ("style-combobox"));
|
gtk_widget_hide (WID ("style-combobox"));
|
||||||
|
@ -813,6 +819,39 @@ color_changed_cb (GtkColorButton *button,
|
||||||
update_preview (priv, NULL);
|
update_preview (priv, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
swap_colors_clicked (GtkButton *button,
|
||||||
|
CcBackgroundPanel *panel)
|
||||||
|
{
|
||||||
|
CcBackgroundPanelPrivate *priv = panel->priv;
|
||||||
|
GdkColor pcolor, scolor;
|
||||||
|
char *new_pcolor, *new_scolor;
|
||||||
|
|
||||||
|
gtk_color_button_get_color (GTK_COLOR_BUTTON (WID ("style-pcolor")), &pcolor);
|
||||||
|
gtk_color_button_get_color (GTK_COLOR_BUTTON (WID ("style-scolor")), &scolor);
|
||||||
|
|
||||||
|
gtk_color_button_set_color (GTK_COLOR_BUTTON (WID ("style-scolor")), &pcolor);
|
||||||
|
gtk_color_button_set_color (GTK_COLOR_BUTTON (WID ("style-pcolor")), &scolor);
|
||||||
|
|
||||||
|
new_pcolor = gdk_color_to_string (&scolor);
|
||||||
|
new_scolor = gdk_color_to_string (&pcolor);
|
||||||
|
|
||||||
|
g_object_set (priv->current_background,
|
||||||
|
"primary-color", new_pcolor,
|
||||||
|
"secondary-color", new_scolor,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
g_settings_set_string (priv->settings, WP_PCOLOR_KEY, new_pcolor);
|
||||||
|
g_settings_set_string (priv->settings, WP_SCOLOR_KEY, new_scolor);
|
||||||
|
|
||||||
|
g_free (new_pcolor);
|
||||||
|
g_free (new_scolor);
|
||||||
|
|
||||||
|
g_settings_apply (priv->settings);
|
||||||
|
|
||||||
|
update_preview (priv, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
row_inserted (GtkTreeModel *tree_model,
|
row_inserted (GtkTreeModel *tree_model,
|
||||||
GtkTreePath *path,
|
GtkTreePath *path,
|
||||||
|
@ -1216,6 +1255,8 @@ cc_background_panel_init (CcBackgroundPanel *self)
|
||||||
G_CALLBACK (color_changed_cb), self);
|
G_CALLBACK (color_changed_cb), self);
|
||||||
g_signal_connect (WID ("style-scolor"), "color-set",
|
g_signal_connect (WID ("style-scolor"), "color-set",
|
||||||
G_CALLBACK (color_changed_cb), self);
|
G_CALLBACK (color_changed_cb), self);
|
||||||
|
g_signal_connect (WID ("swap-color-button"), "clicked",
|
||||||
|
G_CALLBACK (swap_colors_clicked), self);
|
||||||
|
|
||||||
priv->copy_cancellable = g_cancellable_new ();
|
priv->copy_cancellable = g_cancellable_new ();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue