Browse Source

ui: Remove the statusbar

All the info we needed from the statusbar should now be shown in the playbar. So
lets go ahead and remove the statusbar
tags/1.4.0
JosephMcc 4 years ago
parent
commit
92585acf4c
10 changed files with 2 additions and 570 deletions
  1. +0
    -25
      browser-plugin/xplayer-plugin-viewer.c
  2. +0
    -10
      data/xplayer.ui
  3. +0
    -1
      docs/reference/Makefile.am
  4. +0
    -2
      src/Makefile.am
  5. +0
    -53
      src/xplayer-menu.c
  6. +2
    -52
      src/xplayer-object.c
  7. +0
    -1
      src/xplayer-private.h
  8. +0
    -352
      src/xplayer-statusbar.c
  9. +0
    -73
      src/xplayer-statusbar.h
  10. +0
    -1
      src/xplayer.c

+ 0
- 25
browser-plugin/xplayer-plugin-viewer.c View File

@@ -45,7 +45,6 @@

#include "bacon-video-widget.h"
#include "xplayer-interface.h"
#include "xplayer-statusbar.h"
#include "xplayer-time-label.h"
#include "xplayer-fullscreen.h"
#include "xplayer-glow-button.h"
@@ -55,7 +54,6 @@
#include "xplayer-plugin-viewer-constants.h"
#include "xplayer-plugin-viewer-options.h"

GtkWidget *xplayer_statusbar_create (void);
GtkWidget *xplayer_volume_create (void);
GtkWidget *xplayer_pp_create (void);

@@ -108,7 +106,6 @@ typedef struct _XplayerEmbedded {
GtkBuilder *menuxml, *xml;
GtkWidget *pp_button;
GtkWidget *pp_fs_button;
XplayerStatusbar *statusbar;
int width, height;
char *user_agent;
const char *mimetype;
@@ -154,7 +151,6 @@ typedef struct _XplayerEmbedded {
guint is_browser_stream : 1;
guint is_playlist : 1;
guint controller_hidden : 1;
guint show_statusbar : 1;
guint hidden : 1;
guint repeat : 1;
guint seeking : 1;
@@ -349,8 +345,6 @@ xplayer_embedded_set_state (XplayerEmbedded *emb, XplayerStates state)
switch (state) {
case XPLAYER_STATE_STOPPED:
id = xplayer_get_rtl_icon_name ("media-playback-start");
xplayer_statusbar_set_text (emb->statusbar, _("Stopped"));
xplayer_statusbar_set_time_and_length (emb->statusbar, 0, 0);
xplayer_time_label_set_time
(XPLAYER_TIME_LABEL (emb->fs->time_label), 0, 0);
if (emb->href_uri != NULL && emb->hidden == FALSE) {
@@ -361,11 +355,9 @@ xplayer_embedded_set_state (XplayerEmbedded *emb, XplayerStates state)
break;
case XPLAYER_STATE_PAUSED:
id = xplayer_get_rtl_icon_name ("media-playback-start");
xplayer_statusbar_set_text (emb->statusbar, _("Paused"));
break;
case XPLAYER_STATE_PLAYING:
id = "media-playback-pause-symbolic";
xplayer_statusbar_set_text (emb->statusbar, _("Playing"));
if (emb->href_uri == NULL && emb->hidden == FALSE) {
gdk_window_set_cursor
(gtk_widget_get_window (GTK_WIDGET (emb->bvw)),
@@ -1475,14 +1467,6 @@ on_tick (GtkWidget *bvw,
if (emb->seeking == FALSE)
gtk_adjustment_set_value (emb->seekadj,
current_position * 65535);
if (stream_length == 0) {
xplayer_statusbar_set_time_and_length (emb->statusbar,
(int) (current_time / 1000), -1);
} else {
xplayer_statusbar_set_time_and_length (emb->statusbar,
(int) (current_time / 1000),
(int) (stream_length / 1000));
}

xplayer_time_label_set_time
(XPLAYER_TIME_LABEL (emb->fs->time_label),
@@ -1792,7 +1776,6 @@ xplayer_embedded_construct (XplayerEmbedded *emb,
g_signal_connect (G_OBJECT (emb->volume), "value-changed",
G_CALLBACK (cb_vol), emb);

emb->statusbar = XPLAYER_STATUSBAR (gtk_builder_get_object (emb->xml, "statusbar"));

if (!emb->hidden)
gtk_widget_set_size_request (emb->window, width, height);
@@ -1807,10 +1790,6 @@ xplayer_embedded_construct (XplayerEmbedded *emb,
gtk_widget_hide (child);
}

if (!emb->show_statusbar) {
gtk_widget_hide (GTK_WIDGET (emb->statusbar));
}

/* Try to make controls smaller */
{
GtkCssProvider *provider;
@@ -2053,7 +2032,6 @@ static char *arg_mime_type = NULL;
static char **arg_remaining = NULL;
static char *arg_referrer = NULL;
static gboolean arg_no_controls = FALSE;
static gboolean arg_statusbar = FALSE;
static gboolean arg_hidden = FALSE;
static gboolean arg_is_playlist = FALSE;
static gboolean arg_repeat = FALSE;
@@ -2094,7 +2072,6 @@ static GOptionEntry option_entries [] =
{ XPLAYER_OPTION_USER_AGENT, 0, 0, G_OPTION_ARG_STRING, &arg_user_agent, NULL, NULL },
{ XPLAYER_OPTION_MIMETYPE, 0, 0, G_OPTION_ARG_STRING, &arg_mime_type, NULL, NULL },
{ XPLAYER_OPTION_CONTROLS_HIDDEN, 0, 0, G_OPTION_ARG_NONE, &arg_no_controls, NULL, NULL },
{ XPLAYER_OPTION_STATUSBAR, 0, 0, G_OPTION_ARG_NONE, &arg_statusbar, NULL, NULL },
{ XPLAYER_OPTION_HIDDEN, 0, 0, G_OPTION_ARG_NONE, &arg_hidden, NULL, NULL },
{ XPLAYER_OPTION_PLAYLIST, 0, 0, G_OPTION_ARG_NONE, &arg_is_playlist, NULL, NULL },
{ XPLAYER_OPTION_REPEAT, 0, 0, G_OPTION_ARG_NONE, &arg_repeat, NULL, NULL },
@@ -2202,7 +2179,6 @@ int main (int argc, char **argv)
}

g_type_ensure (XPLAYER_TYPE_GLOW_BUTTON);
g_type_ensure (XPLAYER_TYPE_STATUSBAR);
g_type_ensure (XPLAYER_TYPE_TIME_LABEL);

if (arg_audioonly != FALSE)
@@ -2272,7 +2248,6 @@ int main (int argc, char **argv)
emb->width = -1;
emb->height = -1;
emb->controller_hidden = arg_no_controls;
emb->show_statusbar = arg_statusbar;
emb->current_uri = arg_remaining ? arg_remaining[0] : NULL;
emb->mimetype = arg_mime_type;
emb->hidden = arg_hidden;


+ 0
- 10
data/xplayer.ui View File

@@ -724,16 +724,6 @@
</packing>
</child>

<child>
<object class="XplayerStatusbar" id="tmw_statusbar">
<property name="visible">False</property>
</object>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</object>
</child>
</object>


+ 0
- 1
docs/reference/Makefile.am View File

@@ -74,7 +74,6 @@ IGNORE_HFILES = \
xplayer-plugin-manager.h \
xplayer-properties-view.h \
xplayer-open-location.h \
xplayer-statusbar.h \
xplayer-sidebar.h \
xplayer-session.h \
xplayer-resources.h \


+ 0
- 2
src/Makefile.am View File

@@ -34,8 +34,6 @@ header_DATA = $(INST_H_FILES)
# Xplayer UI ltlibrary (used by browser plugins)
libxplayer_player_la_SOURCES = \
$(INST_H_FILES) \
xplayer-statusbar.c \
xplayer-statusbar.h \
xplayer-interface.c \
xplayer-fullscreen.c \
xplayer-fullscreen.h \


+ 0
- 53
src/xplayer-menu.c View File

@@ -35,7 +35,6 @@
#include "xplayer-interface.h"
#include "xplayer-private.h"
#include "xplayer-sidebar.h"
#include "xplayer-statusbar.h"
#include "bacon-video-widget.h"
#include "xplayer-uri.h"

@@ -838,56 +837,6 @@ clear_playlist_action_callback (GtkAction *action, Xplayer *xplayer)
xplayer_action_set_mrl (xplayer, NULL, NULL);
}

/* Show help in status bar when selecting (hovering over) a menu item. */
static void
menu_item_select_cb (GtkMenuItem *proxy, Xplayer *xplayer)
{
GtkAction *action;
const gchar *message;

action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (proxy));
g_return_if_fail (action != NULL);

message = gtk_action_get_tooltip (action);
if (message)
xplayer_statusbar_push_help (XPLAYER_STATUSBAR (xplayer->statusbar), message);
}

static void
menu_item_deselect_cb (GtkMenuItem *proxy, Xplayer *xplayer)
{
xplayer_statusbar_pop_help (XPLAYER_STATUSBAR (xplayer->statusbar));
}

static void
setup_action (Xplayer *xplayer, GtkAction *action)
{
GSList *proxies;
for (proxies = gtk_action_get_proxies (action); proxies != NULL; proxies = proxies->next) {
if (GTK_IS_MENU_ITEM (proxies->data)) {
g_signal_connect (proxies->data, "select", G_CALLBACK (menu_item_select_cb), xplayer);
g_signal_connect (proxies->data, "deselect", G_CALLBACK (menu_item_deselect_cb), xplayer);
}

}
}

static void
setup_menu_items (Xplayer *xplayer)
{
GList *action_groups;

/* FIXME: We can remove this once GTK+ bug #574001 is fixed */
for (action_groups = gtk_ui_manager_get_action_groups (xplayer->ui_manager);
action_groups != NULL; action_groups = action_groups->next) {
GtkActionGroup *action_group = GTK_ACTION_GROUP (action_groups->data);
GList *actions;
for (actions = gtk_action_group_list_actions (action_group); actions != NULL; actions = actions->next) {
setup_action (xplayer, GTK_ACTION (actions->data));
}
}
}

void
xplayer_ui_manager_setup (Xplayer *xplayer)
{
@@ -907,8 +856,6 @@ xplayer_ui_manager_setup (Xplayer *xplayer)

xplayer->ui_manager = GTK_UI_MANAGER (gtk_builder_get_object (xplayer->xml, "xplayer-ui-manager"));

setup_menu_items (xplayer);

xplayer->devices_action_group = NULL;
xplayer->devices_ui_id = gtk_ui_manager_new_merge_id (xplayer->ui_manager);
xplayer->languages_action_group = NULL;


+ 2
- 52
src/xplayer-object.c View File

@@ -55,7 +55,6 @@
#include "xplayer-plugins-engine.h"
#include "xplayer-playlist.h"
#include "bacon-video-widget.h"
#include "xplayer-statusbar.h"
#include "xplayer-time-helpers.h"
#include "xplayer-sidebar.h"
#include "xplayer-menu.h"
@@ -974,7 +973,6 @@ reset_seek_status (XplayerObject *xplayer)
* avoid being "stuck" seeking on errors */

if (xplayer->seek_lock != FALSE) {
xplayer_statusbar_set_seeking (XPLAYER_STATUSBAR (xplayer->statusbar), FALSE);
xplayer_time_label_set_seeking (XPLAYER_TIME_LABEL (xplayer->fs->time_label), FALSE);
xplayer->seek_lock = FALSE;
bacon_video_widget_seek (xplayer->bvw, 0, NULL);
@@ -1167,24 +1165,16 @@ play_pause_set_label (XplayerObject *xplayer, XplayerStates state)
switch (state)
{
case STATE_PLAYING:
xplayer_statusbar_set_text (XPLAYER_STATUSBAR (xplayer->statusbar),
_("Playing"));
id = "media-playback-pause-symbolic";
tip = N_("Pause");
xplayer_playlist_set_playing (xplayer->playlist, XPLAYER_PLAYLIST_STATUS_PLAYING);
break;
case STATE_PAUSED:
xplayer_statusbar_set_text (XPLAYER_STATUSBAR (xplayer->statusbar),
_("Paused"));
id = xplayer_get_rtl_icon_name ("media-playback-start");
tip = N_("Play");
xplayer_playlist_set_playing (xplayer->playlist, XPLAYER_PLAYLIST_STATUS_PAUSED);
break;
case STATE_STOPPED:
xplayer_statusbar_set_text (XPLAYER_STATUSBAR (xplayer->statusbar),
_("Stopped"));
xplayer_statusbar_set_time_and_length
(XPLAYER_STATUSBAR (xplayer->statusbar), 0, 0);
id = xplayer_get_rtl_icon_name ("media-playback-start");
xplayer_playlist_set_playing (xplayer->playlist, XPLAYER_PLAYLIST_STATUS_NONE);
tip = N_("Play");
@@ -1772,11 +1762,6 @@ update_mrl_label (XplayerObject *xplayer, const char *name)
/* Title */
gtk_window_set_title (GTK_WINDOW (xplayer->win), name);
} else {
xplayer_statusbar_set_time_and_length (XPLAYER_STATUSBAR
(xplayer->statusbar), 0, 0);
xplayer_statusbar_set_text (XPLAYER_STATUSBAR (xplayer->statusbar),
_("Stopped"));

g_object_notify (G_OBJECT (xplayer), "stream-length");

/* Update the mrl label */
@@ -2040,7 +2025,6 @@ xplayer_seek_time_rel (XplayerObject *xplayer, gint64 _time, gboolean relative,
if (bacon_video_widget_is_seekable (xplayer->bvw) == FALSE)
return;

xplayer_statusbar_set_seeking (XPLAYER_STATUSBAR (xplayer->statusbar), TRUE);
xplayer_time_label_set_seeking (XPLAYER_TIME_LABEL (xplayer->fs->time_label), TRUE);

if (relative != FALSE) {
@@ -2053,7 +2037,6 @@ xplayer_seek_time_rel (XplayerObject *xplayer, gint64 _time, gboolean relative,

bacon_video_widget_seek_time (xplayer->bvw, sec, accurate, &err);

xplayer_statusbar_set_seeking (XPLAYER_STATUSBAR (xplayer->statusbar), FALSE);
xplayer_time_label_set_seeking (XPLAYER_TIME_LABEL (xplayer->fs->time_label), FALSE);

if (err != NULL)
@@ -2611,12 +2594,6 @@ on_error_event (BaconVideoWidget *bvw, char *message,
xplayer_action_error (xplayer, _("An error occurred"), message);
}

static void
on_buffering_event (BaconVideoWidget *bvw, gdouble percentage, XplayerObject *xplayer)
{
xplayer_statusbar_push (XPLAYER_STATUSBAR (xplayer->statusbar), percentage);
}

static void
on_download_buffering_event (BaconVideoWidget *bvw, gdouble level, XplayerObject *xplayer)
{
@@ -2718,18 +2695,6 @@ update_current_time (BaconVideoWidget *bvw,
gtk_adjustment_set_value (xplayer->seekadj,
current_position * 65535);

if (stream_length == 0 && xplayer->mrl != NULL)
{
xplayer_statusbar_set_time_and_length
(XPLAYER_STATUSBAR (xplayer->statusbar),
(int) (current_time / 1000), -1);
} else {
xplayer_statusbar_set_time_and_length
(XPLAYER_STATUSBAR (xplayer->statusbar),
(int) (current_time / 1000),
(int) (stream_length / 1000));
}

xplayer_time_label_set_time
(XPLAYER_TIME_LABEL (xplayer->fs->time_label),
current_time, stream_length);
@@ -2793,7 +2758,6 @@ seek_slider_pressed_cb (GtkWidget *widget, GdkEventButton *event, XplayerObject

xplayer->seek_lock = TRUE;
if (bacon_video_widget_can_direct_seek (xplayer->bvw) == FALSE) {
xplayer_statusbar_set_seeking (XPLAYER_STATUSBAR (xplayer->statusbar), TRUE);
xplayer_time_label_set_seeking (XPLAYER_TIME_LABEL (xplayer->fs->time_label), TRUE);
}

@@ -2811,8 +2775,6 @@ seek_slider_changed_cb (GtkAdjustment *adj, XplayerObject *xplayer)

pos = gtk_adjustment_get_value (adj) / 65535;
_time = bacon_video_widget_get_stream_length (xplayer->bvw);
xplayer_statusbar_set_time_and_length (XPLAYER_STATUSBAR (xplayer->statusbar),
(int) (pos * _time / 1000), _time / 1000);
xplayer_time_label_set_time
(XPLAYER_TIME_LABEL (xplayer->fs->time_label),
(int) (pos * _time), _time);
@@ -2843,7 +2805,6 @@ seek_slider_released_cb (GtkWidget *widget, GdkEventButton *event, XplayerObject
if (bacon_video_widget_can_direct_seek (xplayer->bvw) == FALSE)
xplayer_action_seek (xplayer, val / 65535.0);

xplayer_statusbar_set_seeking (XPLAYER_STATUSBAR (xplayer->statusbar), FALSE);
xplayer_time_label_set_seeking (XPLAYER_TIME_LABEL (xplayer->fs->time_label), FALSE);
return FALSE;
}
@@ -2952,7 +2913,7 @@ void
show_controls (XplayerObject *xplayer, gboolean was_fullscreen)
{
GtkAction *action;
GtkWidget *menubar, *controlbar, *statusbar, *bvw_box, *widget;
GtkWidget *menubar, *controlbar, *bvw_box, *widget;
GtkAllocation allocation;
int width = 0, height = 0;

@@ -2961,7 +2922,6 @@ show_controls (XplayerObject *xplayer, gboolean was_fullscreen)

menubar = GTK_WIDGET (gtk_builder_get_object (xplayer->xml, "tmw_menubar_box"));
controlbar = GTK_WIDGET (gtk_builder_get_object (xplayer->xml, "tmw_controls_vbox"));
statusbar = GTK_WIDGET (gtk_builder_get_object (xplayer->xml, "tmw_statusbar"));
bvw_box = GTK_WIDGET (gtk_builder_get_object (xplayer->xml, "tmw_bvw_box"));
widget = GTK_WIDGET (xplayer->bvw);

@@ -2978,7 +2938,6 @@ show_controls (XplayerObject *xplayer, gboolean was_fullscreen)
gtk_widget_set_sensitive (menubar, TRUE);
gtk_widget_show (menubar);
gtk_widget_show (controlbar);
gtk_widget_show (statusbar);
if (xplayer_sidebar_is_visible (xplayer) != FALSE) {
/* This is uglier then you might expect because of the
resize handle between the video and sidebar. There
@@ -3008,14 +2967,11 @@ show_controls (XplayerObject *xplayer, gboolean was_fullscreen)
if (was_fullscreen == FALSE) {
GtkAllocation allocation_menubar;
GtkAllocation allocation_controlbar;
GtkAllocation allocation_statusbar;

gtk_widget_get_allocation (menubar, &allocation_menubar);
gtk_widget_get_allocation (controlbar, &allocation_controlbar);
gtk_widget_get_allocation (statusbar, &allocation_statusbar);
height += allocation_menubar.height
+ allocation_controlbar.height
+ allocation_statusbar.height;
+ allocation_controlbar.height;
gtk_window_resize (GTK_WINDOW(xplayer->win),
width, height);
}
@@ -3030,7 +2986,6 @@ show_controls (XplayerObject *xplayer, gboolean was_fullscreen)
gtk_widget_hide (menubar);

gtk_widget_hide (controlbar);
gtk_widget_hide (statusbar);
gtk_widget_hide (xplayer->sidebar);

/* We won't show controls in fullscreen */
@@ -3591,7 +3546,6 @@ xplayer_action_handle_key_release (XplayerObject *xplayer, GdkEventKey *event)
switch (event->keyval) {
case GDK_KEY_Left:
case GDK_KEY_Right:
xplayer_statusbar_set_seeking (XPLAYER_STATUSBAR (xplayer->statusbar), FALSE);
xplayer_time_label_set_seeking (XPLAYER_TIME_LABEL (xplayer->fs->time_label), FALSE);
break;
default:
@@ -4407,10 +4361,6 @@ video_widget_create (XplayerObject *xplayer)
"got-metadata",
G_CALLBACK (on_got_metadata_event),
xplayer);
g_signal_connect (G_OBJECT (xplayer->bvw),
"buffering",
G_CALLBACK (on_buffering_event),
xplayer);
g_signal_connect (G_OBJECT (xplayer->bvw),
"download-buffering",
G_CALLBACK (on_download_buffering_event),


+ 0
- 1
src/xplayer-private.h View File

@@ -78,7 +78,6 @@ struct _XplayerObject {
BaconVideoWidget *bvw;
GtkWidget *prefs;
GtkBuilder *prefs_xml;
GtkWidget *statusbar;

/* UI manager */
GtkActionGroup *main_action_group;


+ 0
- 352
src/xplayer-statusbar.c View File

@@ -1,352 +0,0 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
* XplayerStatusbar Copyright (C) 1998 Shawn T. Amundson
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*/

/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/

#include "config.h"

#include <math.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>

#include "xplayer-statusbar.h"
#include "xplayer-time-helpers.h"

#define SPACING 4
#define NORMAL_CONTEXT "text"
#define BUFFERING_CONTEXT "buffering"
#define HELP_CONTEXT "help"

static void xplayer_statusbar_finalize (GObject *object);
static void xplayer_statusbar_sync_description (XplayerStatusbar *statusbar);

struct _XplayerStatusbarPrivate {
GtkWidget *progress;
GtkWidget *time_label;

gint time;
gint length;
guint timeout;
gdouble percentage;

guint pushed : 1;
guint seeking : 1;
guint timeout_ticks : 2;
};

G_DEFINE_TYPE(XplayerStatusbar, xplayer_statusbar, GTK_TYPE_STATUSBAR)

static void
xplayer_statusbar_class_init (XplayerStatusbarClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);

g_type_class_add_private (klass, sizeof (XplayerStatusbarPrivate));

gobject_class->finalize = xplayer_statusbar_finalize;
}

static void
xplayer_statusbar_init (XplayerStatusbar *statusbar)
{
XplayerStatusbarPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (statusbar, XPLAYER_TYPE_STATUSBAR, XplayerStatusbarPrivate);
GtkStatusbar *gstatusbar = GTK_STATUSBAR (statusbar);
GtkWidget *packer, *hbox, *vbox, *label;
GList *children_list;

statusbar->priv = priv;

priv->time = 0;
priv->length = -1;

hbox = gtk_statusbar_get_message_area (gstatusbar);
children_list = gtk_container_get_children (GTK_CONTAINER (hbox));
label = children_list->data;

gtk_box_set_child_packing (GTK_BOX (hbox), label,
FALSE, FALSE, 0, GTK_PACK_START);
gtk_label_set_ellipsize (GTK_LABEL (label), FALSE);

/* progressbar for network streams */
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, TRUE, 0);
gtk_widget_show (vbox);

priv->progress = gtk_progress_bar_new ();
gtk_progress_bar_set_inverted (GTK_PROGRESS_BAR (priv->progress),
gtk_widget_get_direction (priv->progress) == GTK_TEXT_DIR_LTR ?
FALSE : TRUE);
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->progress), 0.);
gtk_box_pack_start (GTK_BOX (vbox), priv->progress, TRUE, TRUE, 1);
gtk_widget_set_size_request (priv->progress, 150, 10);
//gtk_widget_hide (priv->progress);

packer = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
gtk_box_pack_start (GTK_BOX (hbox), packer, FALSE, FALSE, 0);
gtk_widget_show (packer);

priv->time_label = gtk_label_new (_("0:00 / 0:00"));
gtk_misc_set_alignment (GTK_MISC (priv->time_label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (hbox), priv->time_label, FALSE, FALSE, 0);
gtk_widget_show (priv->time_label);

xplayer_statusbar_set_text (statusbar, _("Stopped"));
}

GtkWidget*
xplayer_statusbar_new (void)
{
return g_object_new (XPLAYER_TYPE_STATUSBAR, NULL);
}

static void
xplayer_statusbar_update_time (XplayerStatusbar *statusbar)
{
XplayerStatusbarPrivate *priv = statusbar->priv;
char *time_string, *length, *label;

time_string = xplayer_time_to_string (priv->time * 1000);

if (priv->length < 0) {
label = g_strdup_printf (_("%s (Streaming)"), time_string);
} else {
length = xplayer_time_to_string
(priv->length == -1 ? 0 : priv->length * 1000);

if (priv->seeking == FALSE)
/* Elapsed / Total Length */
label = g_strdup_printf (_("%s / %s"), time_string, length);
else
/* Seeking to Time / Total Length */
label = g_strdup_printf (_("Seek to %s / %s"), time_string, length);

g_free (length);
}
g_free (time_string);

gtk_label_set_text (GTK_LABEL (priv->time_label), label);
g_free (label);

xplayer_statusbar_sync_description (statusbar);
}

void
xplayer_statusbar_set_text (XplayerStatusbar *statusbar, const char *label)
{
GtkStatusbar *gstatusbar = GTK_STATUSBAR (statusbar);
guint id;

id = gtk_statusbar_get_context_id (gstatusbar, NORMAL_CONTEXT);
gtk_statusbar_pop (gstatusbar, id);
gtk_statusbar_push (gstatusbar, id, label);

xplayer_statusbar_sync_description (statusbar);
}

void
xplayer_statusbar_set_time (XplayerStatusbar *statusbar, gint _time)
{
g_return_if_fail (XPLAYER_IS_STATUSBAR (statusbar));

if (statusbar->priv->time == _time)
return;

statusbar->priv->time = _time;
xplayer_statusbar_update_time (statusbar);
}

/* Set a help message to be displayed in the status bar. */
void
xplayer_statusbar_push_help (XplayerStatusbar *statusbar, const char *message)
{
GtkStatusbar *gstatusbar = GTK_STATUSBAR (statusbar);
guint id;

id = gtk_statusbar_get_context_id (gstatusbar, HELP_CONTEXT);
gtk_statusbar_push (gstatusbar, id, message);
}

/* Remove the last help message of the status bar. */
void
xplayer_statusbar_pop_help (XplayerStatusbar *statusbar)
{
GtkStatusbar *gstatusbar = GTK_STATUSBAR (statusbar);
guint id;

id = gtk_statusbar_get_context_id (gstatusbar, HELP_CONTEXT);
gtk_statusbar_pop (gstatusbar, id);
}

static gboolean
xplayer_statusbar_timeout_pop (XplayerStatusbar *statusbar)
{
XplayerStatusbarPrivate *priv = statusbar->priv;
GtkStatusbar *gstatusbar = GTK_STATUSBAR (statusbar);

if (--priv->timeout_ticks > 0)
return TRUE;

priv->pushed = FALSE;

gtk_statusbar_pop (gstatusbar,
gtk_statusbar_get_context_id (gstatusbar, BUFFERING_CONTEXT));

gtk_widget_hide (priv->progress);

xplayer_statusbar_sync_description (statusbar);

priv->percentage = 101;

priv->timeout = 0;

return FALSE;
}

void
xplayer_statusbar_push (XplayerStatusbar *statusbar, gdouble percentage)
{
XplayerStatusbarPrivate *priv = statusbar->priv;
GtkStatusbar *gstatusbar = GTK_STATUSBAR (statusbar);
char *label;
gboolean need_update = FALSE;

if (priv->pushed == FALSE)
{
gtk_statusbar_push (gstatusbar,
gtk_statusbar_get_context_id (gstatusbar, BUFFERING_CONTEXT),
_("Buffering"));
priv->pushed = TRUE;

need_update = TRUE;
}

if (priv->percentage != percentage)
{
priv->percentage = percentage;

/* eg: 75 % */
label = g_strdup_printf (_("%lf %%"), floorf (percentage));
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (priv->progress), label);
g_free (label);
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->progress),
percentage);
gtk_widget_show (priv->progress);

need_update = TRUE;
}

priv->timeout_ticks = 3;

if (priv->timeout == 0)
{
priv->timeout = g_timeout_add_seconds (1, (GSourceFunc) xplayer_statusbar_timeout_pop, statusbar);
}

if (need_update)
xplayer_statusbar_sync_description (statusbar);
}

void
xplayer_statusbar_pop (XplayerStatusbar *statusbar)
{
if (statusbar->priv->pushed != FALSE)
{
g_source_remove (statusbar->priv->timeout);
xplayer_statusbar_timeout_pop (statusbar);
}
}

void
xplayer_statusbar_set_time_and_length (XplayerStatusbar *statusbar,
gint _time, gint length)
{
g_return_if_fail (XPLAYER_IS_STATUSBAR (statusbar));

if (_time != statusbar->priv->time ||
length != statusbar->priv->length) {
statusbar->priv->time = _time;
statusbar->priv->length = length;

xplayer_statusbar_update_time (statusbar);
}
}

void
xplayer_statusbar_set_seeking (XplayerStatusbar *statusbar,
gboolean seeking)
{
g_return_if_fail (XPLAYER_IS_STATUSBAR (statusbar));

if (statusbar->priv->seeking == seeking)
return;

statusbar->priv->seeking = seeking;

xplayer_statusbar_update_time (statusbar);
}

static void
xplayer_statusbar_sync_description (XplayerStatusbar *statusbar)
{
GtkWidget *message_area, *label;
AtkObject *obj;
GList *children_list;
char *text;

message_area = gtk_statusbar_get_message_area (GTK_STATUSBAR (statusbar));
children_list = gtk_container_get_children (GTK_CONTAINER (message_area));
label = children_list->data;

obj = gtk_widget_get_accessible (GTK_WIDGET (statusbar));
if (statusbar->priv->pushed == FALSE) {
/* eg: Paused, 0:32 / 1:05 */
text = g_strdup_printf (_("%s, %s"),
gtk_label_get_text (GTK_LABEL (label)),
gtk_label_get_text (GTK_LABEL (statusbar->priv->time_label)));
} else {
/* eg: Buffering, 75 % */
text = g_strdup_printf (_("%s, %f %%"),
gtk_label_get_text (GTK_LABEL (label)),
floorf (statusbar->priv->percentage));
}

atk_object_set_name (obj, text);
g_free (text);
}

static void
xplayer_statusbar_finalize (GObject *object)
{
XplayerStatusbarPrivate *priv = XPLAYER_STATUSBAR (object)->priv;

if (priv->timeout != 0)
g_source_remove (priv->timeout);

G_OBJECT_CLASS (xplayer_statusbar_parent_class)->finalize (object);
}

/*
* vim: sw=2 ts=8 cindent noai bs=2
*/

+ 0
- 73
src/xplayer-statusbar.h View File

@@ -1,73 +0,0 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
* XplayerStatusbar Copyright (C) 1998 Shawn T. Amundson
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*/

/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/

#ifndef __XPLAYER_STATUSBAR_H__
#define __XPLAYER_STATUSBAR_H__

#include <gtk/gtk.h>

G_BEGIN_DECLS

#define XPLAYER_TYPE_STATUSBAR (xplayer_statusbar_get_type ())
#define XPLAYER_STATUSBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XPLAYER_TYPE_STATUSBAR, XplayerStatusbar))
#define XPLAYER_STATUSBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XPLAYER_TYPE_STATUSBAR, XplayerStatusbarClass))
#define XPLAYER_IS_STATUSBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XPLAYER_TYPE_STATUSBAR))
#define XPLAYER_IS_STATUSBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XPLAYER_TYPE_STATUSBAR))
#define XPLAYER_STATUSBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XPLAYER_TYPE_STATUSBAR, XplayerStatusbarClass))

typedef struct _XplayerStatusbarPrivate XplayerStatusbarPrivate;

typedef struct
{
GtkStatusbar parent_instance;
XplayerStatusbarPrivate *priv;
} XplayerStatusbar;

typedef GtkStatusbarClass XplayerStatusbarClass;

G_MODULE_EXPORT GType xplayer_statusbar_get_type (void) G_GNUC_CONST;
GtkWidget* xplayer_statusbar_new (void);

void xplayer_statusbar_set_time (XplayerStatusbar *statusbar,
gint time);
void xplayer_statusbar_set_time_and_length (XplayerStatusbar *statusbar,
gint time, gint length);
void xplayer_statusbar_set_seeking (XplayerStatusbar *statusbar,
gboolean seeking);

void xplayer_statusbar_set_text (XplayerStatusbar *statusbar,
const char *label);
void xplayer_statusbar_push_help (XplayerStatusbar *statusbar,
const char *message);
void xplayer_statusbar_pop_help (XplayerStatusbar *statusbar);
void xplayer_statusbar_push (XplayerStatusbar *statusbar,
gdouble percentage);
void xplayer_statusbar_pop (XplayerStatusbar *statusbar);

G_END_DECLS

#endif /* __XPLAYER_STATUSBAR_H__ */

+ 0
- 1
src/xplayer.c View File

@@ -123,7 +123,6 @@ app_init (Xplayer *xplayer, char **argv)
xplayer->seek = GTK_WIDGET (gtk_builder_get_object (xplayer->xml, "tmw_seek_hscale"));
xplayer->seekadj = gtk_range_get_adjustment (GTK_RANGE (xplayer->seek));
xplayer->volume = GTK_WIDGET (gtk_builder_get_object (xplayer->xml, "tmw_volume_button"));
xplayer->statusbar = GTK_WIDGET (gtk_builder_get_object (xplayer->xml, "tmw_statusbar"));
xplayer->seek_lock = FALSE;
xplayer->fs = xplayer_fullscreen_new (GTK_WINDOW (xplayer->win));
gtk_scale_button_set_adjustment (GTK_SCALE_BUTTON (xplayer->fs->volume),


Loading…
Cancel
Save