diff options
author | Krifa75 <yahiaoui.fakhri@gmail.com> | 2022-11-27 21:32:13 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2022-11-28 11:23:42 +0100 |
commit | a61bd5c6de5435ef495986cc1cd3d3809e5b079a (patch) | |
tree | 0865a9c72d709a5af731546afe2b977862331cd6 | |
parent | aaf4d721dab1512a67af4d45cb522bf2bd5e664f (diff) | |
download | totem-a61bd5c6de5435ef495986cc1cd3d3809e5b079a.tar.gz |
main: Merge the main header and fullscreen header
HdyFlap can act as a GtkBox or a GtkOverlay. We make full use
of that so that the main header can act as the fullscreen header.
With this, we avoid to have two separate header having the same content.
Co-authored: Bastien Nocera <hadess@hadess.net>
-rw-r--r-- | data/totem.ui | 111 | ||||
-rw-r--r-- | src/totem-object.c | 48 | ||||
-rw-r--r-- | src/totem-private.h | 7 |
3 files changed, 49 insertions, 117 deletions
diff --git a/data/totem.ui b/data/totem.ui index a9a8f2e92..a67f2a46d 100644 --- a/data/totem.ui +++ b/data/totem.ui @@ -194,10 +194,11 @@ <signal name="key-press-event" handler="window_key_press_event_cb" swapped="no"/> <signal name="delete-event" handler="main_window_destroy_cb" swapped="no"/> <child> - <object class="GtkBox"> + <object class="HdyFlap" id="flap"> <property name="visible">True</property> <property name="orientation">vertical</property> - <child> + <property name="fold-policy">never</property> + <child type="flap"> <object class="TotemMainToolbar" id="header"> <property name="visible">True</property> <property name="show-search-button">True</property> @@ -208,6 +209,27 @@ <signal name="notify::search-mode" handler="update_add_button_visibility"/> <signal name="notify::select-mode" handler="update_add_button_visibility"/> <child> + <object class="GtkButton" id="unfullscreen_button"> + <property name="visible">False</property> + <property name="no-show-all">True</property> + <property name="valign">center</property> + <property name="action-name">app.fullscreen</property> + <style> + <class name="image-button"/> + </style> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="icon-name">view-restore-symbolic</property> + <property name="icon-size">1</property> + </object> + </child> + </object> + <packing> + <property name="pack-type">end</property> + </packing> + </child> + <child> <object class="GtkMenuButton" id="add_button"> <property name="visible">True</property> <property name="valign">center</property> @@ -354,91 +376,6 @@ <property name="halign">fill</property> <property name="valign">fill</property> <child> - <object class="TotemMainToolbar" id="fullscreen_header"> - <property name="visible">False</property> - <property name="show-search-button">False</property> - <property name="show-select-button">False</property> - <property name="show-back-button">True</property> - <property name="opacity">0.86</property> - <property name="halign">fill</property> - <property name="hexpand">True</property> - <property name="title" bind-source="header" bind-property="title"/> - <property name="subtitle" bind-source="header" bind-property="subtitle"/> - <signal name="back-clicked" handler="back_button_clicked_cb"/> - <child> - <object class="GtkButton"> - <property name="visible">True</property> - <property name="no-show-all">True</property> - <property name="valign">center</property> - <property name="action-name">app.fullscreen</property> - <style> - <class name="image-button"/> - </style> - <child> - <object class="GtkImage"> - <property name="visible">True</property> - <property name="icon-name">view-restore-symbolic</property> - <property name="icon-size">1</property> - </object> - </child> - </object> - <packing> - <property name="pack-type">end</property> - </packing> - </child> - <child> - <object class="GtkMenuButton" id="fullscreen_gear_button"> - <property name="visible">True</property> - <property name="valign">center</property> - <property name="use-popover">True</property> - <property name="menu-model">playermenu</property> - <signal name="toggled" handler="popup_menu_shown_cb"/> - <style> - <class name="image-button"/> - </style> - <child> - <object class="GtkImage"> - <property name="visible">True</property> - <property name="icon-name">view-more-symbolic</property> - <property name="icon-size">1</property> - </object> - </child> - </object> - <packing> - <property name="pack-type">end</property> - </packing> - </child> - <child> - <object class="GtkMenuButton" id="fullscreen_subtitles_button"> - <property name="visible">True</property> - <property name="valign">center</property> - <property name="use-popover">True</property> - <property name="menu-model">subtitlesmenu</property> - <signal name="toggled" handler="popup_menu_shown_cb"/> - <style> - <class name="image-button"/> - </style> - <child> - <object class="GtkImage"> - <property name="visible">True</property> - <property name="icon-name">media-view-subtitles-symbolic</property> - <property name="icon-size">1</property> - </object> - </child> - </object> - <packing> - <property name="pack-type">end</property> - </packing> - </child> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">0</property> - <property name="width">3</property> - <property name="height">1</property> - </packing> - </child> - <child> <object class="GtkSpinner" id="spinner"> <property name="visible">False</property> <property name="vexpand">True</property> diff --git a/src/totem-object.c b/src/totem-object.c index 1076f8f16..01f2d0fc3 100644 --- a/src/totem-object.c +++ b/src/totem-object.c @@ -1689,6 +1689,8 @@ window_state_event_cb (GtkWidget *window, TotemObject *totem) { GAction *action; + gboolean is_fullscreen; + const char *main_page; totem->maximised = !!(event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED); @@ -1705,9 +1707,19 @@ window_state_event_cb (GtkWidget *window, totem_object_save_size (totem); } + is_fullscreen = (totem->controls_visibility == TOTEM_CONTROLS_FULLSCREEN); + hdy_flap_set_fold_policy (HDY_FLAP (totem->flap), is_fullscreen ? + HDY_FLAP_FOLD_POLICY_ALWAYS : HDY_FLAP_FOLD_POLICY_NEVER); + gtk_widget_set_opacity (totem->header, is_fullscreen ? 0.86 : 1); + gtk_widget_set_visible (totem->unfullscreen_button, is_fullscreen); + + /* Particular case when we are in fullscreen mode and we go back directly on grilo page */ + main_page = totem_object_get_main_page (totem); + gtk_widget_set_visible (totem->fullscreen_button, !is_fullscreen && g_str_equal(main_page, "player")); + action = g_action_map_lookup_action (G_ACTION_MAP (totem), "fullscreen"); g_simple_action_set_state (G_SIMPLE_ACTION (action), - g_variant_new_boolean (totem->controls_visibility == TOTEM_CONTROLS_FULLSCREEN)); + g_variant_new_boolean (is_fullscreen)); if (totem->transition_timeout_id > 0) set_controls_visibility (totem, TRUE, FALSE); @@ -1882,8 +1894,8 @@ set_controls_visibility (TotemObject *totem, gboolean animate) { gtk_widget_set_visible (GTK_WIDGET (gtk_builder_get_object (totem->xml, "toolbar")), visible); - gtk_widget_set_visible (totem->fullscreen_header, visible && - totem->controls_visibility == TOTEM_CONTROLS_FULLSCREEN); + if (totem->controls_visibility == TOTEM_CONTROLS_FULLSCREEN) + hdy_flap_set_reveal_flap (HDY_FLAP (totem->flap), visible); bacon_video_widget_set_show_cursor (totem->bvw, visible); if (visible && animate) schedule_hiding_popup (totem); @@ -3577,13 +3589,8 @@ totem_object_handle_key_press (TotemObject *totem, GdkEventKey *event) case GDK_KEY_Menu: case GDK_KEY_F10: show_popup (totem); - if (totem->controls_visibility != TOTEM_CONTROLS_FULLSCREEN) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (totem->gear_button), - !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (totem->gear_button))); - } else { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (totem->fullscreen_gear_button), - !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (totem->fullscreen_gear_button))); - } + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (totem->gear_button), + !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (totem->gear_button))); break; case GDK_KEY_Time: show_popup (totem); @@ -3837,9 +3844,11 @@ totem_setup_window (TotemObject *totem) gtk_window_maximize (GTK_WINDOW (totem->win)); } + totem->flap = GTK_WIDGET (gtk_builder_get_object (totem->xml, "flap")); + /* Headerbar */ totem->header = GTK_WIDGET (gtk_builder_get_object (totem->xml, "header")); - g_object_bind_property (totem, "fullscreen", totem->header, "visible", G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN); + g_object_bind_property (totem, "fullscreen", totem->header, "show-close-button", G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN); return; } @@ -3930,6 +3939,9 @@ totem_callback_connect (TotemObject *totem) /* Fullscreen button */ totem->fullscreen_button = GTK_WIDGET (gtk_builder_get_object (totem->xml, "fullscreen_button")); + /* Unfullscreen button */ + totem->unfullscreen_button = GTK_WIDGET (gtk_builder_get_object (totem->xml, "unfullscreen_button")); + /* Set sensitivity of the toolbar buttons */ action_set_sensitive ("play", FALSE); action_set_sensitive ("next-chapter", FALSE); @@ -4000,17 +4012,6 @@ grilo_widget_setup (TotemObject *totem) gtk_stack_set_visible_child_name (GTK_STACK (totem->stack), "grilo"); } -static void -add_fullscreen_toolbar (TotemObject *totem, - GtkWidget *container) -{ - totem->fullscreen_header = GTK_WIDGET (gtk_builder_get_object (totem->xml, "fullscreen_header")); - - totem->fullscreen_gear_button = GTK_WIDGET (gtk_builder_get_object (totem->xml, "fullscreen_gear_button")); - - totem->fullscreen_subtitles_button = GTK_WIDGET (gtk_builder_get_object (totem->xml, "fullscreen_subtitles_button")); -} - void video_widget_create (TotemObject *totem) { @@ -4026,9 +4027,6 @@ video_widget_create (TotemObject *totem) totem_object_exit (totem); } - totem->bvw_grid = GTK_WIDGET (gtk_builder_get_object (totem->xml, "bvw_grid")); - add_fullscreen_toolbar (totem, totem->bvw_grid); - gtk_drag_dest_set (GTK_WIDGET (totem->bvw), GTK_DEST_DEFAULT_ALL, target_table, G_N_ELEMENTS (target_table), GDK_ACTION_MOVE); diff --git a/src/totem-private.h b/src/totem-private.h index 72e5f4a65..421922a85 100644 --- a/src/totem-private.h +++ b/src/totem-private.h @@ -54,9 +54,9 @@ struct _TotemObject { /* Control window */ GtkBuilder *xml; GtkWidget *win; + GtkWidget *flap; GtkWidget *stack; BaconVideoWidget *bvw; - GtkWidget *bvw_grid; GtkWidget *prefs; GtkWindow *shortcuts_win; GtkWidget *spinner; @@ -68,10 +68,6 @@ struct _TotemObject { BaconTimeLabel *time_rem_label; GtkWidget *header; - GtkWidget *fullscreen_header; - GtkWidget *fullscreen_gear_button; - GtkWidget *fullscreen_subtitles_button; - /* Plugins */ GtkWidget *plugins; TotemPluginsEngine *engine; @@ -118,6 +114,7 @@ struct _TotemObject { char *search_string; gboolean select_mode; GObject *custom_title; + GtkWidget *unfullscreen_button; GtkWidget *fullscreen_button; GtkWidget *gear_button; GtkWidget *add_button; |