Commit abef5b8e2f540de56c7258fa142e1161bbef39c3
- Diff rendering mode:
- inline
- side by side
gladeui/glade-property.c
(1 / 0)
|   | |||
| 1520 | 1520 | g_free (property->key); | |
| 1521 | 1521 | ||
| 1522 | 1522 | property->key = g_strdup (key); | |
| 1523 | g_object_notify (property, "settings-key"); | ||
| 1523 | 1524 | }; | |
| 1524 | 1525 | ||
| 1525 | 1526 | const gchar * |
gladeui/glade-settings-editor.c
(94 / 28)
|   | |||
| 51 | 51 | add_property (GladeSettingsEditor *self, | |
| 52 | 52 | GladeProperty *property) | |
| 53 | 53 | { | |
| 54 | GtkTreeIter iter; | ||
| 55 | GladePropertyClass *property_class = property->klass;; | ||
| 56 | |||
| 54 | 57 | gtk_list_store_append (GTK_LIST_STORE (self->data), &iter); | |
| 55 | 58 | ||
| 56 | 59 | // FIXME: set tooltip as klass->name | |
| … | … | ||
| 64 | 64 | -1); | |
| 65 | 65 | }; | |
| 66 | 66 | ||
| 67 | void | ||
| 68 | glade_settings_editor_show (GladeSettingsEditor *self, | ||
| 69 | GladeWidget *widget, | ||
| 70 | GladeProperty *property) | ||
| 67 | static gboolean | ||
| 68 | find_property (GladeSettingsEditor *self, | ||
| 69 | GladeProperty *property, | ||
| 70 | GtkTreeIter *iter) | ||
| 71 | 71 | { | |
| 72 | glade_settings_editor_set_widget (self, widget); | ||
| 73 | glade_settings_editor_set_property (self, property); | ||
| 72 | gboolean result; | ||
| 74 | 73 | ||
| 75 | gtk_widget_show_all (self->dialog); | ||
| 76 | }; | ||
| 74 | result = gtk_tree_model_get_iter_first (self->data, iter); | ||
| 75 | while (result) | ||
| 76 | { | ||
| 77 | GladeProperty *found_property; | ||
| 78 | gtk_tree_model_get (self->data, iter, | ||
| 79 | GLADE_SETTINGS_EDITOR_COLUMN_PROPERTY, &found_property, | ||
| 80 | -1); | ||
| 77 | 81 | ||
| 78 | void | ||
| 79 | glade_settings_editor_set_widget (GladeSettingsEditor *self, | ||
| 80 | GladeWidget *widget) | ||
| 82 | if (found_property == property) | ||
| 83 | return TRUE; | ||
| 84 | |||
| 85 | result = gtk_tree_model_iter_next (self->data, iter); | ||
| 86 | } | ||
| 87 | return FALSE; | ||
| 88 | } | ||
| 89 | |||
| 90 | static void | ||
| 91 | set_widget (GladeSettingsEditor *self, | ||
| 92 | GladeWidget *widget, | ||
| 93 | GladeProperty *initial_property) | ||
| 81 | 94 | { | |
| 82 | 95 | GList *node; | |
| 96 | GladeProperty *first_property = NULL; | ||
| 83 | 97 | ||
| 84 | 98 | if (widget == self->widget) | |
| 85 | 99 | return; | |
| … | … | ||
| 106 | 106 | for (node=widget->properties; node; node=node->next) { | |
| 107 | 107 | GladeProperty *property = GLADE_PROPERTY (node->data); | |
| 108 | 108 | ||
| 109 | if (node->key != NULL) { | ||
| 110 | |||
| 111 | |||
| 112 | }; | ||
| 109 | if (first_property == NULL) | ||
| 110 | first_property = property; | ||
| 111 | |||
| 112 | if (property->key != NULL) | ||
| 113 | add_property (self, property); | ||
| 113 | 114 | }; | |
| 114 | 115 | ||
| 115 | 116 | self->widget = widget; | |
| 117 | if (initial_property == NULL) | ||
| 118 | { | ||
| 119 | /* If this isn't from a glade_settings_editor_set_property call, set first property | ||
| 120 | * as active (and disconnect old property) */ | ||
| 121 | glade_settings_editor_set_property (self, first_property); | ||
| 122 | } | ||
| 116 | 123 | }; | |
| 117 | 124 | ||
| 118 | void | ||
| 119 | glade_settings_editor_set_property (GladeSettingsEditor *self, | ||
| 120 | GladeProperty *property) | ||
| 125 | static void | ||
| 126 | property_settings_key_notify (GladeProperty *property, | ||
| 127 | GParamSpec *pspec, | ||
| 128 | GladeSettingsEditor *self) | ||
| 121 | 129 | { | |
| 122 | GladePropertyClass *property_class = property->klass;; | ||
| 123 | 130 | GtkTreeIter iter; | |
| 131 | gboolean found; | ||
| 132 | const char *key_name; | ||
| 124 | 133 | ||
| 125 | }; | ||
| 126 | }; | ||
| 134 | found = find_property (self, property, &iter); | ||
| 135 | g_return_if_fail (found); | ||
| 127 | 136 | ||
| 128 | self->widget = widget; | ||
| 137 | if (property->key == NULL) | ||
| 138 | key_name = KEY_DEFAULT; | ||
| 139 | else key_name = property->key; | ||
| 140 | |||
| 141 | gtk_list_store_set (GTK_LIST_STORE (self->data), &iter, | ||
| 142 | GLADE_SETTINGS_EDITOR_COLUMN_KEY_NAME, key_name, | ||
| 143 | -1); | ||
| 129 | 144 | }; | |
| 130 | 145 | ||
| 131 | 146 | void | |
| 147 | glade_settings_editor_show (GladeSettingsEditor *self, | ||
| 148 | GladeWidget *widget, | ||
| 149 | GladeProperty *property) | ||
| 150 | { | ||
| 151 | glade_settings_editor_set_widget (self, widget); | ||
| 152 | glade_settings_editor_set_property (self, property); | ||
| 153 | |||
| 154 | gtk_widget_show_all (self->dialog); | ||
| 155 | }; | ||
| 156 | |||
| 157 | void | ||
| 158 | glade_settings_editor_set_widget (GladeSettingsEditor *self, | ||
| 159 | GladeWidget *widget) | ||
| 160 | { | ||
| 161 | set_widget (self, widget, NULL); | ||
| 162 | }; | ||
| 163 | |||
| 164 | void | ||
| 132 | 165 | glade_settings_editor_set_property (GladeSettingsEditor *self, | |
| 133 | 166 | GladeProperty *property) | |
| 134 | 167 | { | |
| 135 | GladePropertyClass *property_class = property->klass;; | ||
| 136 | GtkTreeIter iter; | ||
| 137 | |||
| 138 | 168 | if (property == self->property) | |
| 139 | 169 | return; | |
| 140 | 170 | ||
| 171 | if (self->property_notify_id != 0) | ||
| 172 | g_signal_handler_disconnect (property, self->property_notify_id); | ||
| 173 | |||
| 141 | 174 | if (property->widget != self->widget) | |
| 142 | glade_settings_editor_set_widget (self, property->widget); | ||
| 175 | set_widget (self, property->widget, property); | ||
| 143 | 176 | ||
| 144 | // FIXME: look for property in list | ||
| 145 | add_property (self, property); | ||
| 177 | if (property->key != NULL) | ||
| 178 | { | ||
| 179 | // FIXME: look for property in list & select it | ||
| 180 | GtkTreeIter iter; | ||
| 181 | gboolean found; | ||
| 182 | |||
| 183 | found = find_property (self, property, &iter); | ||
| 184 | g_warn_if_fail (found); | ||
| 185 | } | ||
| 186 | else | ||
| 187 | add_property (self, property); | ||
| 188 | |||
| 189 | self->property = property; | ||
| 190 | self->property_notify_id = g_signal_connect (property, "notify::settings-key", | ||
| 191 | G_CALLBACK (property_settings_key_notify), | ||
| 192 | self); | ||
| 146 | 193 | }; | |
| 147 | 194 | ||
| 148 | 195 | static void | |
| … | … | ||
| 320 | 320 | glade_settings_editor_init (GladeSettingsEditor *self) | |
| 321 | 321 | { | |
| 322 | 322 | self->widget = NULL; | |
| 323 | self->property = NULL; | ||
| 324 | self->property_notify_id = 0; | ||
| 323 | 325 | }; | |
| 324 | 326 | ||
| 325 | 327 | static void |
|   | |||
| 31 | 31 | { | |
| 32 | 32 | GtkObject parent; | |
| 33 | 33 | ||
| 34 | GladeWidget *widget; /* Widget currently having its properties bound */ | ||
| 34 | GladeWidget *widget; /* Widget currently having its properties bound */ | ||
| 35 | GladeProperty *property; /* Currently selected property */ | ||
| 36 | int property_notify_id; /* Signal handler connected to notify::settings-key */ | ||
| 35 | 37 | ||
| 36 | 38 | GtkWidget *dialog; | |
| 37 | 39 | GtkTreeModel *data; |

