[dia/dia-next: 50/59] Clean up presentation of property dialogs
- From: Zander <zbrown src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia/dia-next: 50/59] Clean up presentation of property dialogs
- Date: Wed, 9 Jan 2019 18:38:30 +0000 (UTC)
commit 35407ed1bb0c239cf3ae3074ff93ee08c73fd9e7
Author: Zander Brown <zbrown gnome org>
Date: Thu Jan 3 02:35:14 2019 +0000
Clean up presentation of property dialogs
app/dia-props.c | 5 ++--
app/properties-dialog.c | 55 +++++++++++++++++++++++------------------
lib/prop_attr.c | 2 ++
lib/prop_inttypes.c | 61 ++++++++++++++++++++++++++++++++++------------
lib/prop_widgets.c | 55 ++++++-----------------------------------
lib/propdialogs.c | 14 ++++-------
objects/UML/class_dialog.c | 1 +
7 files changed, 95 insertions(+), 98 deletions(-)
---
diff --git a/app/dia-props.c b/app/dia-props.c
index 39efeb99..e14e0670 100644
--- a/app/dia-props.c
+++ b/app/dia-props.c
@@ -94,6 +94,7 @@ create_diagram_properties_dialog(Diagram *dia)
gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_OK);
dialog_vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
+ gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 0);
gtk_window_set_role(GTK_WINDOW(dialog), "diagram_properties");
@@ -106,9 +107,9 @@ create_diagram_properties_dialog(Diagram *dia)
G_CALLBACK(gtk_widget_destroyed), &dialog);
notebook = gtk_notebook_new();
- gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_TOP);
+ gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP);
+ gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
gtk_box_pack_start(GTK_BOX(dialog_vbox), notebook, TRUE, TRUE, 0);
- gtk_container_set_border_width(GTK_CONTAINER(notebook), 2);
gtk_widget_show(notebook);
/* the grid page */
diff --git a/app/properties-dialog.c b/app/properties-dialog.c
index 98509f26..d250d3e9 100644
--- a/app/properties-dialog.c
+++ b/app/properties-dialog.c
@@ -55,19 +55,27 @@ create_dialog(GtkWidget *parent)
{
/* GtkWidget *actionbox; */
/* GList *buttons; */
-
- dialog = gtk_dialog_new_with_buttons(
- _("Object properties"),
- parent ? GTK_WINDOW (parent) : NULL,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- _("Close"), GTK_RESPONSE_CLOSE,
- _("Apply"), GTK_RESPONSE_APPLY,
- _("Okay"), GTK_RESPONSE_OK,
- NULL);
+ gboolean header;
+
+ g_object_get (gtk_settings_get_default (),
+ "gtk-dialogs-use-header", &header,
+ NULL);
+ dialog = g_object_new (GTK_TYPE_DIALOG,
+ "title", _("Object properties"),
+ "transient-for", parent ? GTK_WINDOW (parent) : NULL,
+ "destroy-with-parent", TRUE,
+ "use-header-bar", header,
+ NULL);
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ _("Cancel"), GTK_RESPONSE_CANCEL,
+ _("Okay"), GTK_RESPONSE_OK,
+ _("Apply"), GTK_RESPONSE_APPLY,
+ NULL);
gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_OK);
dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG(dialog));
+ gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 0);
gtk_window_set_role(GTK_WINDOW (dialog), "properties_window");
@@ -133,29 +141,28 @@ properties_respond(GtkWidget *widget,
object_add_updates_list(current_objects, current_dia);
for (tmp = current_objects; tmp != NULL; tmp = tmp->next) {
- DiaObject *current_obj = (DiaObject*)tmp->data;
- obj_change = current_obj->ops->apply_properties_from_dialog(current_obj, object_part);
- object_add_updates(current_obj, current_dia);
- diagram_update_connections_object(current_dia, current_obj, TRUE);
+ DiaObject *current_obj = (DiaObject*)tmp->data;
+ obj_change = current_obj->ops->apply_properties_from_dialog(current_obj, object_part);
+ object_add_updates(current_obj, current_dia);
+ diagram_update_connections_object(current_dia, current_obj, TRUE);
- if (obj_change != NULL) {
- undo_object_change(current_dia, current_obj, obj_change);
- set_tp = set_tp && TRUE;
- } else
- set_tp = FALSE;
-
- diagram_object_modified(current_dia, current_obj);
+ if (obj_change != NULL) {
+ undo_object_change(current_dia, current_obj, obj_change);
+ set_tp = set_tp && TRUE;
+ } else
+ set_tp = FALSE;
+ diagram_object_modified(current_dia, current_obj);
}
diagram_modified(current_dia);
diagram_update_extents(current_dia);
if (set_tp) {
- undo_set_transactionpoint(current_dia->undo);
+ undo_set_transactionpoint(current_dia->undo);
} else {
- message_warning(_("This object doesn't support Undo/Redo.\n"
- "Undo information erased."));
- undo_clear(current_dia->undo);
+ message_warning(_("This object doesn't support Undo/Redo.\n"
+ "Undo information erased."));
+ undo_clear(current_dia->undo);
}
diagram_flush(current_dia);
diff --git a/lib/prop_attr.c b/lib/prop_attr.c
index 06904d54..632b88ca 100644
--- a/lib/prop_attr.c
+++ b/lib/prop_attr.c
@@ -65,6 +65,7 @@ static WIDGET *
linestyleprop_get_widget(LinestyleProperty *prop, PropDialog *dialog)
{
GtkWidget *ret = dia_line_chooser_new();
+ gtk_widget_set_size_request (ret, 150, -1);
prophandler_connect(&prop->common, G_OBJECT(ret), "value-changed");
return ret;
}
@@ -173,6 +174,7 @@ static WIDGET *
arrowprop_get_widget(ArrowProperty *prop, PropDialog *dialog)
{
GtkWidget *ret = dia_arrow_chooser_new (FALSE);
+ gtk_widget_set_size_request (ret, 150, -1);
prophandler_connect(&prop->common, G_OBJECT(ret), "value-changed");
return ret;
}
diff --git a/lib/prop_inttypes.c b/lib/prop_inttypes.c
index 1148a141..54b4f99b 100644
--- a/lib/prop_inttypes.c
+++ b/lib/prop_inttypes.c
@@ -152,15 +152,6 @@ static const PropertyOps charprop_ops = {
/* The BOOL property type. */
/***************************/
-static void
-bool_toggled(GtkWidget *wid)
-{
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(wid)))
- gtk_label_set_text(GTK_LABEL(gtk_bin_get_child(GTK_BIN(wid))), _("Yes"));
- else
- gtk_label_set_text(GTK_LABEL(gtk_bin_get_child(GTK_BIN(wid))), _("No"));
-}
-
static Property *
boolprop_new(const PropDescription *pdesc, PropDescToPropPredicate reason)
{
@@ -181,26 +172,66 @@ boolprop_copy(BoolProperty *src)
return prop;
}
+G_DECLARE_FINAL_TYPE (DiaSwitch, dia_switch, DIA, SWITCH, GtkSwitch)
+
+struct _DiaSwitch {
+ GtkSwitch parent;
+};
+
+G_DEFINE_TYPE (DiaSwitch, dia_switch, GTK_TYPE_SWITCH)
+
+enum {
+ CHANGED,
+ LAST_SIGNAL
+};
+static guint signals[LAST_SIGNAL] = { 0 };
+
+static void
+dia_switch_class_init (DiaSwitchClass *klass)
+{
+ signals[CHANGED] = g_signal_new ("changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE, 0);
+}
+
+static void
+bubble (DiaSwitch *self)
+{
+ g_signal_emit (self, signals[CHANGED], 0);
+}
+
+static void
+dia_switch_init (DiaSwitch *self)
+{
+ g_signal_connect (self, "notify::active", G_CALLBACK (bubble), NULL);
+}
+
+static GtkWidget *
+dia_switch_new ()
+{
+ return g_object_new (dia_switch_get_type (), NULL);
+}
+
static WIDGET *
boolprop_get_widget(BoolProperty *prop, PropDialog *dialog)
{
- GtkWidget *ret = gtk_toggle_button_new_with_label(_("No"));
- g_signal_connect(G_OBJECT(ret), "toggled",
- G_CALLBACK (bool_toggled), NULL);
- prophandler_connect(&prop->common, G_OBJECT(ret), "toggled");
+ GtkWidget *ret = dia_switch_new ();
+ prophandler_connect(&prop->common, G_OBJECT(ret), "changed");
return ret;
}
static void
boolprop_reset_widget(BoolProperty *prop, WIDGET *widget)
{
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget),prop->bool_data);
+ gtk_switch_set_active (GTK_SWITCH (widget), prop->bool_data);
}
static void
boolprop_set_from_widget(BoolProperty *prop, WIDGET *widget)
{
- prop->bool_data = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget));
+ prop->bool_data = gtk_switch_get_active (GTK_SWITCH (widget));
}
static void
diff --git a/lib/prop_widgets.c b/lib/prop_widgets.c
index 68f4a080..1c615d29 100644
--- a/lib/prop_widgets.c
+++ b/lib/prop_widgets.c
@@ -99,62 +99,21 @@ static const PropertyOps buttonprop_ops = {
/* The FRAME_BEGIN and FRAME_END property types. */
/**************************************************/
-struct FoldButtonInfo {
- GtkWidget *unfoldbutton;
- GtkWidget *frame;
-};
-
-static void
-frame_fold_unfold(GtkWidget *button1, gpointer userdata)
-{
- struct FoldButtonInfo *info = (struct FoldButtonInfo *)userdata;
-
- if (button1 == info->unfoldbutton) {
- gtk_widget_set_sensitive (info->unfoldbutton, FALSE);
- gtk_widget_hide(info->unfoldbutton);
- gtk_widget_show(info->frame);
- } else {
- gtk_widget_hide(info->frame);
- gtk_widget_show(info->unfoldbutton);
- gtk_widget_set_sensitive (info->unfoldbutton, TRUE);
- }
-}
-
static GtkWidget *
frame_beginprop_get_widget(FrameProperty *prop, PropDialog *dialog)
{
- gchar *foldstring = g_strdup_printf("%s <<<", _(prop->common.descr->description));
- gchar *unfoldstring = g_strdup_printf("%s >>>", _(prop->common.descr->description));
- GtkWidget *frame = gtk_frame_new(NULL);
+ GtkWidget *frame = gtk_expander_new (_(prop->common.descr->description));
GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
- GtkWidget *foldbutton = gtk_button_new_with_label(foldstring);
- GtkWidget *unfoldbutton = gtk_button_new_with_label(unfoldstring);
-
- struct FoldButtonInfo *info = g_new(struct FoldButtonInfo, 1);
-
- g_free(foldstring);
- g_free(unfoldstring);
- info->frame = frame;
- info->unfoldbutton = unfoldbutton;
-
- gtk_frame_set_label_widget(GTK_FRAME(frame), foldbutton);
+ gtk_expander_set_expanded (GTK_EXPANDER (frame), TRUE);
+ gtk_expander_set_resize_toplevel (GTK_EXPANDER (frame), TRUE);
gtk_container_set_border_width (GTK_CONTAINER(frame), 2);
gtk_container_add(GTK_CONTAINER(frame),vbox);
- gtk_widget_set_sensitive (unfoldbutton, FALSE);
- gtk_widget_show(foldbutton);
gtk_widget_show(frame);
gtk_widget_show(vbox);
- prop_dialog_add_raw(dialog, frame);
-
- prop_dialog_add_raw_with_flags(dialog, unfoldbutton, FALSE, FALSE);
-
- g_signal_connect(G_OBJECT (foldbutton), "clicked",
- G_CALLBACK (frame_fold_unfold), info);
- g_signal_connect(G_OBJECT (unfoldbutton), "clicked",
- G_CALLBACK (frame_fold_unfold), info);
+ prop_dialog_add_raw(dialog, frame);
prop_dialog_container_push(dialog,vbox);
@@ -298,9 +257,9 @@ notebook_beginprop_get_widget(NotebookProperty *prop, PropDialog *dialog)
{
GtkWidget *notebook = gtk_notebook_new();
- gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook),GTK_POS_TOP);
- gtk_container_set_border_width (GTK_CONTAINER(notebook), 1);
- gtk_widget_show(notebook);
+ gtk_notebook_set_tab_pos (GTK_NOTEBOOK(notebook),GTK_POS_TOP);
+ gtk_notebook_set_show_border (GTK_NOTEBOOK(notebook), FALSE);
+ gtk_widget_show (notebook);
prop_dialog_add_raw(dialog,notebook);
diff --git a/lib/propdialogs.c b/lib/propdialogs.c
index 35de9948..ae1b0cb6 100644
--- a/lib/propdialogs.c
+++ b/lib/propdialogs.c
@@ -113,8 +113,8 @@ static void
prop_dialog_make_curtable(PropDialog *dialog)
{
GtkWidget *table = gtk_grid_new ();
- gtk_grid_set_row_spacing (GTK_GRID (table), 2);
- gtk_grid_set_column_spacing (GTK_GRID (table), 5);
+ gtk_grid_set_row_spacing (GTK_GRID (table), 8);
+ gtk_grid_set_column_spacing (GTK_GRID (table), 16);
gtk_widget_show(table);
prop_dialog_add_raw(dialog,table);
@@ -129,16 +129,14 @@ prop_dialog_add_widget(PropDialog *dialog, GtkWidget *label, GtkWidget *widget)
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_label_set_yalign (GTK_LABEL (label), 0.5);
- gtk_widget_set_vexpand (GTK_WIDGET (label), TRUE);
gtk_widget_set_halign (GTK_WIDGET (label), GTK_ALIGN_FILL);
- gtk_widget_set_valign (GTK_WIDGET (label), GTK_ALIGN_FILL);
+ gtk_widget_set_valign (GTK_WIDGET (label), GTK_ALIGN_CENTER);
gtk_grid_attach (GTK_GRID (dialog->curtable), label,
0, dialog->currow, 1, 1);
gtk_widget_set_hexpand (GTK_WIDGET (widget), TRUE);
- gtk_widget_set_vexpand (GTK_WIDGET (widget), TRUE);
- gtk_widget_set_halign (GTK_WIDGET (widget), GTK_ALIGN_FILL);
- gtk_widget_set_valign (GTK_WIDGET (widget), GTK_ALIGN_FILL);
+ gtk_widget_set_halign (GTK_WIDGET (widget), GTK_ALIGN_END);
+ gtk_widget_set_valign (GTK_WIDGET (widget), GTK_ALIGN_CENTER);
gtk_grid_attach (GTK_GRID (dialog->curtable), widget,
1, dialog->currow, 1, 1);
@@ -274,8 +272,6 @@ prop_dialog_add_property(PropDialog *dialog, Property *prop)
label = gtk_label_new("");
else
label = gtk_label_new(_(prop->descr->description));
- gtk_label_set_xalign (GTK_LABEL (label), 0.0);
- gtk_label_set_yalign (GTK_LABEL (label), 0.5);
prop_dialog_add_widget(dialog, label, widget);
}
diff --git a/objects/UML/class_dialog.c b/objects/UML/class_dialog.c
index 6e5bfb71..95e44035 100644
--- a/objects/UML/class_dialog.c
+++ b/objects/UML/class_dialog.c
@@ -468,6 +468,7 @@ umlclass_get_properties(UMLClass *umlclass, gboolean is_default)
notebook = gtk_notebook_new ();
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP);
+ gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
prop_dialog->dialog = notebook;
g_object_set_data(G_OBJECT(notebook), "user_data", (gpointer) umlclass);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]