static void
node_editor_application_startup (GApplication *app)
{
- const gchar *quit_accels[2] = { "<Ctrl>Q", NULL };
+ const char *quit_accels[2] = { "<Ctrl>Q", NULL };
+ const char *open_accels[2] = { "<Ctrl>O", NULL };
G_APPLICATION_CLASS (node_editor_application_parent_class)->startup (app);
g_action_map_add_action_entries (G_ACTION_MAP (app),
app_entries, G_N_ELEMENTS (app_entries),
app);
- gtk_application_set_accels_for_action (GTK_APPLICATION (app),
- "app.quit",
- quit_accels);
+ gtk_application_set_accels_for_action (GTK_APPLICATION (app), "app.quit", quit_accels);
+ gtk_application_set_accels_for_action (GTK_APPLICATION (app), "win.open", open_accels);
}
static void
g_bytes_get_data (bytes, NULL),
g_bytes_get_size (bytes));
+ g_bytes_unref (bytes);
+
return TRUE;
}
}
static void
-open_cb (GtkWidget *button,
- NodeEditorWindow *self)
+show_open_filechooser (NodeEditorWindow *self)
{
GtkWidget *dialog;
dialog = gtk_file_chooser_dialog_new ("Open node file",
- GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (button))),
+ GTK_WINDOW (self),
GTK_FILE_CHOOSER_ACTION_OPEN,
"_Cancel", GTK_RESPONSE_CANCEL,
"_Load", GTK_RESPONSE_ACCEPT,
gtk_widget_show (dialog);
}
+static void
+open_cb (GtkWidget *button,
+ NodeEditorWindow *self)
+{
+ show_open_filechooser (self);
+}
+
static void
save_response_cb (GtkWidget *dialog,
gint response,
{
GdkPaintable *paintable = item;
GtkWidget *box, *label, *picture;
+ GtkWidget *row;
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_set_size_request (box, 120, 90);
picture = gtk_picture_new_for_paintable (paintable);
gtk_container_add (GTK_CONTAINER (box), picture);
- return box;
+ row = gtk_list_box_row_new ();
+ gtk_container_add (GTK_CONTAINER (row), box);
+ gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (row), FALSE);
+
+ return row;
+}
+
+static void
+window_open (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ NodeEditorWindow *self = user_data;
+
+ show_open_filechooser (self);
}
+static GActionEntry win_entries[] = {
+ { "open", window_open, NULL, NULL, NULL },
+};
+
static void
node_editor_window_init (NodeEditorWindow *self)
{
self->errors = g_array_new (FALSE, TRUE, sizeof (TextViewError));
g_array_set_clear_func (self->errors, (GDestroyNotify)text_view_error_free);
+
+ g_action_map_add_action_entries (G_ACTION_MAP (self), win_entries, G_N_ELEMENTS (win_entries), self);
}
NodeEditorWindow *