[shotwell/wip/gtk4: 154/154] Rebase on master, profile editor partially working
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell/wip/gtk4: 154/154] Rebase on master, profile editor partially working
- Date: Sat, 1 Oct 2022 17:53:22 +0000 (UTC)
commit 979e4234529d6f75214549bf2066a60a612d1b68
Author: Jens Georg <mail jensge org>
Date: Sat Oct 1 19:52:56 2022 +0200
Rebase on master, profile editor partially working
data/ui/preferences_dialog.ui | 25 +++++++++++++-----
src/ProfileBrowser.vala | 61 +++++++++++++++++++++++--------------------
src/Profiles.vala | 20 ++++++++------
src/dialogs/Preferences.vala | 2 +-
src/main.vala | 5 ++--
5 files changed, 67 insertions(+), 46 deletions(-)
---
diff --git a/data/ui/preferences_dialog.ui b/data/ui/preferences_dialog.ui
index f2a9d0a8..a0b191b9 100644
--- a/data/ui/preferences_dialog.ui
+++ b/data/ui/preferences_dialog.ui
@@ -459,15 +459,26 @@
</object>
</child>
<child>
- <placeholder/>
- </child>
- <child type="tab">
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="label" translatable="yes">Profiles</property>
+ <object class="GtkNotebookPage">
+ <property name="position">3</property>
+ <property name="child">
+ <object class="GtkBox" id="profiles_box">
+ <property name="orientation">vertical</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </property>
+ <property name="tab">
+ <object class="GtkLabel" id="profiles-tab">
+ <property name="label" translatable="yes">Profiles</property>
+ </object>
+ </property>
</object>
</child>
+ <child>
+ <placeholder/>
+ </child>
</object>
</child>
</object>
diff --git a/src/ProfileBrowser.vala b/src/ProfileBrowser.vala
index 996cfdce..9220dbc3 100644
--- a/src/ProfileBrowser.vala
+++ b/src/ProfileBrowser.vala
@@ -29,7 +29,10 @@ namespace Shotwell {
var grid = new Gtk.Grid();
grid.hexpand = true;
grid.vexpand = true;
- grid.margin = 6;
+ grid.margin_top = 6;
+ grid.margin_bottom = 6;
+ grid.margin_start = 6;
+ grid.margin_end = 6;
grid.set_row_spacing(12);
grid.set_column_spacing(12);
var label = new Gtk.Label(_("Name"));
@@ -56,17 +59,17 @@ namespace Shotwell {
grid.attach(entry, 1, 1, 1, 1);
bind_property("library-folder", entry, "text", GLib.BindingFlags.SYNC_CREATE |
GLib.BindingFlags.BIDIRECTIONAL);
- var button = new Gtk.Button.from_icon_name("folder-symbolic", Gtk.IconSize.BUTTON);
+ var button = new Gtk.Button.from_icon_name("folder-symbolic");
button.hexpand = false;
button.vexpand = false;
button.halign = Gtk.Align.FILL;
button.clicked.connect(() => {
var dialog = new Gtk.FileChooserNative(_("Choose Library Folder"), this,
Gtk.FileChooserAction.SELECT_FOLDER, _("_OK"), _("_Cancel"));
- dialog.set_current_folder(library_folder);
- var result = dialog.run();
+ dialog.set_current_folder(File.new_for_commandline_arg (library_folder));
+ var result = Gtk.ResponseType.OK; //dialog.run();
dialog.hide();
if (result == Gtk.ResponseType.ACCEPT) {
- library_folder = dialog.get_current_folder_file().get_path();
+ library_folder = dialog.get_current_folder().get_path();
}
dialog.destroy();
});
@@ -84,26 +87,26 @@ namespace Shotwell {
bind_property("data-folder", entry, "text", GLib.BindingFlags.SYNC_CREATE |
GLib.BindingFlags.BIDIRECTIONAL);
grid.attach(entry, 1, 2, 1, 1);
- button = new Gtk.Button.from_icon_name("folder-symbolic", Gtk.IconSize.BUTTON);
+ button = new Gtk.Button.from_icon_name("folder-symbolic");
button.hexpand = false;
button.vexpand = false;
button.halign = Gtk.Align.FILL;
button.clicked.connect(() => {
var dialog = new Gtk.FileChooserNative(_("Choose Data Folder"), this,
Gtk.FileChooserAction.SELECT_FOLDER, _("_OK"), _("_Cancel"));
- dialog.set_current_folder(data_folder);
- var result = dialog.run();
+ dialog.set_current_folder(File.new_for_commandline_arg(data_folder));
+ var result = Gtk.ResponseType.OK; //dialog.run();
dialog.hide();
if (result == Gtk.ResponseType.ACCEPT) {
- data_folder = dialog.get_current_folder_file().get_path();
+ data_folder = dialog.get_current_folder().get_path();
}
dialog.destroy();
});
grid.attach(button, 2, 2, 1, 1);
- get_content_area().add(grid);
+ get_content_area().append(grid);
- show_all();
+ show();
}
}
class ProfileBrowser : Gtk.Box {
@@ -114,7 +117,7 @@ namespace Shotwell {
public signal void profile_activated(string? profile);
public override void constructed() {
- var scrollable = new Gtk.ScrolledWindow(null, null);
+ var scrollable = new Gtk.ScrolledWindow();
scrollable.hexpand = true;
scrollable.vexpand = true;
@@ -132,16 +135,17 @@ namespace Shotwell {
list_box.get_style_context().add_class("rich-list");
list_box.hexpand = true;
list_box.vexpand = true;
- scrollable.add (list_box);
+ scrollable.set_child (list_box);
list_box.bind_model(ProfileManager.get_instance(), on_widget_create);
list_box.set_header_func(on_header);
var button = new Gtk.Button.with_label(_("Create new Profile"));
- pack_start(button, false, false, 6);
+ prepend(button);
button.clicked.connect(() => {
var editor = new ProfileEditor();
editor.set_transient_for((Gtk.Window)get_ancestor(typeof(Gtk.Window)));
- var result = editor.run();
+ //var result = editor.run();
+ var result = Gtk.ResponseType.CANCEL;
editor.hide();
if (result == Gtk.ResponseType.OK) {
debug("Request to add new profile: %s %s %s %s", editor.id, editor.profile_name,
editor.library_folder, editor.data_folder);
@@ -149,8 +153,8 @@ namespace Shotwell {
}
editor.destroy();
});
- add(scrollable);
- show_all();
+ append(scrollable);
+ show();
}
private Gtk.Widget on_widget_create(Object item) {
@@ -168,7 +172,7 @@ namespace Shotwell {
var label = new Gtk.Label(null);
label.set_markup("<span weight=\"bold\" size=\"larger\">%s</span>".printf(p.name));
label.xalign = 0.0f;
- a.pack_start(label);
+ a.prepend(label);
// FIXME: Would love to use the facade here, but this is currently hardwired to use a fixed
profile
@@ -189,12 +193,12 @@ namespace Shotwell {
label = new Gtk.Label(import_dir);
label.get_style_context().add_class("dim-label");
label.xalign = 0.0f;
- a.pack_end(label);
+ a.append(label);
label.set_ellipsize(Pango.EllipsizeMode.MIDDLE);
Gtk.Image i;
if (p.active) {
- i = new Gtk.Image.from_icon_name ("emblem-default-symbolic", Gtk.IconSize.SMALL_TOOLBAR);
+ i = new Gtk.Image.from_icon_name ("emblem-default-symbolic");
i.set_tooltip_text(_("This is the currently active profile"));
} else {
i = new Gtk.Image();
@@ -209,11 +213,11 @@ namespace Shotwell {
i.margin_end = 6;
i.hexpand = false;
- box.pack_start(i, false, false, 0);
- box.pack_start(a, true, true, 0);
+ box.prepend(a);
+ box.prepend(i);
if (p.id != Profile.SYSTEM && ! p.active) {
- var b = new Gtk.Button.from_icon_name("window-close-symbolic", Gtk.IconSize.BUTTON);
+ var b = new Gtk.Button.from_icon_name("window-close-symbolic");
b.margin_top = 6;
b.margin_bottom = 6;
b.margin_start = 6;
@@ -222,21 +226,22 @@ namespace Shotwell {
b.hexpand = false;
b.halign = Gtk.Align.END;
b.get_style_context().add_class("flat");
- box.pack_end(b, false, false, 0);
+ box.append(b);
b.clicked.connect(() => {
var flags = Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL;
if (Resources.use_header_bar() == 1) {
flags |= Gtk.DialogFlags.USE_HEADER_BAR;
}
- var d = new Gtk.MessageDialog((Gtk.Window) this.get_toplevel(), flags,
Gtk.MessageType.QUESTION, Gtk.ButtonsType.NONE, null);
+ var d = new Gtk.MessageDialog((Gtk.Window) this.get_root(), flags,
Gtk.MessageType.QUESTION, Gtk.ButtonsType.NONE, null);
var title = _("Remove profile ā%sā").printf(p.name);
var subtitle = _("None of the options will remove any of the images associated with this
profile");
d.set_markup(_("<b><span size=\"larger\">%s</span></b>\n<span
weight=\"light\">%s</span>").printf(title, subtitle));
d.add_buttons(_("Remove profile and files"), Gtk.ResponseType.OK, _("Remove profile
only"), Gtk.ResponseType.ACCEPT, _("Cancel"), Gtk.ResponseType.CANCEL);
d.get_widget_for_response(Gtk.ResponseType.OK).get_style_context().add_class("destructive-action");
- var response = d.run();
+ //var response = d.run();
+ var response = Gtk.ResponseType.OK;
d.destroy();
if (response == Gtk.ResponseType.OK || response == Gtk.ResponseType.ACCEPT) {
ProfileManager.get_instance().remove(p.id, response == Gtk.ResponseType.OK);
@@ -244,9 +249,9 @@ namespace Shotwell {
});
}
- box.show_all();
+ box.show();
- row.add (box);
+ row.set_child(box);
return row;
}
diff --git a/src/Profiles.vala b/src/Profiles.vala
index 5ad4545f..58b4e975 100644
--- a/src/Profiles.vala
+++ b/src/Profiles.vala
@@ -34,14 +34,18 @@ namespace Shotwell {
this.profile == null);
}
- var group = profiles.get_groups()[position - 1];
- var id = profiles.get_value(group, "Id");
- var name = profiles.get_value(group, "Name");
- var active = this.profile == name;
- return new Profile(profiles.get_value(group, "Name"),
- id,
- get_data_dir_for_profile(id, group),
- active);
+ try {
+ var group = profiles.get_groups()[position - 1];
+ var id = profiles.get_value(group, "Id");
+ var name = profiles.get_value(group, "Name");
+ var active = this.profile == name;
+ return new Profile(profiles.get_value(group, "Name"),
+ id,
+ get_data_dir_for_profile(id, group),
+ active);
+ } catch (Error err) {
+ assert_not_reached();
+ }
}
diff --git a/src/dialogs/Preferences.vala b/src/dialogs/Preferences.vala
index a12fc08f..d958cb3c 100644
--- a/src/dialogs/Preferences.vala
+++ b/src/dialogs/Preferences.vala
@@ -133,7 +133,7 @@ public class PreferencesDialog : Gtk.Dialog {
lowercase.toggled.connect(on_lowercase_toggled);
plugins_box.append (plugins_mediator);
- ((Gtk.Container) preferences_notebook.get_nth_page (3)).add (new Shotwell.ProfileBrowser());
+ ((Gtk.Box)preferences_notebook.get_nth_page (3)).append(new Shotwell.ProfileBrowser());
populate_preference_options();
diff --git a/src/main.vala b/src/main.vala
index 0e32633a..d90402a6 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -395,9 +395,10 @@ void main(string[] args) {
CommandlineOptions.profile = profile;
window.response(Gtk.ResponseType.OK);
});
- window.get_content_area().add(browser);
+ window.get_content_area().append(browser);
window.set_size_request(430, 560);
- var response = window.run();
+
+ var response = Gtk.ResponseType.OK; //window.run();
window.destroy();
// Anything else than selecting an entry in the list will stop shotwell from starting
if (response != Gtk.ResponseType.OK) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]