[dia/dia-next: 37/59] Use GtkColorButton directly
- From: Zander <zbrown src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia/dia-next: 37/59] Use GtkColorButton directly
- Date: Wed, 9 Jan 2019 18:37:24 +0000 (UTC)
commit 53d64a4a20c221ebb2a40253b4687a3f2e576753
Author: Zander Brown <zbrown gnome org>
Date: Sat Dec 29 11:11:43 2018 +0000
Use GtkColorButton directly
We don't loose much when GtkColorButton was already handling colours with alpha
Allows us to finally ditch DiaDynamicMenu + some DiaList hacks
app/dia-props.c | 30 ++--
app/preferences.c | 6 +-
app/toolbox.c | 1 -
lib/Makefile.am | 3 -
lib/diacolorselector.c | 366 ---------------------------------------
lib/diadynamicmenu.c | 423 ---------------------------------------------
lib/diadynamicmenu.h | 53 ------
lib/diafontselector.c | 1 -
lib/libdia.def | 17 --
lib/prop_attr.c | 14 +-
lib/widgets.c | 1 -
lib/widgets.h | 13 --
lib/widgets/dialist.c | 28 ---
lib/widgets/dialist.h | 3 -
objects/UML/class_dialog.c | 34 ++--
15 files changed, 45 insertions(+), 948 deletions(-)
---
diff --git a/app/dia-props.c b/app/dia-props.c
index d95c5cab..39efeb99 100644
--- a/app/dia-props.c
+++ b/app/dia-props.c
@@ -209,7 +209,7 @@ create_diagram_properties_dialog(Diagram *dia)
gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1);
gtk_widget_show(label);
- bg_colour = dia_color_selector_new();
+ bg_colour = gtk_color_button_new ();
gtk_widget_set_hexpand (bg_colour, TRUE);
gtk_grid_attach (GTK_GRID(table), bg_colour, 1, 0, 1, 1);
gtk_widget_show (bg_colour);
@@ -220,7 +220,7 @@ create_diagram_properties_dialog(Diagram *dia)
gtk_grid_attach (GTK_GRID (table), label, 0, 1, 1, 1);
gtk_widget_show (label);
- grid_colour = dia_color_selector_new();
+ grid_colour = gtk_color_button_new ();
gtk_widget_set_hexpand (grid_colour, TRUE);
gtk_grid_attach (GTK_GRID (table), grid_colour, 1, 1, 1, 1);
gtk_widget_show (grid_colour);
@@ -231,7 +231,7 @@ create_diagram_properties_dialog(Diagram *dia)
gtk_grid_attach (GTK_GRID (table), label, 0, 2, 1, 1);
gtk_widget_show (label);
- pagebreak_colour = dia_color_selector_new();
+ pagebreak_colour = gtk_color_button_new ();
gtk_widget_set_hexpand (pagebreak_colour, TRUE);
gtk_grid_attach (GTK_GRID (table), pagebreak_colour, 1, 2, 1, 1);
gtk_widget_show(pagebreak_colour);
@@ -276,12 +276,12 @@ diagram_properties_retrieve(Diagram *dia)
gtk_spin_button_set_value(GTK_SPIN_BUTTON(hex_size_entry),
dia->grid.hex_size);
- dia_color_selector_set_color(bg_colour,
- &dia->data->bg_color);
- dia_color_selector_set_color(grid_colour,
- &dia->grid.colour);
- dia_color_selector_set_color(pagebreak_colour,
- &dia->pagebreak_color);
+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (bg_colour),
+ &dia->data->bg_color);
+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (grid_colour),
+ &dia->grid.colour);
+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (pagebreak_colour),
+ &dia->pagebreak_color);
diagram_properties_update_sensitivity(GTK_TOGGLE_BUTTON(dynamic_check), dia);
@@ -339,12 +339,12 @@ diagram_properties_respond(GtkWidget *widget,
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hex_check));
active_diagram->grid.hex_size =
gtk_spin_button_get_value(GTK_SPIN_BUTTON(hex_size_entry));
- dia_color_selector_get_color(bg_colour,
- &active_diagram->data->bg_color);
- dia_color_selector_get_color(grid_colour,
- &active_diagram->grid.colour);
- dia_color_selector_get_color(pagebreak_colour,
- &active_diagram->pagebreak_color);
+ gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (bg_colour),
+ &active_diagram->data->bg_color);
+ gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (grid_colour),
+ &active_diagram->grid.colour);
+ gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (pagebreak_colour),
+ &active_diagram->pagebreak_color);
diagram_add_update_all(active_diagram);
diagram_flush(active_diagram);
diagram_set_modified(active_diagram, TRUE);
diff --git a/app/preferences.c b/app/preferences.c
index de97d492..ca889ba3 100644
--- a/app/preferences.c
+++ b/app/preferences.c
@@ -385,7 +385,7 @@ prefs_set_value_in_widget(GtkWidget * widget, DiaPrefData *data,
(gfloat) (*((real *)ptr)));
break;
case PREF_COLOUR:
- dia_color_selector_set_color(widget, (GdkRGBA *)ptr);
+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (widget), (GdkRGBA *)ptr);
break;
case PREF_CHOICE: {
GList *names = (data->choice_list_function)(data);
@@ -437,7 +437,7 @@ prefs_get_value_from_widget(GtkWidget * widget, DiaPrefData *data,
break;
case PREF_COLOUR: {
GdkRGBA prev = *(GdkRGBA *)ptr;
- dia_color_selector_get_color(widget, (GdkRGBA *)ptr);
+ gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (widget), (GdkRGBA *)ptr);
changed = memcmp (&prev, ptr, sizeof(GdkRGBA));
}
break;
@@ -515,7 +515,7 @@ prefs_get_property_widget(DiaPrefData *data)
gtk_widget_set_size_request (widget, 80, -1);
break;
case PREF_COLOUR:
- widget = dia_color_selector_new();
+ widget = gtk_color_button_new();
break;
case PREF_STRING:
widget = gtk_entry_new();
diff --git a/app/toolbox.c b/app/toolbox.c
index d589a104..17f7e5be 100644
--- a/app/toolbox.c
+++ b/app/toolbox.c
@@ -20,7 +20,6 @@
#include <gtk/gtk.h>
-#include "diadynamicmenu.h"
#include "attributes.h"
#include "sheet.h"
#include "dia-colour-area.h"
diff --git a/lib/Makefile.am b/lib/Makefile.am
index d75505bf..b8d47059 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -191,11 +191,8 @@ libdia_la_SOURCES = \
parent.h \
widgets/dia-arrow-chooser.h \
widgets/dia-arrow-chooser.c \
- diacolorselector.c \
widgets/dia-line-chooser-popover.c \
widgets/dia-line-chooser.c \
- diadynamicmenu.h \
- diadynamicmenu.c \
diafontselector.h \
diafontselector.c \
persistence.c \
diff --git a/lib/diafontselector.c b/lib/diafontselector.c
index 802c75e9..07215201 100644
--- a/lib/diafontselector.c
+++ b/lib/diafontselector.c
@@ -24,7 +24,6 @@
#include <gtk/gtk.h>
#include "diafontselector.h"
-#include "diadynamicmenu.h"
#include "font.h"
/************* DiaFontSelector: ***************/
diff --git a/lib/libdia.def b/lib/libdia.def
index 1862c9ce..c3bc9c28 100644
--- a/lib/libdia.def
+++ b/lib/libdia.def
@@ -185,11 +185,6 @@ EXPORTS
dia_alignment_selector_new
dia_alignment_selector_set_alignment
dia_assert_true
- dia_color_selector_get_color
-; dia_color_selector_get_type
- dia_color_selector_new
- dia_color_selector_set_color
- dia_color_selector_set_use_alpha
dia_config_filename
dia_context_add_message
@@ -200,18 +195,6 @@ EXPORTS
dia_context_reset
dia_context_set_filename
- dia_dynamic_menu_get_type
- dia_dynamic_menu_new
- dia_dynamic_menu_new_listbased
- dia_dynamic_menu_add_default_entry
- dia_dynamic_menu_add_entry
- dia_dynamic_menu_set_sorting_method
- dia_dynamic_menu_reset
- dia_dynamic_menu_set_max_entries
- dia_dynamic_menu_set_columns
- dia_dynamic_menu_get_entry
- dia_dynamic_menu_select_entry
-
dia_file_selector_get_file
dia_file_selector_get_type
dia_file_selector_new
diff --git a/lib/prop_attr.c b/lib/prop_attr.c
index e29ecb3d..06904d54 100644
--- a/lib/prop_attr.c
+++ b/lib/prop_attr.c
@@ -290,24 +290,24 @@ colorprop_copy(ColorProperty *src)
static WIDGET *
colorprop_get_widget(ColorProperty *prop, PropDialog *dialog)
{
- GtkWidget *ret = dia_color_selector_new();
- dia_color_selector_set_use_alpha (ret, TRUE);
- prophandler_connect(&prop->common, G_OBJECT(ret), "value-changed");
+ GtkWidget *ret = gtk_color_button_new();
+ gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (ret), TRUE);
+ prophandler_connect(&prop->common, G_OBJECT(ret), "color-set");
return ret;
}
static void
colorprop_reset_widget(ColorProperty *prop, WIDGET *widget)
{
- dia_color_selector_set_color(widget,
- &prop->color_data);
+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (widget),
+ &prop->color_data);
}
static void
colorprop_set_from_widget(ColorProperty *prop, WIDGET *widget)
{
- dia_color_selector_get_color(widget,
- &prop->color_data);
+ gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (widget),
+ &prop->color_data);
}
static void
diff --git a/lib/widgets.c b/lib/widgets.c
index 0ece3cfe..9f97ec7c 100644
--- a/lib/widgets.c
+++ b/lib/widgets.c
@@ -23,7 +23,6 @@
#include "units.h"
#include "message.h"
#include "dia_dirs.h"
-#include "diadynamicmenu.h"
#include "diaoptionmenu.h"
#include "dia-lib-icons.h"
diff --git a/lib/widgets.h b/lib/widgets.h
index 72a9b35f..a7c7c2b3 100644
--- a/lib/widgets.h
+++ b/lib/widgets.h
@@ -32,19 +32,6 @@ GtkWidget* dia_alignment_selector_new (void);
Alignment dia_alignment_selector_get_alignment (GtkWidget *as);
void dia_alignment_selector_set_alignment (GtkWidget *as, Alignment align);
-/* DiaColorSelector: */
-#define DIACOLORSELECTOR(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, dia_color_selector_get_type (),
DiaColorSelector)
-#define DIACOLORSELECTOR_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, dia_color_selector_get_type (),
DiaColorSelectorClass)
-#define IS_DIACOLORSELECTOR(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, dia_color_selector_get_type ())
-
-GType dia_color_selector_get_type (void);
-GtkWidget* dia_color_selector_new (void);
-void dia_color_selector_set_use_alpha (GtkWidget *cs, gboolean use_alpha);
-void dia_color_selector_get_color (GtkWidget *cs, GdkRGBA *color);
-void dia_color_selector_set_color (GtkWidget *cs,
- const GdkRGBA *color);
-
-
/* DiaArrowSelector */
#define DEFAULT_ARROW ARROW_NONE
#define DEFAULT_ARROW_LENGTH DEFAULT_ARROW_SIZE
diff --git a/lib/widgets/dialist.c b/lib/widgets/dialist.c
index 05396893..7f53c1b3 100644
--- a/lib/widgets/dialist.c
+++ b/lib/widgets/dialist.c
@@ -230,34 +230,6 @@ dia_list_append (DiaList *self,
return DIA_LIST_ITEM (row);
}
-void
-dia_list_add (DiaList *self,
- GtkListBoxRow *item)
-{
- GtkWidget* list;
-
- g_return_val_if_fail (self != NULL, NULL);
- g_return_val_if_fail (item != NULL, NULL);
-
- list = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
- gtk_container_add (GTK_CONTAINER (list), item);
-}
-
-void
-dia_list_add_seperator (DiaList *self)
-{
- GtkWidget *sep;
- GtkWidget *list;
-
- g_return_if_fail (self != NULL);
-
- sep = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
- gtk_widget_show_all (sep);
-
- list = ((DiaListPrivate *) dia_list_get_instance_private (self))->real;
- gtk_container_add (GTK_CONTAINER (list), sep);
-}
-
void
dia_list_select_item (DiaList *self,
gint i)
diff --git a/lib/widgets/dialist.h b/lib/widgets/dialist.h
index 2f4fe553..b7b4d07c 100644
--- a/lib/widgets/dialist.h
+++ b/lib/widgets/dialist.h
@@ -36,11 +36,8 @@ void dia_list_remove_items (DiaList *self,
GList *items);
DiaListItem *dia_list_append (DiaList *self,
const gchar *item);
-void dia_list_add (DiaList *self,
- GtkListBoxRow *itm);
void dia_list_set_active (DiaList *self,
gint index);
-void dia_list_add_seperator (DiaList *self);
void dia_list_select_item (DiaList *self,
gint i);
void dia_list_empty (DiaList *self);
diff --git a/objects/UML/class_dialog.c b/objects/UML/class_dialog.c
index 9bcf8561..b898c6d7 100644
--- a/objects/UML/class_dialog.c
+++ b/objects/UML/class_dialog.c
@@ -207,9 +207,12 @@ class_read_from_dialog(UMLClass *umlclass, UMLClassDialog *prop_dialog)
umlclass->suppress_attributes = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (prop_dialog->attr_supp));
umlclass->suppress_operations = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (prop_dialog->op_supp));
umlclass->line_width = gtk_spin_button_get_value(prop_dialog->line_width);
- dia_color_selector_get_color(GTK_WIDGET(prop_dialog->text_color), ¨class->text_color);
- dia_color_selector_get_color(GTK_WIDGET(prop_dialog->line_color), ¨class->line_color);
- dia_color_selector_get_color(GTK_WIDGET(prop_dialog->fill_color), ¨class->fill_color);
+ gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (prop_dialog->text_color),
+ ¨class->text_color);
+ gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (prop_dialog->line_color),
+ ¨class->line_color);
+ gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (prop_dialog->fill_color),
+ ¨class->fill_color);
umlclass->normal_font = dia_font_selector_get_font (prop_dialog->normal_font);
umlclass->polymorphic_font = dia_font_selector_get_font (prop_dialog->polymorphic_font);
@@ -256,9 +259,12 @@ class_fill_in_dialog(UMLClass *umlclass)
gtk_toggle_button_set_active(prop_dialog->attr_supp, umlclass->suppress_attributes);
gtk_toggle_button_set_active(prop_dialog->op_supp, umlclass->suppress_operations);
gtk_spin_button_set_value (prop_dialog->line_width, umlclass->line_width);
- dia_color_selector_set_color(GTK_WIDGET(prop_dialog->text_color), ¨class->text_color);
- dia_color_selector_set_color(GTK_WIDGET(prop_dialog->line_color), ¨class->line_color);
- dia_color_selector_set_color(GTK_WIDGET(prop_dialog->fill_color), ¨class->fill_color);
+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (prop_dialog->text_color),
+ ¨class->text_color);
+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (prop_dialog->line_color),
+ ¨class->line_color);
+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (prop_dialog->fill_color),
+ ¨class->fill_color);
dia_font_selector_set_font (prop_dialog->normal_font, umlclass->normal_font);
dia_font_selector_set_font (prop_dialog->polymorphic_font, umlclass->polymorphic_font);
dia_font_selector_set_font (prop_dialog->abstract_font, umlclass->abstract_font);
@@ -522,9 +528,9 @@ style_create_page(GtkNotebook *notebook, UMLClass *umlclass)
gtk_label_set_yalign (GTK_LABEL (label), 0.5);
gtk_widget_set_hexpand (label, TRUE);
gtk_grid_attach (GTK_GRID (table), label, 0, 1, 1, 1);
- text_color = dia_color_selector_new();
- dia_color_selector_set_use_alpha (text_color, TRUE);
- dia_color_selector_set_color(text_color, ¨class->text_color);
+ text_color = gtk_color_button_new();
+ gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (text_color), TRUE);
+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (text_color), ¨class->text_color);
prop_dialog->text_color = (DiaColorSelector *)text_color;
gtk_widget_set_hexpand (text_color, TRUE);
@@ -535,9 +541,9 @@ style_create_page(GtkNotebook *notebook, UMLClass *umlclass)
gtk_label_set_yalign (GTK_LABEL (label), 0.5);
gtk_widget_set_hexpand (label, TRUE);
gtk_grid_attach (GTK_GRID (table), label, 0, 2, 1, 1);
- line_color = dia_color_selector_new();
- dia_color_selector_set_use_alpha (line_color, TRUE);
- dia_color_selector_set_color(line_color, ¨class->line_color);
+ line_color = gtk_color_button_new();
+ gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (line_color), TRUE);
+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (line_color), ¨class->line_color);
prop_dialog->line_color = (DiaColorSelector *)line_color;
gtk_widget_set_hexpand (line_color, TRUE);
@@ -548,8 +554,8 @@ style_create_page(GtkNotebook *notebook, UMLClass *umlclass)
gtk_label_set_yalign (GTK_LABEL (label), 0.5);
gtk_widget_set_hexpand (label, TRUE);
gtk_grid_attach (GTK_GRID (table), label, 0, 3, 1, 1);
- fill_color = dia_color_selector_new();
- dia_color_selector_set_color(fill_color, ¨class->fill_color);
+ fill_color = gtk_color_button_new ();
+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (fill_color), ¨class->fill_color);
prop_dialog->fill_color = (DiaColorSelector *)fill_color;
gtk_widget_set_hexpand (fill_color, TRUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]