[shotwell/wip/gtk4: 4/45] Starts
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell/wip/gtk4: 4/45] Starts
- Date: Wed, 13 Apr 2022 18:21:20 +0000 (UTC)
commit 1452fb4adf63781c6de7cd7206c7d1868fc2d815
Author: Jens Georg <mail jensge org>
Date: Sun Apr 3 18:57:57 2022 +0200
Starts
src/CheckerboardPage.vala | 10 +++++-----
src/Page.vala | 15 ++++++++++----
src/SearchFilter.vala | 25 +++++++++++------------
src/SinglePhotoPage.vala | 6 +++---
src/dialogs/EntryMultiCompletion.vala | 18 ++++++++++-------
src/dialogs/TextEntry.vala | 2 +-
src/library/BackgroundProgressBar.vala | 36 ++++++++++++----------------------
src/library/LibraryWindow.vala | 13 ++++++------
8 files changed, 62 insertions(+), 63 deletions(-)
---
diff --git a/src/CheckerboardPage.vala b/src/CheckerboardPage.vala
index e74f9a8a..9b9e8481 100644
--- a/src/CheckerboardPage.vala
+++ b/src/CheckerboardPage.vala
@@ -58,9 +58,9 @@ public abstract class CheckerboardPage : Page {
// want to set_adjustments before adding to ScrolledWindow to let our signal handlers
// run first ... otherwise, the thumbnails draw late
- layout.set_adjustments(get_hadjustment(), get_vadjustment());
+ layout.set_adjustments(scrolled.get_hadjustment(), scrolled.get_vadjustment());
- set_child(viewport);
+ scrolled.set_child(viewport);
// need to monitor items going hidden when dealing with anchor/cursor/highlighted items
get_view().items_hidden.connect(on_items_hidden);
@@ -69,7 +69,7 @@ public abstract class CheckerboardPage : Page {
get_view().items_visibility_changed.connect(on_items_visibility_changed);
// scrollbar policy
- set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
+ scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
}
public void init_item_context_menu(string path) {
@@ -154,7 +154,7 @@ public abstract class CheckerboardPage : Page {
}
public void scroll_to_item(CheckerboardItem item) {
- Gtk.Adjustment vadj = get_vadjustment();
+ Gtk.Adjustment vadj = scrolled.get_vadjustment();
if (!(get_adjustment_relation(vadj, item.allocation.y) == AdjustmentRelation.IN_RANGE
&& (get_adjustment_relation(vadj, item.allocation.y + item.allocation.height) ==
AdjustmentRelation.IN_RANGE))) {
@@ -611,7 +611,7 @@ public abstract class CheckerboardPage : Page {
}
// as the viewport never scrolls horizontally, only interested in vertical
- Gtk.Adjustment vadj = get_vadjustment();
+ Gtk.Adjustment vadj = scrolled.get_vadjustment();
int x, y;
Gdk.ModifierType mask;
diff --git a/src/Page.vala b/src/Page.vala
index addaf0fe..1463add7 100644
--- a/src/Page.vala
+++ b/src/Page.vala
@@ -55,9 +55,10 @@ public class InjectionGroup {
}
}
-public abstract class Page : Gtk.ScrolledWindow {
+public abstract class Page : Gtk.Box {
private const int CONSIDER_CONFIGURE_HALTED_MSEC = 400;
+ protected Gtk.ScrolledWindow scrolled;
protected Gtk.Builder builder = new Gtk.Builder ();
protected Gtk.Box toolbar;
protected bool in_view = false;
@@ -87,17 +88,23 @@ public abstract class Page : Gtk.ScrolledWindow {
private OneShotScheduler? update_actions_scheduler = null;
protected Page(string page_name) {
+ Object (orientation: Gtk.Orientation.HORIZONTAL);
+
+ scrolled = new Gtk.ScrolledWindow();
+ append(scrolled);
+ scrolled.hexpand = true;
+ scrolled.vexpand = true;
this.page_name = page_name;
view = new ViewCollection("ViewCollection for Page %s".printf(page_name));
last_down = { -1, -1 };
- set_can_focus(true);
+ scrolled.set_can_focus(true);
//popup_menu.connect(on_context_keypress);
- realize.connect(attach_view_signals);
+ scrolled.realize.connect(attach_view_signals);
}
~Page() {
@@ -129,7 +136,7 @@ public abstract class Page : Gtk.ScrolledWindow {
is_destroyed = true;
- base.destroy();
+ base.dispose();
debug("Page %s Destroyed", get_page_name());
}
diff --git a/src/SearchFilter.vala b/src/SearchFilter.vala
index f72e94ab..761a953b 100644
--- a/src/SearchFilter.vala
+++ b/src/SearchFilter.vala
@@ -619,8 +619,7 @@ public class SearchFilterActions {
}
}
-public class SearchFilterToolbar : Gtk.Revealer {
- private Gtk.Box toolbar;
+public class SearchFilterToolbar : Gtk.Box {
private const int FILTER_BUTTON_MARGIN = 12; // the distance between icon and edge of button
private const float FILTER_ICON_STAR_SCALE = 0.65f; // changes the size of the filter icon
private const float FILTER_ICON_SCALE = 0.75f; // changes the size of the all photos icon
@@ -1071,12 +1070,12 @@ public class SearchFilterToolbar : Gtk.Revealer {
private ToggleActionToolButton toolbtn_flag;
public SearchFilterToolbar(SearchFilterActions actions) {
+ Object(orientation: Gtk.Orientation.HORIZONTAL, spacing: 6);
this.actions = actions;
- toolbar = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 6);
actions.media_context_changed.connect(on_media_context_changed);
search_box = new SearchBox(actions.text);
- toolbar.set_name("search-filter-toolbar");
+ set_name("search-filter-toolbar");
try {
this.builder.add_from_resource (Resources.get_ui("search_bar.ui"));
@@ -1099,7 +1098,7 @@ public class SearchFilterToolbar : Gtk.Revealer {
// Type label and toggles
label_type = new LabelToolItem(_("Type"), 10, 5);
- toolbar.append(label_type);
+ append(label_type);
toolbtn_photos = new ToggleActionToolButton("win.display.photos");
toolbtn_photos.set_tooltip_text (_("Photos"));
@@ -1110,9 +1109,9 @@ public class SearchFilterToolbar : Gtk.Revealer {
toolbtn_raw = new ToggleActionToolButton("win.display.raw");
toolbtn_raw.set_tooltip_text(_("RAW Photos"));
- toolbar.append(toolbtn_photos);
- toolbar.append(toolbtn_videos);
- toolbar.append(toolbtn_raw);
+ append(toolbtn_photos);
+ append(toolbtn_videos);
+ append(toolbtn_raw);
// separator
@@ -1122,7 +1121,7 @@ public class SearchFilterToolbar : Gtk.Revealer {
toolbtn_flag.set_label(_("Flagged"));
toolbtn_flag.set_tooltip_text(_("Flagged"));
- toolbar.append(toolbtn_flag);
+ append(toolbtn_flag);
// separator
@@ -1130,7 +1129,7 @@ public class SearchFilterToolbar : Gtk.Revealer {
var model = this.builder.get_object ("popup-menu") as GLib.MenuModel;
rating_button = new RatingFilterButton (model);
rating_button.set_label(_("Rating"));
- toolbar.append(rating_button);
+ append(rating_button);
// separator
@@ -1138,15 +1137,13 @@ public class SearchFilterToolbar : Gtk.Revealer {
saved_search_button.set_label(_("Saved Search"));
saved_search_button.set_tooltip_text(_("Use a saved search to filter items in the current view"));
saved_search_button.clicked.connect(on_saved_search_button_clicked);
- toolbar.append(saved_search_button);
+ append(saved_search_button);
// Separator to right-align the text box
// Search box.
- toolbar.append(search_box);
+ append(search_box);
- set_child (toolbar);
-
// hook up signals to actions to be notified when they change
actions.flagged_toggled.connect(on_flagged_toggled);
actions.photos_toggled.connect(on_photos_toggled);
diff --git a/src/SinglePhotoPage.vala b/src/SinglePhotoPage.vala
index c239e24a..15093be4 100644
--- a/src/SinglePhotoPage.vala
+++ b/src/SinglePhotoPage.vala
@@ -45,11 +45,11 @@ public abstract class SinglePhotoPage : Page {
// With the current code automatically resizing the image to the viewport, scrollbars
// should never be shown, but this may change if/when zooming is supported
- set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
+ scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
viewport.set_child(canvas);
- set_child(viewport);
+ scrolled.set_child(viewport);
#if 0
canvas.add_events(Gdk.EventMask.EXPOSURE_MASK | Gdk.EventMask.STRUCTURE_MASK
@@ -204,7 +204,7 @@ public abstract class SinglePhotoPage : Page {
// scrollbar policy in fullscreen mode needs to be auto/auto, else the pixbuf will shift
// off the screen
if (container is FullscreenWindow)
- set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
+ scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
}
// max_dim represents the maximum size of the original pixbuf (i.e. pixbuf may be scaled and
diff --git a/src/dialogs/EntryMultiCompletion.vala b/src/dialogs/EntryMultiCompletion.vala
index f915f526..c746bd76 100644
--- a/src/dialogs/EntryMultiCompletion.vala
+++ b/src/dialogs/EntryMultiCompletion.vala
@@ -7,19 +7,23 @@
// Entry completion for values separated by separators (e.g. comma in the case of tags)
// Partly inspired by the class of the same name in gtkmm-utils by Marko Anastasov
-public class EntryMultiCompletion : Gtk.EntryCompletion {
+public class EntryMultiCompletion : Object {
private string delimiter;
+ private Gtk.EntryCompletion completion;
public EntryMultiCompletion(Gee.Collection<string> completion_list, string? delimiter) {
+ completion = new Gtk.EntryCompletion();
assert(delimiter == null || delimiter.length == 1);
this.delimiter = delimiter;
- set_model(create_completion_store(completion_list));
- set_text_column(0);
- set_match_func(match_func);
- match_selected.connect(on_match_selected);
+ completion.set_model(create_completion_store(completion_list));
+ completion.set_text_column(0);
+ completion.set_match_func(match_func);
+ completion.match_selected.connect(on_match_selected);
}
+ public Gtk.EntryCompletion get_completion () { return completion; }
+
private static Gtk.ListStore create_completion_store(Gee.Collection<string> completion_list) {
Gtk.ListStore completion_store = new Gtk.ListStore(1, typeof(string));
Gtk.TreeIter store_iter;
@@ -50,7 +54,7 @@ public class EntryMultiCompletion : Gtk.EntryCompletion {
if (normed_key.contains(delimiter)) {
// check whether cursor is before last delimiter
int offset = normed_key.char_count(normed_key.last_index_of_char(delimiter[0]));
- int position = ((Gtk.Entry) get_entry()).get_position();
+ int position = ((Gtk.Entry) completion.get_entry()).get_position();
if (position <= offset)
return false; // TODO: Autocompletion for tags not last in list
}
@@ -68,7 +72,7 @@ public class EntryMultiCompletion : Gtk.EntryCompletion {
string match;
model.get(iter, 0, out match);
- Gtk.Entry entry = (Gtk.Entry)get_entry();
+ Gtk.Entry entry = (Gtk.Entry)completion.get_entry();
string old_text = entry.get_text().normalize(-1, NormalizeMode.ALL_COMPOSE);
if (old_text.length > 0) {
diff --git a/src/dialogs/TextEntry.vala b/src/dialogs/TextEntry.vala
index 1c0727ab..23a74ed2 100644
--- a/src/dialogs/TextEntry.vala
+++ b/src/dialogs/TextEntry.vala
@@ -37,7 +37,7 @@ public class TextEntryDialog : Gtk.Dialog {
if (completion_list != null) { // Textfield with autocompletion
EntryMultiCompletion completion = new EntryMultiCompletion(completion_list,
completion_delimiter);
- entry.set_completion(completion);
+ entry.set_completion(completion.get_completion());
}
set_default_response(Gtk.ResponseType.OK);
diff --git a/src/library/BackgroundProgressBar.vala b/src/library/BackgroundProgressBar.vala
index 8ad71853..105f0730 100644
--- a/src/library/BackgroundProgressBar.vala
+++ b/src/library/BackgroundProgressBar.vala
@@ -4,7 +4,7 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-internal class BackgroundProgressBar : Gtk.ProgressBar {
+internal class BackgroundProgressBar : Gtk.Box {
public enum Priority {
NONE = 0,
STARTUP_SCAN = 35,
@@ -15,15 +15,15 @@ internal class BackgroundProgressBar : Gtk.ProgressBar {
public bool should_be_visible { get; private set; default = false; }
-#if UNITY_SUPPORT
- // UnityProgressBar: init
- private UnityProgressBar uniprobar = UnityProgressBar.get_instance();
-#endif
+ private Gtk.ProgressBar progress_bar;
private const int PULSE_MSEC = 250;
public BackgroundProgressBar() {
- Object(show_text: true);
+ Object(orientation: Gtk.Orientation.HORIZONTAL, spacing: 0);
+ progress_bar = new Gtk.ProgressBar();
+ progress_bar.show_text = true;
+ append (progress_bar);
}
private Priority current_priority = Priority.NONE;
@@ -36,8 +36,8 @@ internal class BackgroundProgressBar : Gtk.ProgressBar {
stop(priority, false);
current_priority = priority;
- set_text(label);
- pulse();
+ progress_bar.set_text(label);
+ progress_bar.pulse();
should_be_visible = true;
pulse_id = Timeout.add(PULSE_MSEC, on_pulse_timeout);
}
@@ -70,16 +70,10 @@ internal class BackgroundProgressBar : Gtk.ProgressBar {
current_priority = priority;
double fraction = count / total;
- set_fraction(fraction);
- set_text(_("%s (%d%%)").printf(label, (int) (fraction * 100.0)));
+ progress_bar.set_fraction(fraction);
+ progress_bar.set_text(_("%s (%d%%)").printf(label, (int) (fraction * 100.0)));
should_be_visible = true;
-#if UNITY_SUPPORT
- // UnityProgressBar: try to draw & set progress
- uniprobar.set_visible(true);
- uniprobar.set_progress(fraction);
-#endif
-
return true;
}
@@ -91,18 +85,14 @@ internal class BackgroundProgressBar : Gtk.ProgressBar {
current_priority = 0;
- set_fraction(0.0);
- set_text("");
+ progress_bar.set_fraction(0.0);
+ progress_bar.set_text("");
should_be_visible = false;
-#if UNITY_SUPPORT
- // UnityProgressBar: reset
- uniprobar.reset();
-#endif
}
private bool on_pulse_timeout() {
- pulse();
+ progress_bar.pulse();
return true;
}
diff --git a/src/library/LibraryWindow.vala b/src/library/LibraryWindow.vala
index d9a9d624..88eaa1df 100644
--- a/src/library/LibraryWindow.vala
+++ b/src/library/LibraryWindow.vala
@@ -131,7 +131,7 @@ public class LibraryWindow : AppWindow {
// own UIManager which will suck up the accelerators, and we want them to be associated with
// AppWindows instead.
private SearchFilterActions search_actions = new SearchFilterActions();
- private SearchFilterToolbar search_toolbar;
+ private Gtk.Revealer search_toolbar;
private Gtk.Box top_section = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
private Gtk.Revealer background_progress_frame = new Gtk.Revealer();
@@ -178,7 +178,8 @@ public class LibraryWindow : AppWindow {
on_update_properties_now);
// setup search bar and add its accelerators to the window
- search_toolbar = new SearchFilterToolbar(search_actions);
+ search_toolbar = new Gtk.Revealer();
+ search_toolbar.set_child (new SearchFilterToolbar(search_actions));
// create the main layout & start at the Library page
basic_properties = new BasicProperties();
@@ -344,7 +345,7 @@ public class LibraryWindow : AppWindow {
var basic_properties_action = get_current_page ().get_common_action
("CommonDisplayBasicProperties");
- assert(basic_properties_action != null);
+ //assert(basic_properties_action != null);
if (!basic_properties_action.get_state().get_boolean())
bottom_frame.hide();
@@ -646,7 +647,7 @@ public class LibraryWindow : AppWindow {
action.change_state (true);
// give it focus (which should move cursor to the text entry control)
- search_toolbar.take_focus();
+ ((SearchFilterToolbar)search_toolbar.get_child()).take_focus();
}
private void on_media_altered() {
@@ -1245,7 +1246,7 @@ public class LibraryWindow : AppWindow {
}
private void init_view_filter(CheckerboardPage page) {
- search_toolbar.set_view_filter(page.get_search_view_filter());
+ ((SearchFilterToolbar)search_toolbar.get_child()).set_view_filter(page.get_search_view_filter());
page.get_view().install_view_filter(page.get_search_view_filter());
}
@@ -1258,7 +1259,7 @@ public class LibraryWindow : AppWindow {
search_toolbar.set_reveal_child(show);
if (show) {
assert(null != page);
- search_toolbar.set_view_filter(page.get_search_view_filter());
+ ((SearchFilterToolbar)search_toolbar.get_child()).set_view_filter(page.get_search_view_filter());
page.get_view().install_view_filter(page.get_search_view_filter());
} else {
if (page != null)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]