1021
1015
return g_list_reverse (command_properties);
1026
1019
glade_gtk_widget_action_activate (GladeWidgetAdaptor *adaptor,
1027
1020
GObject *object,
1028
1021
const gchar *action_path)
1030
1023
GladeWidget *gwidget = glade_widget_get_from_gobject (object), *gparent;
1031
GList this_widget = { 0, }, that_widget = { 0, };
1032
GtkWidget *parent = gtk_widget_get_parent (GTK_WIDGET (object));
1024
GList this_widget = { 0, }, that_widget = { 0,};
1025
GtkWidget *parent = gtk_widget_get_parent (GTK_WIDGET (object));
1026
GladeProject *project;
1035
1029
gparent = glade_widget_get_from_gobject (parent);
1037
1031
gparent = NULL;
1033
project = glade_widget_get_project (gwidget);
1039
1035
if (strcmp (action_path, "edit_separate") == 0)
1042
glade_editor_dialog_for_widget (gwidget);
1037
GtkWidget *dialog = glade_editor_dialog_for_widget (gwidget);
1043
1038
gtk_widget_show_all (dialog);
1045
1040
else if (strcmp (action_path, "remove_parent") == 0)
1047
1042
GladeWidget *new_gparent;
1043
GladeProperty *property;
1049
1045
g_return_if_fail (gparent);
1050
new_gparent = gparent->parent;
1052
glade_command_push_group (_("Removing parent of %s"),
1055
/* Remove "this" widget */
1047
property = glade_widget_get_parentless_widget_ref (gparent);
1048
new_gparent = glade_widget_get_parent (gparent);
1050
glade_command_push_group (_("Removing parent of %s"), glade_widget_get_name (gwidget));
1052
/* Remove "this" widget, If the parent we're removing is a parentless
1053
* widget reference, the reference will be implicitly broken by the 'cut' command */
1056
1054
this_widget.data = gwidget;
1057
glade_command_cut (&this_widget);
1055
glade_command_delete (&this_widget);
1059
1057
/* Delete the parent */
1060
1058
that_widget.data = gparent;
1061
1059
glade_command_delete (&that_widget);
1063
/* Add "this" widget to the new parent */
1064
glade_command_paste(&this_widget, new_gparent, NULL);
1061
/* Add "this" widget to the new parent, if there is no new parent this will re-add
1062
* the widget to the project at the toplevel without a parent
1064
glade_command_add (&this_widget, new_gparent, NULL, project, FALSE);
1066
/* If the parent had a parentless widget reference, undoably add the child
1067
* as the new parentless widget reference here */
1069
glade_command_set_property (property, glade_widget_get_object (gwidget));
1066
1071
glade_command_pop_group ();
1068
1073
else if (strncmp (action_path, "add_parent/", 11) == 0)
1070
1075
GType new_type = 0;
1072
if (strcmp (action_path + 11, "alignment") == 0)
1073
new_type = GTK_TYPE_ALIGNMENT;
1074
else if (strcmp (action_path + 11, "viewport") == 0)
1075
new_type = GTK_TYPE_VIEWPORT;
1076
else if (strcmp (action_path + 11, "eventbox") == 0)
1077
new_type = GTK_TYPE_EVENT_BOX;
1078
else if (strcmp (action_path + 11, "frame") == 0)
1079
new_type = GTK_TYPE_FRAME;
1080
else if (strcmp (action_path + 11, "aspect_frame") == 0)
1081
new_type = GTK_TYPE_ASPECT_FRAME;
1082
else if (strcmp (action_path + 11, "scrolled_window") == 0)
1083
new_type = GTK_TYPE_SCROLLED_WINDOW;
1084
else if (strcmp (action_path + 11, "expander") == 0)
1085
new_type = GTK_TYPE_EXPANDER;
1086
else if (strcmp (action_path + 11, "table") == 0)
1087
new_type = GTK_TYPE_TABLE;
1088
else if (strcmp (action_path + 11, "hbox") == 0)
1089
new_type = GTK_TYPE_HBOX;
1090
else if (strcmp (action_path + 11, "vbox") == 0)
1091
new_type = GTK_TYPE_VBOX;
1092
else if (strcmp (action_path + 11, "hpaned") == 0)
1093
new_type = GTK_TYPE_HPANED;
1094
else if (strcmp (action_path + 11, "vpaned") == 0)
1095
new_type = GTK_TYPE_VPANED;
1100
GladeWidgetAdaptor *adaptor = glade_widget_adaptor_get_by_type (new_type);
1101
GList *saved_props, *prop_cmds;
1102
GladeProject *project;
1104
/* Dont add non-scrollable widgets to scrolled windows... */
1106
glade_util_check_and_warn_scrollable (gparent, adaptor, glade_app_get_window()))
1109
glade_command_push_group (_("Adding parent %s for %s"),
1110
adaptor->title, gwidget->name);
1112
/* Record packing properties */
1113
saved_props = glade_widget_dup_properties (gwidget, gwidget->packing_properties, FALSE, FALSE, FALSE);
1115
/* Remove "this" widget */
1116
this_widget.data = gwidget;
1117
glade_command_cut (&this_widget);
1120
project = glade_widget_get_project (gparent);
1122
project = glade_app_get_project ();
1124
/* Create new widget and put it where the placeholder was */
1125
if ((that_widget.data =
1126
glade_command_create (adaptor, gparent, NULL, project)) != NULL)
1129
/* Remove the alignment that we added in the frame's post_create... */
1130
if (new_type == GTK_TYPE_FRAME)
1132
GObject *frame = glade_widget_get_object (that_widget.data);
1133
GladeWidget *galign = glade_widget_get_from_gobject (gtk_bin_get_child (GTK_BIN (frame)));
1134
GList to_delete = { 0, };
1136
to_delete.data = galign;
1137
glade_command_delete (&to_delete);
1140
/* Create heavy-duty glade-command properties stuff */
1141
prop_cmds = create_command_property_list (that_widget.data, saved_props);
1142
g_list_foreach (saved_props, (GFunc)g_object_unref, NULL);
1143
g_list_free (saved_props);
1145
/* Apply the properties in an undoable way */
1147
glade_command_set_properties_list (glade_widget_get_project (gparent), prop_cmds);
1149
/* Add "this" widget to the new parent */
1150
glade_command_paste(&this_widget, GLADE_WIDGET (that_widget.data), NULL);
1153
/* Create parent was cancelled, paste back to parent */
1154
glade_command_paste(&this_widget, gparent, NULL);
1156
glade_command_pop_group ();
1159
else if (strcmp (action_path, "sizegroup_add") == 0)
1164
GWA_GET_CLASS (G_TYPE_OBJECT)->action_activate (adaptor,
1076
GladeProperty *property;
1078
if (strcmp (action_path + 11, "alignment") == 0)
1079
new_type = GTK_TYPE_ALIGNMENT;
1080
else if (strcmp (action_path + 11, "viewport") == 0)
1081
new_type = GTK_TYPE_VIEWPORT;
1082
else if (strcmp (action_path + 11, "eventbox") == 0)
1083
new_type = GTK_TYPE_EVENT_BOX;
1084
else if (strcmp (action_path + 11, "frame") == 0)
1085
new_type = GTK_TYPE_FRAME;
1086
else if (strcmp (action_path + 11, "aspect_frame") == 0)
1087
new_type = GTK_TYPE_ASPECT_FRAME;
1088
else if (strcmp (action_path + 11, "scrolled_window") == 0)
1089
new_type = GTK_TYPE_SCROLLED_WINDOW;
1090
else if (strcmp (action_path + 11, "expander") == 0)
1091
new_type = GTK_TYPE_EXPANDER;
1092
else if (strcmp (action_path + 11, "table") == 0)
1093
new_type = GTK_TYPE_TABLE;
1094
else if (strcmp (action_path + 11, "hbox") == 0)
1095
new_type = GTK_TYPE_HBOX;
1096
else if (strcmp (action_path + 11, "vbox") == 0)
1097
new_type = GTK_TYPE_VBOX;
1098
else if (strcmp (action_path + 11, "hpaned") == 0)
1099
new_type = GTK_TYPE_HPANED;
1100
else if (strcmp (action_path + 11, "vpaned") == 0)
1101
new_type = GTK_TYPE_VPANED;
1105
GladeWidgetAdaptor *adaptor =
1106
glade_widget_adaptor_get_by_type (new_type);
1107
GList *saved_props, *prop_cmds;
1108
GladeWidget *gnew_parent;
1110
/* Dont add non-scrollable widgets to scrolled windows... */
1112
glade_util_check_and_warn_scrollable (gparent, adaptor,
1113
glade_app_get_window ()))
1116
glade_command_push_group (_("Adding parent %s for %s"),
1118
glade_widget_get_name (gwidget));
1120
/* Record packing properties */
1122
glade_widget_dup_properties (gwidget, gwidget->packing_properties,
1123
FALSE, FALSE, FALSE);
1126
property = glade_widget_get_parentless_widget_ref (gwidget);
1128
/* Remove "this" widget, If the parent we're removing is a parentless
1129
* widget reference, the reference will be implicitly broken by the 'cut' command */
1130
this_widget.data = gwidget;
1131
glade_command_delete (&this_widget);
1133
/* Create new widget and put it where the placeholder was */
1135
glade_command_create (adaptor, gparent, NULL, project)) != NULL)
1137
/* Now we created the new parent, if gwidget had a parentless widget reference...
1138
* set that reference to the new parent instead */
1140
glade_command_set_property (property, glade_widget_get_object (gnew_parent));
1142
/* Remove the alignment that we added in the frame's post_create... */
1143
if (new_type == GTK_TYPE_FRAME)
1145
GObject *frame = glade_widget_get_object (gnew_parent);
1146
GladeWidget *galign =
1147
glade_widget_get_from_gobject (gtk_bin_get_child (GTK_BIN (frame)));
1148
GList to_delete = { 0, };
1150
to_delete.data = galign;
1151
glade_command_delete (&to_delete);
1154
/* Create heavy-duty glade-command properties stuff */
1156
create_command_property_list (gnew_parent, saved_props);
1157
g_list_foreach (saved_props, (GFunc) g_object_unref, NULL);
1158
g_list_free (saved_props);
1160
/* Apply the properties in an undoable way */
1162
glade_command_set_properties_list
1163
(glade_widget_get_project (gparent), prop_cmds);
1165
/* Add "this" widget to the new parent */
1166
glade_command_add (&this_widget, gnew_parent, NULL, project, FALSE);
1170
/* Create parent was cancelled, paste back to parent */
1171
glade_command_add (&this_widget, gparent, NULL, project, FALSE);
1173
/* Restore any parentless widget reference if there was one */
1175
glade_command_set_property (property, glade_widget_get_object (gwidget));
1178
glade_command_pop_group ();
1181
else if (strcmp (action_path, "sizegroup_add") == 0)
1186
GWA_GET_CLASS (G_TYPE_OBJECT)->action_activate (adaptor,
1187
object, action_path);
1169
static GList *list_sizegroups (GladeWidget *gwidget)
1191
list_sizegroups (GladeWidget *gwidget)
1171
1193
GladeProject *project = glade_widget_get_project (gwidget);
1172
1194
GList *groups = NULL;
2762
#define TABLE_OCCUPIED(occmap, n_columns, col, row) \
2763
(occmap)[row * n_columns + col]
2766
glade_gtk_table_build_occupation_maps(GtkTable *table, guint n_columns, guint n_rows,
2767
gchar **child_map, gpointer **placeholder_map)
2770
GList *list, *children = gtk_container_get_children (GTK_CONTAINER (table));
2772
*child_map = g_malloc0(n_columns * n_rows * sizeof(gchar)); /* gchar is smaller than gboolean */
2773
*placeholder_map = g_malloc0(n_columns * n_rows * sizeof(gpointer));
2775
for (list = children; list && list->data; list = list->next)
2777
GtkTableChild child;
2779
glade_gtk_table_get_child_attachments (GTK_WIDGET (table),
2780
GTK_WIDGET (list->data), &child);
2782
if (GLADE_IS_PLACEHOLDER(list->data))
2784
/* assumption: placeholders are always attached to exactly 1 cell */
2785
TABLE_OCCUPIED(*placeholder_map, n_columns, child.left_attach, child.top_attach) = list->data;
2789
for (i = child.left_attach; i < child.right_attach && i < n_columns; i++)
2791
for (j = child.top_attach; j < child.bottom_attach && j < n_rows; j++)
2793
TABLE_OCCUPIED(*child_map, n_columns, i, j) = 1;
2798
g_list_free (children);
2741
2802
glade_gtk_table_refresh_placeholders (GtkTable *table)
2743
GList *list, *children;
2744
guint n_columns, n_rows;
2804
guint n_columns, n_rows, i, j;
2806
gpointer *placeholder_map;
2747
2808
g_object_get (table,
2748
2809
"n-columns", &n_columns,
2749
2810
"n-rows", &n_rows,
2752
children = gtk_container_get_children (GTK_CONTAINER (table));
2754
for (list = children; list && list->data; list = list->next)
2756
if (GLADE_IS_PLACEHOLDER (list->data))
2757
gtk_container_remove (GTK_CONTAINER (table),
2758
GTK_WIDGET (list->data));
2760
g_list_free (children);
2813
glade_gtk_table_build_occupation_maps(table, n_columns, n_rows,
2814
&child_map, &placeholder_map);
2762
2816
for (i = 0; i < n_columns; i++)
2763
for (j = 0; j < n_rows; j++)
2764
if (glade_gtk_table_has_child (table, i, j) == FALSE)
2766
gtk_table_attach_defaults (table,
2767
glade_placeholder_new (),
2768
i, i + 1, j, j + 1);
2818
for (j = 0; j < n_rows; j++)
2820
gpointer placeholder = TABLE_OCCUPIED(placeholder_map, n_columns, i, j);
2822
if (TABLE_OCCUPIED(child_map, n_columns, i, j))
2826
gtk_container_remove (GTK_CONTAINER (table),
2827
GTK_WIDGET (placeholder));
2834
gtk_table_attach_defaults (table,
2835
glade_placeholder_new (),
2836
i, i + 1, j, j + 1);
2842
g_free(placeholder_map);
2770
2843
gtk_container_check_resize (GTK_CONTAINER (table));
5952
6014
const GValue *value)
5954
6016
GladeWidget *gwidget = glade_widget_get_from_gobject (object);
6017
gboolean sensitivity;
5956
6020
if (!strcmp (id, "related-action"))
5958
GtkAction *action = g_value_get_object (value);
5962
glade_widget_property_set_sensitive (gwidget, "visible", FALSE, ACTION_APPEARANCE_MSG);
5963
glade_widget_property_set_sensitive (gwidget, "sensitive", FALSE, ACTION_APPEARANCE_MSG);
5965
glade_widget_property_set_sensitive (gwidget, "accel-group", FALSE, ACTION_APPEARANCE_MSG);
5967
glade_widget_property_set_sensitive (gwidget, "visible", TRUE, NULL);
5968
glade_widget_property_set_sensitive (gwidget, "sensitive", TRUE, NULL);
5970
glade_widget_property_set_sensitive (gwidget, "accel-group", TRUE, NULL);
6022
GtkAction *action = g_value_get_object (value);
6026
sensitivity = FALSE;
6027
msg = ACTION_APPEARANCE_MSG;
6035
glade_widget_property_set_sensitive (gwidget, "visible", sensitivity, msg);
6036
glade_widget_property_set_sensitive (gwidget, "sensitive", sensitivity, msg);
6037
glade_widget_property_set_sensitive (gwidget, "accel-group", sensitivity, msg);
6038
glade_widget_property_set_sensitive (gwidget, "use-action-appearance", !sensitivity, sensitivity ? msg : NULL);
5974
6040
else if (!strcmp (id, "use-action-appearance"))
5976
gboolean use_appearance = g_value_get_boolean (value);
6042
if (g_value_get_boolean (value))
6044
sensitivity = FALSE;
6045
msg = ACTION_APPEARANCE_MSG;
5981
glade_widget_property_set_sensitive (gwidget, "label", FALSE, ACTION_APPEARANCE_MSG);
5982
glade_widget_property_set_sensitive (gwidget, "use-underline", FALSE, ACTION_APPEARANCE_MSG);
5983
glade_widget_property_set_sensitive (gwidget, "stock", FALSE, ACTION_APPEARANCE_MSG);
5984
//glade_widget_property_set_sensitive (gwidget, "use-stock", FALSE, ACTION_APPEARANCE_MSG);
5985
glade_widget_property_set_sensitive (gwidget, "image", FALSE, ACTION_APPEARANCE_MSG);
5986
glade_widget_property_set_sensitive (gwidget, "custom-child", FALSE, ACTION_APPEARANCE_MSG);
5987
glade_widget_property_set_sensitive (gwidget, "stock-id", FALSE, ACTION_APPEARANCE_MSG);
5988
glade_widget_property_set_sensitive (gwidget, "label-widget", FALSE, ACTION_APPEARANCE_MSG);
5989
glade_widget_property_set_sensitive (gwidget, "icon-name", FALSE, ACTION_APPEARANCE_MSG);
5990
glade_widget_property_set_sensitive (gwidget, "icon-widget", FALSE, ACTION_APPEARANCE_MSG);
5991
glade_widget_property_set_sensitive (gwidget, "icon", FALSE, ACTION_APPEARANCE_MSG);
5993
glade_widget_property_set_sensitive (gwidget, "label", TRUE, NULL);
5994
glade_widget_property_set_sensitive (gwidget, "use-underline", TRUE, NULL);
5995
glade_widget_property_set_sensitive (gwidget, "stock", TRUE, NULL);
5996
//glade_widget_property_set_sensitive (gwidget, "use-stock", TRUE, NULL);
5997
glade_widget_property_set_sensitive (gwidget, "image", TRUE, NULL);
5998
glade_widget_property_set_sensitive (gwidget, "custom-child", TRUE, NULL);
5999
glade_widget_property_set_sensitive (gwidget, "stock-id", TRUE, NULL);
6000
glade_widget_property_set_sensitive (gwidget, "label-widget", TRUE, NULL);
6001
glade_widget_property_set_sensitive (gwidget, "icon-name", TRUE, NULL);
6002
glade_widget_property_set_sensitive (gwidget, "icon-widget", TRUE, NULL);
6003
glade_widget_property_set_sensitive (gwidget, "icon", TRUE, NULL);
6053
glade_widget_property_set_sensitive (gwidget, "label", sensitivity, msg);
6054
glade_widget_property_set_sensitive (gwidget, "use-underline", sensitivity, msg);
6055
glade_widget_property_set_sensitive (gwidget, "stock", sensitivity, msg);
6056
//glade_widget_property_set_sensitive (gwidget, "use-stock", sensitivity, msg);
6057
glade_widget_property_set_sensitive (gwidget, "image", sensitivity, msg);
6058
glade_widget_property_set_sensitive (gwidget, "custom-child", sensitivity, msg);
6059
glade_widget_property_set_sensitive (gwidget, "stock-id", sensitivity, msg);
6060
glade_widget_property_set_sensitive (gwidget, "label-widget", sensitivity, msg);
6061
glade_widget_property_set_sensitive (gwidget, "icon-name", sensitivity, msg);
6062
glade_widget_property_set_sensitive (gwidget, "icon-widget", sensitivity, msg);
6063
glade_widget_property_set_sensitive (gwidget, "icon", sensitivity, msg);
6008
6067
/* ----------------------------- GtkButton ------------------------------ */