diff options
author | Thomas White <taw@bitwiz.me.uk> | 2018-10-29 08:45:10 +0100 |
---|---|---|
committer | Thomas White <taw@bitwiz.me.uk> | 2018-10-29 08:45:10 +0100 |
commit | 36e9ae723b3caebaa7e58f58438913b174d57573 (patch) | |
tree | 4d458316091c79bd58434cbfe467407da39b8058 | |
parent | 8e05062ad3b94068825a1f80eb362aa3d3e9098f (diff) |
Switch to "fancy" save window
-rw-r--r-- | data/colloquium.gresource.xml | 1 | ||||
-rw-r--r-- | data/savepresentation.ui | 140 | ||||
-rw-r--r-- | src/narrative_window.c | 41 |
3 files changed, 167 insertions, 15 deletions
diff --git a/data/colloquium.gresource.xml b/data/colloquium.gresource.xml index 819a966..307a437 100644 --- a/data/colloquium.gresource.xml +++ b/data/colloquium.gresource.xml @@ -4,6 +4,7 @@ <file>sky.png</file> <file>menus.ui</file> <file>stylesheeteditor.ui</file> + <file>savepresentation.ui</file> <file>demo.sc</file> <file>demo.ss</file> <file>default.ss</file> diff --git a/data/savepresentation.ui b/data/savepresentation.ui new file mode 100644 index 0000000..5597377 --- /dev/null +++ b/data/savepresentation.ui @@ -0,0 +1,140 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.20.4 --> +<interface> + <requires lib="gtk+" version="3.20"/> + <object class="GtkDialog" id="savepresentation"> + <property name="can_focus">False</property> + <property name="destroy_with_parent">True</property> + <property name="type_hint">dialog</property> + <signal name="response" handler="saveas_response_sig" swapped="no"/> + <child internal-child="vbox"> + <object class="GtkBox"> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">2</property> + <child internal-child="action_area"> + <object class="GtkButtonBox"> + <property name="can_focus">False</property> + <property name="layout_style">end</property> + <child> + <object class="GtkButton" id="button2"> + <property name="label">gtk-cancel</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="button1"> + <property name="label">gtk-save</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">8</property> + <child> + <object class="GtkFileChooserWidget" id="filechooser"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="action">save</property> + <property name="do_overwrite_confirmation">True</property> + <property name="local_only">False</property> + <property name="preview_widget_active">False</property> + <property name="use_preview_label">False</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="radiobutton1"> + <property name="label" translatable="yes">Create/update private stylesheet for this presentation</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkRadioButton"> + <property name="label" translatable="yes">Create/update default stylesheet for presentations in folder</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <property name="group">radiobutton1</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkRadioButton"> + <property name="label" translatable="yes">Don't save stylesheet at all</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <property name="group">radiobutton1</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">3</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + <action-widgets> + <action-widget response="2">button2</action-widget> + <action-widget response="1">button1</action-widget> + </action-widgets> + <child> + <placeholder/> + </child> + </object> +</interface> diff --git a/src/narrative_window.c b/src/narrative_window.c index b287f61..123535d 100644 --- a/src/narrative_window.c +++ b/src/narrative_window.c @@ -99,15 +99,22 @@ static void update_toolbar(NarrativeWindow *nw) } +struct saveas_info +{ + NarrativeWindow *nw; + GtkWidget *filechooser; +}; + + static gint saveas_response_sig(GtkWidget *d, gint response, - NarrativeWindow *nw) + struct saveas_info *si) { - if ( response == GTK_RESPONSE_ACCEPT ) { + if ( response == 1 ) { /* hard-coded number in Glade file */ - GFile *file = gtk_file_chooser_get_file(GTK_FILE_CHOOSER(d)); + GFile *file = gtk_file_chooser_get_file(GTK_FILE_CHOOSER(si->filechooser)); - if ( save_presentation(nw->p, file) ) { - show_error(nw, _("Failed to save presentation")); + if ( save_presentation(si->nw->p, file) ) { + show_error(si->nw, _("Failed to save presentation")); } g_object_unref(file); @@ -115,6 +122,7 @@ static gint saveas_response_sig(GtkWidget *d, gint response, } gtk_widget_destroy(d); + free(si); return 0; } @@ -123,19 +131,22 @@ static gint saveas_response_sig(GtkWidget *d, gint response, static void saveas_sig(GSimpleAction *action, GVariant *parameter, gpointer vp) { GtkWidget *d; + GtkBuilder *builder; NarrativeWindow *nw = vp; + struct saveas_info *si; - d = gtk_file_chooser_dialog_new(_("Save Presentation"), - GTK_WINDOW(nw->window), - GTK_FILE_CHOOSER_ACTION_SAVE, - _("_Cancel"), GTK_RESPONSE_CANCEL, - _("_Save"), GTK_RESPONSE_ACCEPT, - NULL); - gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(d), - TRUE); + si = malloc(sizeof(struct saveas_info)); + if ( si == NULL ) return; - g_signal_connect(G_OBJECT(d), "response", - G_CALLBACK(saveas_response_sig), nw); + si->nw = nw; + + builder = gtk_builder_new_from_resource("/uk/me/bitwiz/Colloquium/savepresentation.ui"); + gtk_builder_add_callback_symbol(builder, "saveas_response_sig", + G_CALLBACK(saveas_response_sig)); + gtk_builder_connect_signals(builder, si); + d = GTK_WIDGET(gtk_builder_get_object(builder, "savepresentation")); + si->filechooser = GTK_WIDGET(gtk_builder_get_object(builder, "filechooser")); + gtk_window_set_transient_for(GTK_WINDOW(d), GTK_WINDOW(nw->window)); gtk_widget_show_all(d); } |