Commit 3e3f9de40a382614f0432808fa955c3ee1a88a25
- Diff rendering mode:
- inline
- side by side
gladeui/glade-settings-editor.c
(26 / 22)
|   | |||
| 40 | 40 | ||
| 41 | 41 | static void | |
| 42 | 42 | add_property (GladeSettingsEditor *self, | |
| 43 | GladeProperty *property) | ||
| 43 | GladeProperty *property, | ||
| 44 | GtkTreeIter *iter) | ||
| 44 | 45 | { | |
| 45 | GtkTreeIter iter; | ||
| 46 | GtkTreeIter temp_iter; | ||
| 47 | if (iter == NULL) | ||
| 48 | iter = &temp_iter; | ||
| 49 | |||
| 46 | 50 | GladePropertyClass *property_class = property->klass;; | |
| 47 | 51 | ||
| 48 | gtk_list_store_append (GTK_LIST_STORE (self->data), &iter); | ||
| 52 | gtk_list_store_append (GTK_LIST_STORE (self->data), iter); | ||
| 49 | 53 | ||
| 50 | gtk_list_store_set (GTK_LIST_STORE (self->data), &iter, | ||
| 54 | gtk_list_store_set (GTK_LIST_STORE (self->data), iter, | ||
| 51 | 55 | GLADE_SETTINGS_EDITOR_COLUMN_PROPERTY, property, | |
| 52 | 56 | GLADE_SETTINGS_EDITOR_COLUMN_PROPERTY_NAME, property_class->name, | |
| 53 | 57 | GLADE_SETTINGS_EDITOR_COLUMN_KEY_NAME, KEY_DEFAULT, | |
| … | … | ||
| 103 | 103 | ||
| 104 | 104 | if (property->key != NULL) | |
| 105 | 105 | { | |
| 106 | add_property (self, property); | ||
| 106 | add_property (self, property, NULL); | ||
| 107 | 107 | if (first_property == NULL) | |
| 108 | 108 | first_property = property; | |
| 109 | 109 | } | |
| … | … | ||
| 161 | 161 | glade_settings_editor_set_property (GladeSettingsEditor *self, | |
| 162 | 162 | GladeProperty *property) | |
| 163 | 163 | { | |
| 164 | gboolean found = FALSE; | ||
| 165 | GtkTreeIter iter; | ||
| 166 | GtkTreeSelection *tree_selection; | ||
| 167 | |||
| 164 | 168 | if (property == self->property) | |
| 165 | 169 | return; | |
| 166 | 170 | ||
| … | … | ||
| 180 | 180 | ||
| 181 | 181 | if (property->widget != self->widget) | |
| 182 | 182 | set_widget (self, property->widget, property); | |
| 183 | |||
| 184 | if (property->key != NULL) | ||
| 185 | { | ||
| 186 | // FIXME: look for property in list & select it | ||
| 187 | GtkTreeIter iter; | ||
| 188 | gboolean found; | ||
| 189 | |||
| 190 | found = find_property (self, property, &iter); | ||
| 191 | g_warn_if_fail (found); | ||
| 192 | } | ||
| 193 | 183 | else | |
| 194 | add_property (self, property); | ||
| 184 | /* Same widget - maybe the property is already in the window. */ | ||
| 185 | found = find_property (self, property, &iter); | ||
| 186 | |||
| 187 | if (!found) | ||
| 188 | add_property (self, property, &iter); | ||
| 189 | |||
| 190 | tree_selection = gtk_tree_view_get_selection (self->view); | ||
| 191 | gtk_tree_selection_select_iter (tree_selection, &iter); | ||
| 195 | 192 | ||
| 196 | 193 | self->property = property; | |
| 197 | 194 | self->property_notify_id = g_signal_connect (property, "notify::settings-key", | |
| … | … | ||
| 251 | 251 | { | |
| 252 | 252 | GladeSettingsEditor *self; | |
| 253 | 253 | GObject *retval; | |
| 254 | GtkWidget *tree_view; | ||
| 255 | 254 | GtkCellRenderer *cell_renderer; | |
| 256 | 255 | GtkTreeViewColumn *column; | |
| 257 | 256 | ||
| … | … | ||
| 266 | 266 | GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
| 267 | 267 | NULL); | |
| 268 | 268 | ||
| 269 | tree_view = gtk_tree_view_new_with_model (self->data); | ||
| 270 | gtk_widget_set_size_request (tree_view, 200, 200); | ||
| 269 | self->view = gtk_tree_view_new_with_model (self->data); | ||
| 270 | gtk_widget_set_size_request (self->view, 200, 200); | ||
| 271 | 271 | ||
| 272 | 272 | cell_renderer = gtk_cell_renderer_text_new (); | |
| 273 | 273 | column = gtk_tree_view_column_new_with_attributes | |
| 274 | 274 | (_("Property Name"), cell_renderer, | |
| 275 | 275 | "text", GLADE_SETTINGS_EDITOR_COLUMN_PROPERTY_NAME, | |
| 276 | 276 | NULL); | |
| 277 | gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); | ||
| 277 | gtk_tree_view_append_column (GTK_TREE_VIEW (self->view), column); | ||
| 278 | 278 | ||
| 279 | 279 | cell_renderer = gtk_cell_renderer_text_new (); | |
| 280 | 280 | g_object_set (cell_renderer, "editable", TRUE, NULL); | |
| … | … | ||
| 282 | 282 | (_("Settings Key"), cell_renderer, | |
| 283 | 283 | "text", GLADE_SETTINGS_EDITOR_COLUMN_KEY_NAME, | |
| 284 | 284 | NULL); | |
| 285 | gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); | ||
| 285 | gtk_tree_view_append_column (GTK_TREE_VIEW (self->view), column); | ||
| 286 | 286 | ||
| 287 | 287 | g_signal_connect (cell_renderer, "edited", G_CALLBACK (key_edited), self); | |
| 288 | 288 | ||
| 289 | 289 | ||
| 290 | 290 | gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (self->dialog))), | |
| 291 | tree_view); | ||
| 291 | self->view); | ||
| 292 | 292 | ||
| 293 | 293 | g_signal_connect (self->dialog, "response", G_CALLBACK (dialog_response), NULL); | |
| 294 | 294 |
|   | |||
| 35 | 35 | GladeProperty *property; /* Currently selected property */ | |
| 36 | 36 | int property_notify_id; /* Signal handler connected to notify::settings-key */ | |
| 37 | 37 | ||
| 38 | GtkWidget *dialog; | ||
| 38 | GtkWidget *dialog, *view; | ||
| 39 | 39 | GtkTreeModel *data; | |
| 40 | 40 | }; | |
| 41 | 41 |

