Commit 98e5f53e authored by Jens Georg's avatar Jens Georg

publishing: Separate UI files and code

parent 1f8fd2cf
......@@ -24,7 +24,9 @@
<file preprocess="xml-stripblanks">ui/search_sidebar_context.ui</file>
<file preprocess="xml-stripblanks">ui/set_background_dialog.ui</file>
<file preprocess="xml-stripblanks">ui/set_background_slideshow_dialog.ui</file>
<file compressed="true">ui/shotwell.ui</file>
<file preprocess="xml-stripblanks">ui/login_welcome_pane_widget.ui</file>
<file preprocess="xml-stripblanks">ui/progress_pane_widget.ui</file>
<file preprocess="xml-stripblanks">ui/static_message_pane_widget.ui</file>
<file preprocess="xml-stripblanks">ui/sidebar_default_context.ui</file>
<file preprocess="xml-stripblanks">ui/slideshow_settings.ui</file>
<file preprocess="xml-stripblanks">ui/saved_search_dialog.ui</file>
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<!-- Generated with glade 3.22.0 -->
<interface domain="shotwell">
<requires lib="gtk+" version="3.18"/>
<object class="GtkBox" id="progress_pane_widget">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkProgressBar" id="publishing_progress_bar">
<property name="height_request">64</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">32</property>
<property name="margin_right">32</property>
<property name="margin_top">108</property>
<property name="show_text">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">32</property>
<property name="position">1</property>
</packing>
</child>
</object>
<object class="GtkBox" id="static_msg_pane_widget">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="static_msg_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">16</property>
<property name="margin_right">16</property>
<property name="margin_top">97</property>
<property name="margin_bottom">24</property>
<property name="label" comments="This is a placeholder string and may be ignored.">This is populated from within the code;
changes made here will not display.</property>
<property name="wrap">True</property>
<property name="max_width_chars">70</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<object class="GtkBox" id="welcome_pane_widget">
<template class="PublishingUILoginWelcomePane" parent="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
......@@ -56,8 +10,8 @@ changes made here will not display.</property>
<object class="GtkLabel" id="not_logged_in_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">16</property>
<property name="margin_right">16</property>
<property name="margin_start">16</property>
<property name="margin_end">16</property>
<property name="margin_top">97</property>
<property name="margin_bottom">24</property>
<property name="label" comments="This is a placeholder string and may be ignored.">This is populated from within the code;
......@@ -77,8 +31,8 @@ changes made here will not display.</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="margin_left">256</property>
<property name="margin_right">240</property>
<property name="margin_start">256</property>
<property name="margin_end">240</property>
<property name="margin_top">80</property>
<property name="margin_bottom">16</property>
<property name="use_underline">True</property>
......@@ -90,5 +44,5 @@ changes made here will not display.</property>
<property name="position">1</property>
</packing>
</child>
</object>
</template>
</interface>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.0 -->
<interface>
<requires lib="gtk+" version="3.22"/>
<template class="PublishingUIProgressPane" parent="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkProgressBar" id="progress_bar">
<property name="height_request">64</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_start">32</property>
<property name="margin_end">32</property>
<property name="margin_top">108</property>
<property name="show_text">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">32</property>
<property name="position">1</property>
</packing>
</child>
</template>
</interface>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.0 -->
<interface>
<requires lib="gtk+" version="3.22"/>
<template class="PublishingUIStaticMessagePane" parent="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="static_msg_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_start">16</property>
<property name="margin_end">16</property>
<property name="margin_top">97</property>
<property name="margin_bottom">24</property>
<property name="label" comments="This is a placeholder string and may be ignored.">This is populated from within the code;
changes made here will not display.</property>
<property name="wrap">True</property>
<property name="max_width_chars">70</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</template>
</interface>
......@@ -474,19 +474,6 @@ public abstract class AppWindow : PageWindow {
return fullscreen_window;
}
public static Gtk.Builder create_builder(string glade_filename = "shotwell.ui", void *user = null) {
Gtk.Builder builder = new Gtk.Builder();
try {
builder.add_from_resource(Resources.get_ui(glade_filename));
} catch(GLib.Error error) {
warning("Unable to create Gtk.Builder: %s\n", error.message);
}
builder.connect_signals(user);
return builder;
}
public static void error_message(string message, Gtk.Window? parent = null) {
error_message_with_title(Resources.APP_TITLE, message, parent);
}
......
......@@ -36,6 +36,9 @@ shotwell_deps = [gio, gee, sqlite, gtk, sqlite, posix, gphoto2,
if unity_available
shotwell_deps += [unity]
endif
subdir('publishing')
executable('shotwell',
['unit/Unit.vala',
'util/Util.vala',
......@@ -241,7 +244,10 @@ executable('shotwell',
'.unitize/_Library_unitize_entry.vala',
'.unitize/_Direct_unitize_entry.vala'] + shotwell_resources + face_sources,
include_directories : vapi_incdir,
dependencies : shotwell_deps,
dependencies : [
shotwell_deps,
sw_publishing_gui
],
vala_args : ['--pkg', 'libgphoto2',
'--pkg', 'libraw',
'--pkg', 'libexif',
......@@ -251,5 +257,7 @@ executable('shotwell',
join_paths(meson.source_root(), 'data',
'org.gnome.Shotwell.gresource.xml')
],
link_with: [sw_graphics_processor],
link_with: [
sw_graphics_processor
],
install : true)
/* Copyright 2016 Software Freedom Conservancy Inc.
* Copyright 2019 Jens Georg <mail@jensge.org>
*
* This software is licensed under the GNU LGPL (version 2.1 or later).
* See the COPYING file in this distribution.
*/
namespace PublishingUI {
[GtkTemplate (ui = "/org/gnome/Shotwell/ui/login_welcome_pane_widget.ui")]
public class LoginWelcomePane : Spit.Publishing.DialogPane, Gtk.Box {
[GtkChild]
private Gtk.Button login_button;
[GtkChild]
private Gtk.Label not_logged_in_label;
public Gtk.Widget get_widget() {
return this;
}
public Spit.Publishing.DialogPane.GeometryOptions get_preferred_geometry() {
return Spit.Publishing.DialogPane.GeometryOptions.NONE;
}
public void on_pane_installed() {
}
public void on_pane_uninstalled() {
}
public signal void login_requested();
public LoginWelcomePane(string service_welcome_message) {
Object();
login_button.clicked.connect(on_login_clicked);
not_logged_in_label.set_use_markup(true);
not_logged_in_label.set_markup(service_welcome_message);
}
private void on_login_clicked() {
login_requested();
}
}
} // namespace PublishingUI
/* Copyright 2016 Software Freedom Conservancy Inc.
* Copyright 2019 Jens Georg <mail@jensge.org>
*
* This software is licensed under the GNU LGPL (version 2.1 or later).
* See the COPYING file in this distribution.
*/
namespace PublishingUI {
[GtkTemplate (ui = "/org/gnome/Shotwell/ui/progress_pane_widget.ui")]
public class ProgressPane : Spit.Publishing.DialogPane, Gtk.Box {
[GtkChild]
private Gtk.ProgressBar progress_bar;
public Gtk.Widget get_widget() {
return this;
}
public Spit.Publishing.DialogPane.GeometryOptions get_preferred_geometry() {
return Spit.Publishing.DialogPane.GeometryOptions.NONE;
}
public void on_pane_installed() {
}
public void on_pane_uninstalled() {
}
public void set_text(string text) {
progress_bar.set_text(text);
}
public void set_progress(double progress) {
progress_bar.set_fraction(progress);
}
public void set_status(string status_text, double progress) {
if (status_text != progress_bar.get_text())
progress_bar.set_text(status_text);
set_progress(progress);
}
}
} // namespace PublishingUI
......@@ -6,134 +6,6 @@
namespace PublishingUI {
public class ConcreteDialogPane : Spit.Publishing.DialogPane, GLib.Object {
protected Gtk.Box pane_widget = null;
protected Gtk.Builder builder = null;
public ConcreteDialogPane() {
builder = AppWindow.create_builder();
}
public Gtk.Widget get_widget() {
return pane_widget;
}
public Spit.Publishing.DialogPane.GeometryOptions get_preferred_geometry() {
return Spit.Publishing.DialogPane.GeometryOptions.NONE;
}
public void on_pane_installed() {
}
public void on_pane_uninstalled() {
}
}
public class StaticMessagePane : ConcreteDialogPane {
private Gtk.Label msg_label = null;
public StaticMessagePane(string message_string, bool enable_markup = false) {
base();
msg_label = builder.get_object("static_msg_label") as Gtk.Label;
pane_widget = builder.get_object("static_msg_pane_widget") as Gtk.Box;
if (enable_markup) {
msg_label.set_markup(message_string);
msg_label.set_line_wrap(true);
msg_label.set_use_markup(true);
} else {
msg_label.set_label(message_string);
}
}
}
public class LoginWelcomePane : ConcreteDialogPane {
private Gtk.Button login_button = null;
private Gtk.Label not_logged_in_label = null;
public signal void login_requested();
public LoginWelcomePane(string service_welcome_message) {
base();
pane_widget = builder.get_object("welcome_pane_widget") as Gtk.Box;
login_button = builder.get_object("login_button") as Gtk.Button;
not_logged_in_label = builder.get_object("not_logged_in_label") as Gtk.Label;
login_button.clicked.connect(on_login_clicked);
not_logged_in_label.set_use_markup(true);
not_logged_in_label.set_markup(service_welcome_message);
}
private void on_login_clicked() {
login_requested();
}
}
public class ProgressPane : ConcreteDialogPane {
private Gtk.ProgressBar progress_bar = null;
public ProgressPane() {
base();
pane_widget = (Gtk.Box) builder.get_object("progress_pane_widget");
progress_bar = (Gtk.ProgressBar) builder.get_object("publishing_progress_bar");
}
public void set_text(string text) {
progress_bar.set_text(text);
}
public void set_progress(double progress) {
progress_bar.set_fraction(progress);
}
public void set_status(string status_text, double progress) {
if (status_text != progress_bar.get_text())
progress_bar.set_text(status_text);
set_progress(progress);
}
}
public class SuccessPane : StaticMessagePane {
public SuccessPane(Spit.Publishing.Publisher.MediaType published_media, int num_uploaded = 1) {
string? message_string = null;
// Here, we check whether more than one item is being uploaded, and if so, display
// an alternate message.
if (published_media == Spit.Publishing.Publisher.MediaType.VIDEO) {
message_string = ngettext ("The selected video was successfully published.",
"The selected videos were successfully published.",
num_uploaded);
}
else if (published_media == Spit.Publishing.Publisher.MediaType.PHOTO) {
message_string = ngettext ("The selected photo was successfully published.",
"The selected photos were successfully published.",
num_uploaded);
}
else if (published_media == (Spit.Publishing.Publisher.MediaType.PHOTO
| Spit.Publishing.Publisher.MediaType.VIDEO)) {
message_string = _("The selected photos/videos were successfully published.");
}
else {
assert_not_reached ();
}
base(message_string);
}
}
public class AccountFetchWaitPane : StaticMessagePane {
public AccountFetchWaitPane() {
base(_("Fetching account information…"));
}
}
public class LoginWaitPane : StaticMessagePane {
public LoginWaitPane() {
base(_("Logging in…"));
}
}
public class PublishingDialog : Gtk.Dialog {
private const int LARGE_WINDOW_WIDTH = 860;
private const int LARGE_WINDOW_HEIGHT = 688;
......
/* Copyright 2016 Software Freedom Conservancy Inc.
* Copyright 2019 Jens Georg <mail@jensge.org>
*
* This software is licensed under the GNU LGPL (version 2.1 or later).
* See the COPYING file in this distribution.
*/
namespace PublishingUI {
[GtkTemplate (ui = "/org/gnome/Shotwell/ui/static_message_pane_widget.ui")]
public class StaticMessagePane : Spit.Publishing.DialogPane, Gtk.Box {
[GtkChild]
private Gtk.Label static_msg_label;
public Gtk.Widget get_widget() {
return this;
}
public Spit.Publishing.DialogPane.GeometryOptions get_preferred_geometry() {
return Spit.Publishing.DialogPane.GeometryOptions.NONE;
}
public void on_pane_installed() {
}
public void on_pane_uninstalled() {
}
public StaticMessagePane(string message_string, bool enable_markup = false) {
Object();
if (enable_markup) {
static_msg_label.set_markup(message_string);
static_msg_label.set_line_wrap(true);
static_msg_label.set_use_markup(true);
} else {
static_msg_label.set_label(message_string);
}
}
}
public class AccountFetchWaitPane : StaticMessagePane {
public AccountFetchWaitPane() {
base(_("Fetching account information…"));
}
}
public class LoginWaitPane : StaticMessagePane {
public LoginWaitPane() {
base(_("Logging in…"));
}
}
} // namespace PublishingUI
/* Copyright 2016 Software Freedom Conservancy Inc.
* Copyright 2019 Jens Georg <mail@jensge.org>
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
*/
namespace PublishingUI {
public class SuccessPane : StaticMessagePane {
public SuccessPane(Spit.Publishing.Publisher.MediaType published_media, int num_uploaded = 1) {
string? message_string = null;
// Here, we check whether more than one item is being uploaded, and if so, display
// an alternate message.
if (published_media == Spit.Publishing.Publisher.MediaType.VIDEO) {
message_string = ngettext ("The selected video was successfully published.",
"The selected videos were successfully published.",
num_uploaded);
}
else if (published_media == Spit.Publishing.Publisher.MediaType.PHOTO) {
message_string = ngettext ("The selected photo was successfully published.",
"The selected photos were successfully published.",
num_uploaded);
}
else if (published_media == (Spit.Publishing.Publisher.MediaType.PHOTO
| Spit.Publishing.Publisher.MediaType.VIDEO)) {
message_string = _("The selected photos/videos were successfully published.");
}
else {
assert_not_reached ();
}
base(message_string);
}
}
}
libsw_publishing_gui = static_library(
'publishing_gui',
[
'StaticMessagePaneWidget.vala',
'ProgressPaneWidget.vala',
'SuccessPaneWidget.vala',
'LoginWelcomePaneWidget.vala',
],
vala_header : 'shotwell-internal-publishing-gui.h',
vala_vapi : 'shotwell-internal-publishing-gui.vapi',
include_directories : config_incdir,
dependencies: [
gtk,
gee,
sw_plugin
],
vala_args : [
'--gresources',
join_paths(meson.source_root(), 'data',
'org.gnome.Shotwell.gresource.xml')
]
)
sw_publishing_gui = declare_dependency(
include_directories : include_directories('.'),
link_with : libsw_publishing_gui
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment