user_interface.h 4.34 KB
Newer Older
1
/*
2
 * snappy - 1.0
3
 *
4
 * Copyright (C) 2011-2014 Collabora Ltd.
5
 * Luis de Bethencourt <luis@debethencourt.com>
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
 * USA
 */

#ifndef __USER_INTERFACE_H__
#define __USER_INTERFACE_H__

26 27 28 29
#include <clutter/clutter.h>
#include <clutter-gst/clutter-gst.h>
#include <clutter-gtk/clutter-gtk.h>

30 31
#include <gtk/gtk.h>

32
#include "gst_engine.h"
33
#include "screensaver.h"
34

35
#define CTL_SHOW_SEC 3
36
#define CTL_FADE_DURATION G_TIME_SPAN_MILLISECOND / 4
37

38
#define CONTROLS_WIDTH_RATIO 0.48f
39
#define CONTROLS_HEIGHT_RATIO 0.20f
40
#define CONTROLS_ASPECT_RATIO 4.0f
41
#define CONTROLS_MAX_WIDTH 480.0f
42
#define CONTROLS_MIN_WIDTH 300.0f
43

Robert Swain's avatar
Robert Swain committed
44 45
#define MAIN_BOX_W 0.95f
#define MAIN_BOX_H 0.8f
46

47
#define PLAY_TOGGLE_RATIO 0.38f
Luis de Bethencourt's avatar
Luis de Bethencourt committed
48
#define TITLE_RATIO 0.033f
49
#define SEEK_WIDTH_RATIO 0.9f
50
#define SEEK_HEIGHT_RATIO 0.10f
51
#define POS_RATIO 0.1f
Luis de Bethencourt's avatar
Luis de Bethencourt committed
52
#define VOLUME_ICON_RATIO 0.18f
Robert Swain's avatar
Robert Swain committed
53
#define VOLUME_WIDTH_RATIO 0.65f
54
#define VOLUME_HEIGHT_RATIO 0.05f
55 56 57 58 59

#define TITLE_LENGTH 40

#define SEC_IN_HOUR 3600
#define SEC_IN_MIN 60
60

61
#define PENALTY_TIME G_TIME_SPAN_MILLISECOND / 2
62

63 64 65
#define DEFAULT_WIDTH 640
#define DEFAULT_HEIGHT 480

66 67
G_BEGIN_DECLS

68 69 70 71 72 73 74
enum
{
  STREAM_AUDIO,
  STREAM_TEXT,
  STREAM_VIDEO
};

75
typedef struct _UserInterface UserInterface;
76 77 78

struct _UserInterface
{
79
  gboolean controls_showing, keep_showing_controls;
80
  gboolean blind, fullscreen, hide, penalty_box_active, tags;
81
  gboolean subtitles_available;
82
  gboolean duration_str_fwd_direction;
83

84
  gint title_length, controls_timeout, progress_id;
85
  guint media_width, media_height;
86
  gint64 media_duration;
87 88 89
  gfloat stage_width, stage_height;
  gfloat screen_width, screen_height;
  gfloat windowed_width, windowed_height;
90
  gfloat playback_position, volume;
91
  gfloat seek_width, seek_height;
92
  gfloat volume_width, volume_height;
93

94 95
  gchar *filename, *fileuri;
  gchar *play_png, *pause_png;
96
  gchar *segment_png;
97
  gchar *volume_low_png, *volume_high_png;
98
  gchar *fullscreen_svg;
99
  gchar *subtitle_active_png, *subtitle_inactive_png;
100
  gchar *video_stream_toggle_png, *audio_stream_toggle_png;
Andoni Morales's avatar
Andoni Morales committed
101
  gchar *data_dir;
102
  gchar *duration_str;
103

104 105
  GList *uri_list;

106 107
  GtkWidget *window, *box, *clutter_widget;

108 109
  ClutterColor stage_bg_color, text_color, border_color;
  ClutterColor gradient_start, gradient_finish;
110

111
  ClutterActor *stage;
112 113 114
  ClutterActor *texture;
  ClutterActor *control_box;
  ClutterActor *control_bg, *control_title, *control_play_toggle;
115
  ClutterActor *control_seekbar;
116
  ClutterActor *control_pos;
117 118
  ClutterActor *volume_box;
  ClutterActor *volume_low, *volume_high;
119
  ClutterActor *fullscreen_button;
120
  ClutterActor *subtitle_toggle;
121
  ClutterActor *video_stream_toggle, *audio_stream_toggle;
122
  ClutterActor *vol_int, *vol_int_bg, *volume_point;
123
  ClutterActor *info_box;
124
  ClutterActor *pos_n_vol_box;
125
  ClutterActor *main_box;
126

127
  ClutterContent *seek_canvas;
128
  ClutterContent *vol_int_canvas;
129

130
  ClutterLayoutManager *main_box_layout;
131
  ClutterLayoutManager *info_box_layout;
132
  ClutterLayoutManager *pos_n_vol_layout;
133
  ClutterLayoutManager *middle_box_layout;
134

135
  GstEngine *engine;
136
  ScreenSaver *screensaver;
137 138
};

139 140 141 142 143
static const GtkTargetEntry drop_target_table[] = {
  {(gchar *) "text/uri-list", 0, 0}
};


144
// Declaration of non-static functions
145
void interface_init (UserInterface * ui);
146
gboolean interface_is_it_last (UserInterface * ui);
147
gboolean interface_load_uri (UserInterface * ui, gchar * uri);
148 149 150
void interface_on_drop_cb (GtkWidget * widget, GdkDragContext * context, gint x,
    gint y, GtkSelectionData * data, guint info, guint _time,
    UserInterface * ui);
151
void interface_play_next_or_prev (UserInterface * ui, gboolean next);
152
void interface_start (UserInterface * ui, gchar * uri);
153
gboolean interface_update_controls (UserInterface * ui);
154 155 156

G_END_DECLS
#endif /* __USER_INTERFACE_H__ */