Skip to content

Commit

Permalink
feat: move to ui files, style, revealed view
Browse files Browse the repository at this point in the history
  • Loading branch information
GeopJr committed Oct 13, 2023
1 parent d9862c5 commit e7b493b
Show file tree
Hide file tree
Showing 6 changed files with 269 additions and 206 deletions.
1 change: 1 addition & 0 deletions data/gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<file>gtk/dropdown/expiration.ui</file>

<file>ui/views/base.ui</file>
<file>ui/views/media_viewer.ui</file>
<file>ui/views/profile_header.ui</file>
<file>ui/views/sidebar/view.ui</file>
<file>ui/views/sidebar/account.ui</file>
Expand Down
4 changes: 2 additions & 2 deletions data/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ flowboxchild {
background: alpha(@success_bg_color, 0.1);
}

.media-viewer-headerbar {
background: rgba(0, 0, 0, .7);
.media-viewer {
background: black;
color: white;
}

Expand Down
182 changes: 182 additions & 0 deletions data/ui/views/media_viewer.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0" />
<menu id="menu-model">
<item>
<attribute name="label" translatable="yes">Open in Browser</attribute>
<attribute name="action">mediaviewer.open-in-browser</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Copy URL</attribute>
<attribute name="action">mediaviewer.copy-url</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Save Media</attribute>
<attribute name="action">mediaviewer.save-as</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Copy Media</attribute>
<attribute name="action">mediaviewer.copy-media</attribute>
<attribute name="hidden-when">action-disabled</attribute>
</item>
</menu>
<template class="TubaViewsMediaViewer" parent="AdwBin">
<object class="GtkPopoverMenu" id="context_menu">
<property name="menu-model">menu-model</property>
<property name="has-arrow">0</property>
<property name="halign">start</property>
</object>
<child>
<object class="TubaWidgetsScaleRevealer" id="scale_revealer">
<property name="child">
<object class="AdwToolbarView">
<style>
<class name="media-viewer" />
</style>
<child type="top">
<object class="AdwHeaderBar">
<property name="centering-policy">strict</property>
<property name="title-widget">
<object class="GtkLabel">
<property name="label" translatable="yes">Media Viewer</property>
<style>
<class name="title" />
</style>
</object>
</property>
<child type="start">
<object class="GtkButton">
<property name="icon-name">tuba-left-large-symbolic</property>
<property name="tooltip-text" translatable="yes">Go Back</property>
<signal name="clicked" handler="clear" swapped="no" />
</object>
</child>
<child type="end">
<object class="GtkButton" id="fullscreen_btn">
<property name="icon-name">view-fullscreen-symbolic</property>
<property name="tooltip-text" translatable="yes">Toggle Fullscreen</property>
<signal name="clicked" handler="toggle_fullscreen" swapped="no" />
</object>
</child>
<child type="end">
<object class="GtkMenuButton">
<property name="menu-model">menu-model</property>
<property name="icon-name">view-more-symbolic</property>
<property name="tooltip-text" translatable="yes">Menu</property>
</object>
</child>
</object>
</child>
<property name="content">
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<child>
<object class="GtkOverlay">
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<child type="overlay">
<object class="GtkRevealer" id="page_buttons_revealer">
<property name="transition_type">crossfade</property>
<property name="reveal-child">0</property>
<property name="visible">0</property>
<property name="valign">end</property>
<property name="halign">start</property>
<property name="margin_end">18</property>
<property name="margin_bottom">18</property>
<property name="child">
<object class="GtkBox">
<property name="orientation">horizontal</property>
<property name="spacing">12</property>
<child>
<object class="GtkButton" id="prev_btn">
<property name="icon-name">go-previous-symbolic</property>
<property name="tooltip-text" translatable="yes">Previous Attachment</property>
<signal name="clicked" handler="on_previous_clicked" swapped="no" />
<style>
<class name="osd" />
<class name="media-viewer-fab" />
<class name="circular" />
</style>
</object>
</child>
<child>
<object class="GtkButton" id="next_btn">
<property name="icon-name">go-next-symbolic</property>
<property name="tooltip-text" translatable="yes">Next Attachment</property>
<signal name="clicked" handler="on_next_clicked" swapped="no" />
<style>
<class name="osd" />
<class name="media-viewer-fab" />
<class name="circular" />
</style>
</object>
</child>
</object>
</property>
</object>
</child>
<child type="overlay">
<object class="GtkRevealer" id="zoom_buttons_revealer">
<property name="transition_type">crossfade</property>
<property name="reveal-child">0</property>
<property name="visible">0</property>
<property name="valign">end</property>
<property name="halign">end</property>
<property name="margin_end">18</property>
<property name="margin_bottom">18</property>
<property name="child">
<object class="GtkBox">
<property name="orientation">horizontal</property>
<property name="spacing">12</property>
<child>
<object class="GtkButton" id="zoom_out_btn">
<property name="icon-name">zoom-out-symbolic</property>
<property name="tooltip-text" translatable="yes">Zoom Out</property>
<signal name="clicked" handler="on_zoom_out_clicked" swapped="no" />
<style>
<class name="osd" />
<class name="media-viewer-fab" />
<class name="circular" />
</style>
</object>
</child>
<child>
<object class="GtkButton" id="zoom_in_btn">
<property name="icon-name">zoom-in-symbolic</property>
<property name="tooltip-text" translatable="yes">Zoom In</property>
<signal name="clicked" handler="on_zoom_in_clicked" swapped="no" />
<style>
<class name="osd" />
<class name="media-viewer-fab" />
<class name="circular" />
</style>
</object>
</child>
</object>
</property>
</object>
</child>
<property name="child">
<object class="AdwCarousel" id="carousel">
<property name="hexpand">1</property>
<property name="vexpand">1</property>
</object>
</property>
</object>
</child>
<child>
<object class="AdwCarouselIndicatorDots" id="carousel_dots">
<property name="carousel">carousel</property>
<property name="visible">0</property>
</object>
</child>
</object>
</property>
</object>
</property>
</object>
</child>
</template>
</interface>
24 changes: 9 additions & 15 deletions src/Dialogs/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,16 @@ public class Tuba.Dialogs.MainWindow: Adw.ApplicationWindow, Saveable {
#endif
}

public bool is_media_viewer_visible () {
return media_viewer.visible;
public bool is_media_viewer_visible {
get { return media_viewer.visible; }
}

public void scroll_media_viewer (int pos) {
if (!is_media_viewer_visible ()) return;
if (!is_media_viewer_visible) return;

media_viewer.scroll_to (pos);
}

public void temp_reveal_media_viewer (Gtk.Widget widget) {
// if (is_media_viewer_visible ())
media_viewer.reveal (widget);
}

public void show_media_viewer (
string url,
Tuba.Attachment.MediaType media_type,
Expand All @@ -73,7 +68,7 @@ public class Tuba.Dialogs.MainWindow: Adw.ApplicationWindow, Saveable {

media_viewer.add_media (url, media_type, preview, pos, as_is, user_friendly_url);

if (!is_media_viewer_visible ()) {
if (!is_media_viewer_visible) {
if (source_widget != null) {
media_viewer.reveal (source_widget);
} else {
Expand All @@ -83,12 +78,11 @@ public class Tuba.Dialogs.MainWindow: Adw.ApplicationWindow, Saveable {
}

public void show_media_viewer_remote_video (string url, Gdk.Paintable? preview, string? user_friendly_url = null) {
if (!is_media_viewer_visible ()) {
// main_stack.visible_child_name = "media_viewer";
// media_viewer.clear.connect (hide_media_viewer);
}

media_viewer.set_remote_video (url, preview, user_friendly_url);

if (!is_media_viewer_visible) {
media_viewer.visible = true;
}
}

public void show_book (API.BookWyrm book, string? fallback = null) {
Expand Down Expand Up @@ -149,7 +143,7 @@ public class Tuba.Dialogs.MainWindow: Adw.ApplicationWindow, Saveable {
}

public bool back () {
if (is_media_viewer_visible ()) {
if (is_media_viewer_visible) {
media_viewer.clear ();
return true;
};
Expand Down
Loading

0 comments on commit e7b493b

Please sign in to comment.