[goobox] implemented a GNOME 3 like interface
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goobox] implemented a GNOME 3 like interface
- Date: Wed, 5 Dec 2012 16:22:43 +0000 (UTC)
commit b41c2fefaf0764589d18e3769c6f814287216d94
Author: Paolo Bacchilega <paobac src gnome org>
Date: Wed Dec 5 16:43:35 2012 +0100
implemented a GNOME 3 like interface
data/org.gnome.Goobox.gschema.xml.in | 4 -
src/Makefile.am | 2 +
src/dlg-cover-chooser.c | 12 -
src/dlg-extract.c | 12 -
src/dlg-preferences.c | 12 -
src/dlg-properties.c | 12 -
src/glib-utils.c | 4 +-
src/goo-player-bar.c | 569 ++++++++++++++++++++++++++++++++++
src/goo-player-bar.h | 62 ++++
src/goo-player-info.c | 493 +++++++----------------------
src/goo-player-info.h | 7 +-
src/goo-window.c | 455 ++++++----------------------
src/goo-window.h | 2 -
src/goobox.gresource.xml | 3 +-
src/gth-toggle-menu-action.c | 60 ++++-
src/gth-toggle-menu-action.h | 2 +
src/gth-toggle-menu-tool-button.c | 420 +++++++++++---------------
src/gth-toggle-menu-tool-button.h | 5 +
src/gth-window.c | 319 ++++++++++++++-----
src/gth-window.h | 36 ++-
src/main.c | 6 +-
src/main.h | 5 +-
src/preferences.h | 1 -
src/ui/Makefile.am | 1 +
src/ui/cover-chooser.ui | 27 --
src/ui/extract.ui | 125 ++-------
src/ui/goobox.css | 32 ++
src/ui/menu-toolbars.ui | 12 +-
src/ui/preferences.ui | 47 +---
src/ui/properties.ui | 39 +---
30 files changed, 1419 insertions(+), 1367 deletions(-)
---
diff --git a/data/org.gnome.Goobox.gschema.xml.in b/data/org.gnome.Goobox.gschema.xml.in
index 0cdc19a..959a008 100644
--- a/data/org.gnome.Goobox.gschema.xml.in
+++ b/data/org.gnome.Goobox.gschema.xml.in
@@ -78,10 +78,6 @@
<default>400</default>
<_summary>Window height</_summary>
</key>
- <key name="playlist-visible" type="b">
- <default>true</default>
- <_summary>Playlist visibility</_summary>
- </key>
</schema>
<schema id="org.gnome.Goobox.Playlist" path="/org/gnome/goobox/playlist/">
diff --git a/src/Makefile.am b/src/Makefile.am
index 861716c..dd868fd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -55,6 +55,8 @@ goobox_SOURCES = \
goo-error.h \
goo-player.c \
goo-player.h \
+ goo-player-bar.c \
+ goo-player-bar.h \
goo-player-info.c \
goo-player-info.h \
goo-stock.c \
diff --git a/src/dlg-cover-chooser.c b/src/dlg-cover-chooser.c
index 8491111..d842c45 100644
--- a/src/dlg-cover-chooser.c
+++ b/src/dlg-cover-chooser.c
@@ -374,14 +374,6 @@ start_searching (DialogData *data)
static void
-help_button_clicked_cb (GtkWidget *widget,
- DialogData *data)
-{
- show_help_dialog (GTK_WINDOW (data->window), "search_cover_on_internet");
-}
-
-
-static void
revert_button_clicked_cb (GtkWidget *widget,
DialogData *data)
{
@@ -526,10 +518,6 @@ dlg_cover_chooser (GooWindow *window,
"clicked",
G_CALLBACK (gtk_widget_destroy),
G_OBJECT (data->dialog));
- g_signal_connect (GET_WIDGET ("help_button"),
- "clicked",
- G_CALLBACK (help_button_clicked_cb),
- data);
g_signal_connect (GET_WIDGET ("ok_button"),
"clicked",
G_CALLBACK (ok_button_clicked_cb),
diff --git a/src/dlg-extract.c b/src/dlg-extract.c
index ef235b9..6d7e41d 100644
--- a/src/dlg-extract.c
+++ b/src/dlg-extract.c
@@ -78,14 +78,6 @@ ok_button_clicked_cb (GtkWidget *widget,
}
-static void
-help_button_clicked_cb (GtkWidget *widget,
- DialogData *data)
-{
- show_help_dialog (GTK_WINDOW (data->window), "extract");
-}
-
-
void
dlg_extract_ask (GooWindow *window)
{
@@ -174,10 +166,6 @@ dlg_extract_ask (GooWindow *window)
"clicked",
G_CALLBACK (gtk_widget_destroy),
G_OBJECT (data->dialog));
- g_signal_connect (GET_WIDGET ("help_button"),
- "clicked",
- G_CALLBACK (help_button_clicked_cb),
- data);
g_signal_connect (GET_WIDGET ("ok_button"),
"clicked",
G_CALLBACK (ok_button_clicked_cb),
diff --git a/src/dlg-preferences.c b/src/dlg-preferences.c
index 77bdb4f..cef2cec 100644
--- a/src/dlg-preferences.c
+++ b/src/dlg-preferences.c
@@ -110,14 +110,6 @@ close_button_clicked_cb (GtkWidget *widget,
}
-static void
-help_button_clicked_cb (GtkWidget *widget,
- DialogData *data)
-{
- show_help_dialog (GTK_WINDOW (data->window), "goobox-preferences");
-}
-
-
void dlg_format (DialogData *dialog_data, GooFileFormat format);
@@ -321,10 +313,6 @@ dlg_preferences (GooWindow *window)
"clicked",
G_CALLBACK (close_button_clicked_cb),
data);
- g_signal_connect (GET_WIDGET ("help_button"),
- "clicked",
- G_CALLBACK (help_button_clicked_cb),
- data);
g_signal_connect (GET_WIDGET ("filetype_properties_button"),
"clicked",
G_CALLBACK (filetype_properties_clicked_cb),
diff --git a/src/dlg-properties.c b/src/dlg-properties.c
index 1873720..f5a41f9 100644
--- a/src/dlg-properties.c
+++ b/src/dlg-properties.c
@@ -167,14 +167,6 @@ ok_button_clicked_cb (GtkWidget *widget,
static void
-help_button_clicked_cb (GtkWidget *widget,
- DialogData *data)
-{
- show_help_dialog (GTK_WINDOW (data->window), "properties");
-}
-
-
-static void
set_data_from_album (DialogData *data,
AlbumInfo *album)
{
@@ -547,10 +539,6 @@ dlg_properties (GooWindow *window)
"clicked",
G_CALLBACK (ok_button_clicked_cb),
data);
- g_signal_connect (GET_WIDGET ("help_button"),
- "clicked",
- G_CALLBACK (help_button_clicked_cb),
- data);
g_signal_connect (GET_WIDGET ("search_button"),
"clicked",
G_CALLBACK (search_cb),
diff --git a/src/glib-utils.c b/src/glib-utils.c
index eec0ba0..57fff61 100644
--- a/src/glib-utils.c
+++ b/src/glib-utils.c
@@ -2222,7 +2222,7 @@ _g_format_duration_for_display (gint64 msecs)
* the separator that your locale uses or use "%Id" instead
* of "%d" if your locale uses localized digits.
*/
- return g_strdup_printf (C_("long time format", "%d:%02d:%02d"), hour, min, sec);
+ return g_strdup_printf (C_("long time format", "%dâ%02dâ%02d"), hour, min, sec);
}
/* minutes:seconds */
@@ -2231,5 +2231,5 @@ _g_format_duration_for_display (gint64 msecs)
* separator that your locale uses or use "%Id" instead of
* "%d" if your locale uses localized digits.
*/
- return g_strdup_printf (C_("short time format", "%d:%02d"), min, sec);
+ return g_strdup_printf (C_("short time format", "%dâ%02d"), min, sec);
}
diff --git a/src/goo-player-bar.c b/src/goo-player-bar.c
new file mode 100644
index 0000000..75b036f
--- /dev/null
+++ b/src/goo-player-bar.c
@@ -0,0 +1,569 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * Goo
+ *
+ * Copyright (C) 2012 Free Software Foundation, Inc.
+ *
+ * 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 of the License, 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., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <string.h>
+#include <glib/gi18n.h>
+#include "goo-player-bar.h"
+#include "goo-marshal.h"
+#include "goo-stock.h"
+#include "glib-utils.h"
+#include "gth-toggle-menu-action.h"
+
+
+#define SCALE_WIDTH 150
+#define MIN_WIDTH 500
+#define UPDATE_TIMEOUT 50
+
+
+G_DEFINE_TYPE (GooPlayerBar, goo_player_bar, GTK_TYPE_BOX)
+
+
+struct _GooPlayerBarPrivateData {
+ GooPlayer *player;
+ GtkWidget *time_label;
+ GtkWidget *time_scale;
+ char *current_time;
+ char *total_time;
+ char time[64];
+ gint64 track_length;
+ gboolean dragging;
+ guint update_id;
+ double fraction;
+ guint update_progress_timeout;
+};
+
+
+enum {
+ SKIP_TO,
+ LAST_SIGNAL
+};
+static guint goo_player_bar_signals[LAST_SIGNAL] = { 0 };
+
+
+static void
+goo_player_bar_get_preferred_width (GtkWidget *widget,
+ int *minimum_width,
+ int *natural_width)
+{
+ *minimum_width = *natural_width = MIN_WIDTH;
+}
+
+
+static void
+set_label (GtkWidget *label,
+ const char *format,
+ const char *text)
+{
+ char *e_text;
+ char *markup;
+
+ if ((text == NULL) || (*text == '\0')) {
+ gtk_label_set_text (GTK_LABEL (label), "");
+ gtk_widget_hide (label);
+ return;
+ }
+
+ e_text = g_markup_escape_text (text, -1);
+ markup = g_strdup_printf (format, e_text);
+ g_free (e_text);
+
+ gtk_label_set_markup (GTK_LABEL (label), markup);
+ gtk_widget_show (label);
+
+ g_free (markup);
+}
+
+
+static void
+set_time (GooPlayerBar *self,
+ const char *text)
+{
+ set_label (self->priv->time_label, "%s", text);
+}
+
+
+static void
+_goo_player_bar_set_current_time (GooPlayerBar *self,
+ gint64 current_time)
+{
+ g_free (self->priv->current_time);
+ self->priv->current_time = _g_format_duration_for_display (current_time * 1000);
+ sprintf (self->priv->time, "%s", self->priv->current_time);
+ set_time (self, self->priv->time);
+}
+
+
+static void
+time_scale_value_changed_cb (GtkRange *range,
+ GooPlayerBar *self)
+{
+ double new_value;
+ gint64 current_time;
+
+ new_value = gtk_range_get_value (range);
+ current_time = self->priv->track_length * (new_value / 100.0);
+ _goo_player_bar_set_current_time (self, current_time);
+
+ if (! self->priv->dragging) {
+ int seconds;
+
+ seconds = (int) (new_value * self->priv->track_length);
+ g_signal_emit (self, goo_player_bar_signals[SKIP_TO], 0, seconds);
+ }
+}
+
+
+static gboolean
+update_time_label_cb (gpointer data)
+{
+ GooPlayerBar *self = data;
+ GooPlayerBarPrivateData *priv = self->priv;
+ double new_value = gtk_range_get_value (GTK_RANGE (priv->time_scale));
+ gint64 current_time;
+
+ if (priv->update_id != 0) {
+ g_source_remove (priv->update_id);
+ priv->update_id = 0;
+ }
+
+ current_time = priv->track_length * new_value;
+ _goo_player_bar_set_current_time (self, current_time);
+
+ priv->update_id = g_timeout_add (UPDATE_TIMEOUT,
+ update_time_label_cb,
+ data);
+
+ return FALSE;
+}
+
+
+static gboolean
+time_scale_button_press_cb (GtkRange *range,
+ GdkEventButton *event,
+ GooPlayerBar *self)
+{
+ self->priv->dragging = TRUE;
+ self->priv->update_id = g_timeout_add (UPDATE_TIMEOUT,
+ update_time_label_cb,
+ self);
+ return FALSE;
+}
+
+
+static gboolean
+time_scale_button_release_cb (GtkRange *range,
+ GdkEventButton *event,
+ GooPlayerBar *self)
+{
+ if (self->priv->update_id != 0) {
+ g_source_remove (self->priv->update_id);
+ self->priv->update_id = 0;
+ }
+
+ self->priv->dragging = FALSE;
+ g_signal_emit_by_name (range, "value-changed");
+
+ return FALSE;
+}
+
+
+static void
+goo_player_bar_init (GooPlayerBar *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GOO_TYPE_PLAYER_BAR, GooPlayerBarPrivateData);
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_HORIZONTAL);
+}
+
+
+static GtkWidget *
+_gtk_button_new_from_icon_name (const char *icon_name,
+ GtkIconSize size)
+{
+ GtkWidget *button;
+ GtkWidget *image;
+
+ button = gtk_button_new ();
+ image = gtk_image_new_from_icon_name (icon_name, size);
+ gtk_widget_show (image);
+ gtk_container_add (GTK_CONTAINER (button), image);
+
+ return button;
+}
+
+
+static GtkWidget *
+_gtk_menu_button_new_from_icon_name (const char *icon_name)
+{
+ GtkWidget *button;
+ GtkWidget *image;
+
+ button = gtk_menu_button_new ();
+ image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_SMALL_TOOLBAR);
+ gtk_widget_show (image);
+ gtk_container_add (GTK_CONTAINER (button), image);
+
+ return button;
+}
+
+
+static void
+toggle_play_notify_icon_name_cb (GObject *gobject,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ GtkWidget *button = user_data;
+ GtkWidget *image;
+
+ image = gtk_bin_get_child (GTK_BIN (button));
+ if ((image != NULL) && GTK_IS_IMAGE (image))
+ gtk_image_set_from_icon_name (GTK_IMAGE (image), gtk_action_get_icon_name (GTK_ACTION (gobject)), GTK_ICON_SIZE_LARGE_TOOLBAR);
+}
+
+
+static void
+_gtk_button_sync_with_action (GtkWidget *button,
+ GtkAction *action)
+{
+ gtk_activatable_set_related_action (GTK_ACTIVATABLE (button), action);
+ gtk_widget_set_tooltip_text (button, gtk_action_get_tooltip (action));
+ if (GTK_IS_MENU_BUTTON (button))
+ g_object_set (button,
+ "menu", gth_toggle_menu_action_get_menu (GTH_TOGGLE_MENU_ACTION (action)),
+ NULL);
+}
+
+
+static void
+goo_player_bar_construct (GooPlayerBar *self,
+ GtkActionGroup *actions)
+{
+ GtkWidget *frame;
+ GtkWidget *main_box;
+ GtkWidget *button_box;
+ GtkWidget *time_box;
+ GtkWidget *button;
+ GError *error = NULL;
+
+ gtk_widget_set_can_focus (GTK_WIDGET (self), FALSE);
+ self->priv->dragging = FALSE;
+ self->priv->current_time = NULL;
+ self->priv->total_time = NULL;
+ self->priv->update_id = 0;
+
+ frame = gtk_event_box_new ();
+ gtk_style_context_add_class (gtk_widget_get_style_context (frame), "goobox-player-bar");
+ gtk_widget_show (frame);
+ gtk_box_pack_start (GTK_BOX (self), frame, TRUE, TRUE, 0);
+
+ main_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (main_box), 10);
+ gtk_box_set_spacing (GTK_BOX (main_box), 6);
+ gtk_box_set_homogeneous (GTK_BOX (main_box), FALSE);
+ gtk_widget_show (main_box);
+ gtk_container_add (GTK_CONTAINER (frame), main_box);
+
+ /* Play buttons */
+
+ button_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_style_context_add_class (gtk_widget_get_style_context (button_box), GTK_STYLE_CLASS_LINKED);
+ gtk_box_pack_start (GTK_BOX (main_box), button_box, FALSE, FALSE, 0);
+
+ button = _gtk_button_new_from_icon_name (GOO_STOCK_PREV, GTK_ICON_SIZE_SMALL_TOOLBAR);
+ _gtk_button_sync_with_action (button, gtk_action_group_get_action (actions, "Prev"));
+ gtk_box_pack_start (GTK_BOX (button_box), button, FALSE, FALSE, 0);
+
+ button = _gtk_button_new_from_icon_name (GOO_STOCK_PLAY, GTK_ICON_SIZE_LARGE_TOOLBAR);
+ _gtk_button_sync_with_action (button, gtk_action_group_get_action (actions, "TogglePlay"));
+ g_signal_connect (gtk_action_group_get_action (actions, "TogglePlay"),
+ "notify::icon-name",
+ G_CALLBACK (toggle_play_notify_icon_name_cb),
+ button);
+ gtk_box_pack_start (GTK_BOX (button_box), button, FALSE, FALSE, 0);
+
+ button = _gtk_button_new_from_icon_name (GOO_STOCK_NEXT, GTK_ICON_SIZE_SMALL_TOOLBAR);
+ _gtk_button_sync_with_action (button, gtk_action_group_get_action (actions, "Next"));
+ gtk_box_pack_start (GTK_BOX (button_box), button, FALSE, FALSE, 0);
+
+ /* Time */
+
+ time_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+
+ self->priv->time_scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0.0, 1.0, 0.01);
+ gtk_range_set_increments (GTK_RANGE (self->priv->time_scale), 0.01, 0.1);
+ gtk_scale_set_draw_value (GTK_SCALE (self->priv->time_scale), FALSE);
+ gtk_widget_set_size_request (self->priv->time_scale, SCALE_WIDTH, -1);
+ gtk_widget_set_no_show_all (self->priv->time_scale, TRUE);
+
+ self->priv->time_label = gtk_label_new (NULL);
+ gtk_widget_set_no_show_all (self->priv->time_label, TRUE);
+
+ gtk_box_pack_start (GTK_BOX (time_box), self->priv->time_scale, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (time_box), self->priv->time_label, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (main_box), time_box, TRUE, FALSE, 0);
+
+ /* Other actions */
+
+ button_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_style_context_add_class (gtk_widget_get_style_context (button_box), GTK_STYLE_CLASS_LINKED);
+ gtk_box_pack_end (GTK_BOX (main_box), button_box, FALSE, FALSE, 0);
+
+ button = _gtk_button_new_from_icon_name (GOO_STOCK_EXTRACT, GTK_ICON_SIZE_SMALL_TOOLBAR);
+ _gtk_button_sync_with_action (button, gtk_action_group_get_action (actions, "Extract"));
+ gtk_box_pack_start (GTK_BOX (button_box), button, FALSE, FALSE, 0);
+
+ button = _gtk_menu_button_new_from_icon_name ("emblem-system-symbolic");
+ _gtk_button_sync_with_action (button, gtk_action_group_get_action (actions, "OtherActions"));
+ gtk_box_pack_start (GTK_BOX (button_box), button, FALSE, FALSE, 0);
+
+ /* signals */
+
+ g_signal_connect (self->priv->time_scale,
+ "value_changed",
+ G_CALLBACK (time_scale_value_changed_cb),
+ self);
+ g_signal_connect (self->priv->time_scale,
+ "button_press_event",
+ G_CALLBACK (time_scale_button_press_cb),
+ self);
+ g_signal_connect (self->priv->time_scale,
+ "button_release_event",
+ G_CALLBACK (time_scale_button_release_cb),
+ self);
+}
+
+
+static void
+goo_player_bar_finalize (GObject *object)
+{
+ GooPlayerBar *self;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GOO_IS_PLAYER_BAR (object));
+
+ self = GOO_PLAYER_BAR (object);
+
+ g_free (self->priv->current_time);
+ g_free (self->priv->total_time);
+ if (self->priv->update_id != 0) {
+ g_source_remove (self->priv->update_id);
+ self->priv->update_id = 0;
+ }
+
+ G_OBJECT_CLASS (goo_player_bar_parent_class)->finalize (object);
+}
+
+
+
+static void
+goo_player_bar_class_init (GooPlayerBarClass *class)
+{
+ GObjectClass *gobject_class;
+ GtkWidgetClass *widget_class;
+
+ g_type_class_add_private (class, sizeof (GooPlayerBarPrivateData));
+
+ gobject_class = G_OBJECT_CLASS (class);
+ gobject_class->finalize = goo_player_bar_finalize;
+
+ widget_class = GTK_WIDGET_CLASS (class);
+ widget_class->get_preferred_width = goo_player_bar_get_preferred_width;
+
+ goo_player_bar_signals[SKIP_TO] =
+ g_signal_new ("skip-to",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GooPlayerBarClass, skip_to),
+ NULL, NULL,
+ goo_marshal_VOID__INT,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_INT);
+}
+
+
+static void
+goo_player_bar_set_time (GooPlayerBar *self,
+ gint64 current_time)
+{
+ if (self->priv->dragging)
+ return;
+
+ _goo_player_bar_set_current_time (self, current_time);
+
+ g_signal_handlers_block_by_data (self->priv->time_scale, self);
+ gtk_range_set_value (GTK_RANGE (self->priv->time_scale), (double) current_time / self->priv->track_length);
+ g_signal_handlers_unblock_by_data (self->priv->time_scale, self);
+}
+
+
+static gboolean
+update_progress_cb (gpointer data)
+{
+ GooPlayerBar *self = data;
+
+ if ((self->priv->fraction >= 0.0) && (self->priv->fraction <= 1.0))
+ goo_player_bar_set_time (self, self->priv->fraction * self->priv->track_length);
+
+ return FALSE;
+}
+
+
+static void
+player_progress_cb (GooPlayer *player,
+ double fraction,
+ GooPlayerBar *self)
+{
+ self->priv->fraction = fraction;
+ self->priv->update_progress_timeout = g_idle_add (update_progress_cb, self);
+}
+
+
+static void
+goo_player_bar_set_sensitive (GooPlayerBar *self,
+ gboolean value)
+{
+ /* FIXME */
+}
+
+
+static void
+goo_player_bar_update_state (GooPlayerBar *self)
+{
+ GooPlayerState state;
+
+ if (self->priv->player == NULL)
+ return;
+
+ state = goo_player_get_state (self->priv->player);
+
+ if ((state == GOO_PLAYER_STATE_PLAYING)
+ || (state == GOO_PLAYER_STATE_PAUSED))
+ {
+ gtk_widget_show (self->priv->time_scale);
+ gtk_widget_show (self->priv->time_label);
+ }
+ else {
+ gtk_widget_hide (self->priv->time_scale);
+ gtk_widget_hide (self->priv->time_label);
+ }
+}
+
+
+static void
+goo_player_bar_set_total_time (GooPlayerBar *self,
+ gint64 total_time)
+{
+ g_free (self->priv->total_time);
+ self->priv->total_time = _g_format_duration_for_display (total_time * 1000);
+ goo_player_bar_update_state (self);
+}
+
+
+static void
+player_state_changed_cb (GooPlayer *player,
+ GooPlayerBar *self)
+{
+ goo_player_bar_update_state (self);
+ goo_player_bar_set_sensitive (self, (goo_player_get_state (player) != GOO_PLAYER_STATE_ERROR) && (goo_player_get_discid (player) != NULL));
+}
+
+
+static void
+player_start_cb (GooPlayer *player,
+ GooPlayerAction action,
+ GooPlayerBar *self)
+{
+ goo_player_bar_update_state (self);
+}
+
+
+static void
+player_done_cb (GooPlayer *player,
+ GooPlayerAction action,
+ GError *error,
+ GooPlayerBar *self)
+{
+ AlbumInfo *album;
+
+ switch (action) {
+ case GOO_PLAYER_ACTION_LIST:
+ album = goo_player_get_album (player);
+ goo_player_bar_set_total_time (self, album->total_length);
+ break;
+ case GOO_PLAYER_ACTION_METADATA:
+ goo_player_bar_update_state (self);
+ break;
+ case GOO_PLAYER_ACTION_SEEK_SONG:
+ album = goo_player_get_album (player);
+ self->priv->track_length = album_info_get_track (album, goo_player_get_current_track (player))->length;
+ goo_player_bar_set_total_time (self, self->priv->track_length);
+ break;
+ case GOO_PLAYER_ACTION_PLAY:
+ case GOO_PLAYER_ACTION_STOP:
+ case GOO_PLAYER_ACTION_MEDIUM_REMOVED:
+ goo_player_bar_set_time (self, 0);
+ break;
+ default:
+ break;
+ }
+}
+
+
+GtkWidget *
+goo_player_bar_new (GooPlayer *player,
+ GtkActionGroup *actions)
+{
+ GooPlayerBar *self;
+
+ g_return_val_if_fail (player != NULL, NULL);
+
+ self = GOO_PLAYER_BAR (g_object_new (GOO_TYPE_PLAYER_BAR, NULL));
+ self->priv->player = g_object_ref (player);
+ goo_player_bar_construct (self, actions);
+
+ g_signal_connect (player,
+ "start",
+ G_CALLBACK (player_start_cb),
+ self);
+ g_signal_connect (player,
+ "done",
+ G_CALLBACK (player_done_cb),
+ self);
+ g_signal_connect (player,
+ "progress",
+ G_CALLBACK (player_progress_cb),
+ self);
+ g_signal_connect (player,
+ "state_changed",
+ G_CALLBACK (player_state_changed_cb),
+ self);
+
+ return GTK_WIDGET (self);
+}
+
+
+double
+goo_player_bar_get_progress (GooPlayerBar *self)
+{
+ return self->priv->fraction;
+}
diff --git a/src/goo-player-bar.h b/src/goo-player-bar.h
new file mode 100644
index 0000000..00d80fc
--- /dev/null
+++ b/src/goo-player-bar.h
@@ -0,0 +1,62 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * Goo
+ *
+ * Copyright (C) 2012 Free Software Foundation, Inc.
+ *
+ * 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 of the License, 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., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef GOO_PLAYER_BAR_H
+#define GOO_PLAYER_BAR_H
+
+#include <gtk/gtk.h>
+#include "goo-player.h"
+
+#define GOO_TYPE_PLAYER_BAR (goo_player_bar_get_type ())
+#define GOO_PLAYER_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GOO_TYPE_PLAYER_BAR, GooPlayerBar))
+#define GOO_PLAYER_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GOO_TYPE_PLAYER_BAR, GooPlayerBarClass))
+#define GOO_IS_PLAYER_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GOO_TYPE_PLAYER_BAR))
+#define GOO_IS_PLAYER_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GOO_TYPE_PLAYER_BAR))
+#define GOO_PLAYER_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GOO_TYPE_PLAYER_BAR, GooPlayerBarClass))
+
+typedef struct _GooPlayerBar GooPlayerBar;
+typedef struct _GooPlayerBarClass GooPlayerBarClass;
+typedef struct _GooPlayerBarPrivateData GooPlayerBarPrivateData;
+
+struct _GooPlayerBar
+{
+ GtkBox __parent;
+ GooPlayerBarPrivateData *priv;
+};
+
+struct _GooPlayerBarClass
+{
+ GtkBoxClass __parent_class;
+
+ /*<signals>*/
+
+ void (*skip_to) (GooPlayerBar *info,
+ int seconds);
+
+};
+
+GType goo_player_bar_get_type (void);
+GtkWidget * goo_player_bar_new (GooPlayer *player,
+ GtkActionGroup *actions);
+double goo_player_bar_get_progress (GooPlayerBar *info);
+
+#endif /* GOO_PLAYER_BAR_H */
diff --git a/src/goo-player-info.c b/src/goo-player-info.c
index caed7f7..36ee827 100644
--- a/src/goo-player-info.c
+++ b/src/goo-player-info.c
@@ -29,12 +29,10 @@
#include "goo-window.h"
#include "glib-utils.h"
-#define SPACING 0
-#define TITLE1_FORMAT "<span size='large' weight='bold'>%s</span>"
+#define TITLE1_FORMAT "<span size='large'>%s</span>"
#define TITLE2_FORMAT "%s"
-#define TITLE3_FORMAT "<i>%s</i>"
+#define TITLE3_FORMAT "%s"
#define TIME_FORMAT "%s"
-#define PLAYING_FORMAT "[ <small>%s</small> ]"
#define SCALE_WIDTH 150
#define COVER_SIZE 80
#define TRAY_COVER_SIZE 80
@@ -44,21 +42,21 @@
#define MIN_CHARS 45
#define UPDATE_TIMEOUT 50
+
+G_DEFINE_TYPE (GooPlayerInfo, goo_player_info, GTK_TYPE_BOX)
+
+
struct _GooPlayerInfoPrivateData {
GooWindow *window;
- gboolean interactive;
GtkWidget *cover_frame;
GtkWidget *title1_label;
GtkWidget *title2_label;
GtkWidget *title3_label;
GtkWidget *time_label;
- GtkWidget *playing_label;
- GtkWidget *time_scale;
GtkWidget *cover_image;
GtkWidget *cover_button;
GtkWidget *status_image;
GtkWidget *notebook;
- char *current_time;
char *total_time;
char time[64];
gint64 track_length;
@@ -69,26 +67,23 @@ struct _GooPlayerInfoPrivateData {
guint update_progress_timeout;
};
+
enum {
COVER_CLICKED,
- SKIP_TO,
LAST_SIGNAL
};
-static guint goo_player_info_signals[LAST_SIGNAL] = { 0 };
+enum {
+ TARGET_URL
+};
+
-enum { TARGET_URL };
+static guint goo_player_info_signals[LAST_SIGNAL] = { 0 };
static GtkTargetEntry target_table[] = {
{ "text/uri-list", 0, TARGET_URL }
};
static guint n_targets = sizeof (target_table) / sizeof (target_table[0]);
-static void goo_player_info_finalize (GObject *object);
-
-#define GOO_PLAYER_INFO_GET_PRIVATE_DATA(object) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((object), GOO_TYPE_PLAYER_INFO, GooPlayerInfoPrivateData))
-
-G_DEFINE_TYPE (GooPlayerInfo, goo_player_info, GTK_TYPE_BOX)
static void
goo_player_info_get_preferred_width (GtkWidget *widget,
@@ -97,55 +92,16 @@ goo_player_info_get_preferred_width (GtkWidget *widget,
{
GooPlayerInfo *info = GOO_PLAYER_INFO (widget);
- if (info->priv->interactive)
- *minimum_width = *natural_width = MIN_WIDTH;
- else
- *minimum_width = *natural_width = MIN_TOOLTIP_WIDTH;
-}
-
-
-static void
-goo_player_info_class_init (GooPlayerInfoClass *class)
-{
- GObjectClass *gobject_class;
- GtkWidgetClass *widget_class;
-
- goo_player_info_signals[COVER_CLICKED] =
- g_signal_new ("cover_clicked",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GooPlayerInfoClass, cover_clicked),
- NULL, NULL,
- goo_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
- goo_player_info_signals[SKIP_TO] =
- g_signal_new ("skip_to",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GooPlayerInfoClass, skip_to),
- NULL, NULL,
- goo_marshal_VOID__INT,
- G_TYPE_NONE,
- 1,
- G_TYPE_INT);
-
- gobject_class = G_OBJECT_CLASS (class);
- gobject_class->finalize = goo_player_info_finalize;
-
- widget_class = GTK_WIDGET_CLASS (class);
- widget_class->get_preferred_width = goo_player_info_get_preferred_width;
-
- g_type_class_add_private (class, sizeof (GooPlayerInfoPrivateData));
+ *minimum_width = *natural_width = MIN_WIDTH;
}
static void
-set_label (GtkWidget *label,
- const char *format,
- const char *text)
+set_label (GtkWidget *label,
+ const char *format,
+ const char *text)
{
- char *e_text;
+ char *esc;
char *markup;
if ((text == NULL) || (*text == '\0')) {
@@ -154,14 +110,13 @@ set_label (GtkWidget *label,
return;
}
- e_text = g_markup_escape_text (text, -1);
- markup = g_strdup_printf (format, e_text);
- g_free (e_text);
-
+ esc = g_markup_escape_text (text, -1);
+ markup = g_strdup_printf (format, esc);
gtk_label_set_markup (GTK_LABEL (label), markup);
gtk_widget_show (label);
g_free (markup);
+ g_free (esc);
}
@@ -190,103 +145,14 @@ set_title3 (GooPlayerInfo *info,
static void
-set_playing (GooPlayerInfo *info,
- const char *text)
-{
- set_label (info->priv->playing_label, PLAYING_FORMAT, text);
-}
-
-
-static void
-set_time (GooPlayerInfo *info,
- const char *text)
+set_total_time (GooPlayerInfo *info,
+ const char *text)
{
set_label (info->priv->time_label, TIME_FORMAT, text);
}
static void
-time_scale_value_changed_cb (GtkRange *range,
- GooPlayerInfo *info)
-{
- double new_value;
- gint64 current_time;
-
- new_value = gtk_range_get_value (range);
- current_time = info->priv->track_length * (new_value / 100.0);
- g_free (info->priv->current_time);
- info->priv->current_time = _g_format_duration_for_display (current_time * 1000);
- /* translators: this is the current_time / total_time label */
- sprintf (info->priv->time, _("%s / %s"), info->priv->total_time, info->priv->current_time);
- set_time (info, info->priv->time);
-
- if (! info->priv->dragging) {
- int seconds;
-
- seconds = (int) (new_value * info->priv->track_length);
- g_signal_emit (info, goo_player_info_signals[SKIP_TO], 0, seconds);
- }
-}
-
-
-static gboolean
-update_time_label_cb (gpointer data)
-{
- GooPlayerInfo *info = data;
- GooPlayerInfoPrivateData *priv = info->priv;
- double new_value = gtk_range_get_value (GTK_RANGE (priv->time_scale));
- gint64 current_time;
-
- if (priv->update_id != 0) {
- g_source_remove (priv->update_id);
- priv->update_id = 0;
- }
-
- current_time = priv->track_length * new_value;
- g_free (info->priv->current_time);
- info->priv->current_time = _g_format_duration_for_display (current_time * 1000);
- sprintf (priv->time, _("%s / %s"), priv->current_time, priv->total_time);
- set_time (info, priv->time);
-
- priv->update_id = g_timeout_add (UPDATE_TIMEOUT,
- update_time_label_cb,
- data);
-
- return FALSE;
-}
-
-
-static gboolean
-time_scale_button_press_cb (GtkRange *range,
- GdkEventButton *event,
- GooPlayerInfo *info)
-{
- info->priv->dragging = TRUE;
- info->priv->update_id = g_timeout_add (UPDATE_TIMEOUT,
- update_time_label_cb,
- info);
- return FALSE;
-}
-
-
-static gboolean
-time_scale_button_release_cb (GtkRange *range,
- GdkEventButton *event,
- GooPlayerInfo *info)
-{
- if (info->priv->update_id != 0) {
- g_source_remove (info->priv->update_id);
- info->priv->update_id = 0;
- }
-
- info->priv->dragging = FALSE;
- g_signal_emit_by_name (range, "value-changed");
-
- return FALSE;
-}
-
-
-static void
cover_button_clicked_cb (GtkWidget *button,
GooPlayerInfo *info)
{
@@ -330,125 +196,89 @@ cover_button_drag_data_received (GtkWidget *widget,
static void
-goo_player_info_init (GooPlayerInfo *info)
-{
- gtk_orientable_set_orientation (GTK_ORIENTABLE (info), GTK_ORIENTATION_HORIZONTAL);
- info->priv = GOO_PLAYER_INFO_GET_PRIVATE_DATA (info);
-}
-
-
-static void goo_player_info_update_state (GooPlayerInfo *info);
-
-
-static void
goo_player_info_construct (GooPlayerInfo *info)
{
GooPlayerInfoPrivateData *priv;
- GtkWidget *vbox, *time_box;
+ GtkWidget *vbox;
priv = info->priv;
priv->dragging = FALSE;
- priv->current_time = NULL;
priv->total_time = NULL;
priv->update_id = 0;
+ gtk_widget_set_margin_top (GTK_WIDGET (info), 10);
+ gtk_widget_set_margin_right (GTK_WIDGET (info), 10);
+ gtk_widget_set_margin_bottom (GTK_WIDGET (info), 10);
+ gtk_widget_set_margin_left (GTK_WIDGET (info), 10);
+
gtk_widget_set_can_focus (GTK_WIDGET (info), FALSE);
- gtk_box_set_spacing (GTK_BOX (info), SPACING);
+ gtk_box_set_spacing (GTK_BOX (info), 12);
gtk_box_set_homogeneous (GTK_BOX (info), FALSE);
/* Title and Artist */
priv->title1_label = gtk_label_new (NULL);
+ gtk_style_context_add_class (gtk_widget_get_style_context (priv->title1_label), "goobox-info-album");
gtk_misc_set_alignment (GTK_MISC (priv->title1_label), 0.0, 0.5);
gtk_widget_set_margin_top (priv->title1_label, 6);
priv->title2_label = gtk_label_new (NULL);
+ gtk_style_context_add_class (gtk_widget_get_style_context (priv->title2_label), "goobox-info-artist");
gtk_misc_set_alignment (GTK_MISC (priv->title2_label), 0.0, 0.5);
- gtk_label_set_selectable (GTK_LABEL (priv->title2_label), priv->interactive);
+ gtk_label_set_selectable (GTK_LABEL (priv->title2_label), TRUE);
priv->title3_label = gtk_label_new (NULL);
+ gtk_style_context_add_class (gtk_widget_get_style_context (priv->title3_label), "goobox-info-track");
gtk_misc_set_alignment (GTK_MISC (priv->title3_label), 0.0, 0.5);
- gtk_label_set_selectable (GTK_LABEL (priv->title3_label), priv->interactive);
+ gtk_label_set_selectable (GTK_LABEL (priv->title3_label), TRUE);
+
+ priv->time_label = gtk_label_new (NULL);
+ gtk_style_context_add_class (gtk_widget_get_style_context (priv->time_label), "goobox-info-time");
+ gtk_misc_set_alignment (GTK_MISC (priv->time_label), 0.0, 0.5);
+ gtk_label_set_selectable (GTK_LABEL (priv->time_label), TRUE);
- gtk_label_set_ellipsize (GTK_LABEL (priv->title1_label),
- PANGO_ELLIPSIZE_END);
+ gtk_label_set_ellipsize (GTK_LABEL (priv->title1_label), PANGO_ELLIPSIZE_END);
gtk_label_set_width_chars (GTK_LABEL (priv->title2_label), MIN_CHARS);
- gtk_label_set_ellipsize (GTK_LABEL (priv->title2_label),
- PANGO_ELLIPSIZE_END);
+ gtk_label_set_ellipsize (GTK_LABEL (priv->title2_label), PANGO_ELLIPSIZE_END);
gtk_label_set_width_chars (GTK_LABEL (priv->title2_label), MIN_CHARS);
- gtk_label_set_ellipsize (GTK_LABEL (priv->title3_label),
- PANGO_ELLIPSIZE_END);
+ gtk_label_set_ellipsize (GTK_LABEL (priv->title3_label), PANGO_ELLIPSIZE_END);
gtk_label_set_width_chars (GTK_LABEL (priv->title3_label), MIN_CHARS);
- /* Time */
-
- time_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
- gtk_widget_set_margin_bottom (time_box, 6);
-
- priv->time_scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0.0, 1.0, 0.01);
- gtk_range_set_increments (GTK_RANGE (priv->time_scale), 0.01, 0.1);
- gtk_scale_set_draw_value (GTK_SCALE (priv->time_scale), FALSE);
- gtk_widget_set_size_request (priv->time_scale, SCALE_WIDTH, -1);
- /* gtk_range_set_update_policy (GTK_RANGE (priv->time_scale), GTK_UPDATE_DISCONTINUOUS); FIXME */
- gtk_widget_set_no_show_all (priv->time_scale, TRUE);
-
- priv->time_label = gtk_label_new (NULL);
- gtk_widget_set_no_show_all (priv->time_label, TRUE);
-
- priv->playing_label = gtk_label_new (NULL);
- gtk_widget_set_no_show_all (priv->playing_label, TRUE);
-
- gtk_box_pack_start (GTK_BOX (time_box), priv->time_scale, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (time_box), priv->time_label, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (time_box), priv->playing_label, FALSE, FALSE, 0);
-
/* Image */
+ priv->cover_button = gtk_button_new ();
+ gtk_button_set_relief (GTK_BUTTON (priv->cover_button),
+ GTK_RELIEF_NONE);
- if (priv->interactive) {
- priv->cover_button = gtk_button_new ();
- gtk_button_set_relief (GTK_BUTTON (priv->cover_button),
- GTK_RELIEF_NONE);
-
- gtk_widget_set_tooltip_text (GTK_WIDGET (priv->cover_button),
- _("Click here to choose a cover for this CD"));
-
- g_signal_connect (G_OBJECT (priv->cover_button),
- "clicked",
- G_CALLBACK (cover_button_clicked_cb),
- info);
- gtk_drag_dest_set (priv->cover_button,
- GTK_DEST_DEFAULT_ALL,
- target_table, n_targets,
- GDK_ACTION_COPY);
- g_signal_connect (G_OBJECT (priv->cover_button),
- "drag_data_received",
- G_CALLBACK (cover_button_drag_data_received),
- info);
- }
+ gtk_widget_set_tooltip_text (GTK_WIDGET (priv->cover_button),
+ _("Click here to choose a cover for this CD"));
+
+ g_signal_connect (G_OBJECT (priv->cover_button),
+ "clicked",
+ G_CALLBACK (cover_button_clicked_cb),
+ info);
+ gtk_drag_dest_set (priv->cover_button,
+ GTK_DEST_DEFAULT_ALL,
+ target_table, n_targets,
+ GDK_ACTION_COPY);
+ g_signal_connect (G_OBJECT (priv->cover_button),
+ "drag_data_received",
+ G_CALLBACK (cover_button_drag_data_received),
+ info);
priv->cover_image = gtk_image_new_from_stock (GOO_STOCK_NO_DISC, GTK_ICON_SIZE_DIALOG);
- if (priv->interactive)
- gtk_widget_set_size_request (priv->cover_image, COVER_SIZE, COVER_SIZE);
- else
- gtk_widget_set_size_request (priv->cover_image, TRAY_COVER_SIZE, TRAY_COVER_SIZE);
+ gtk_widget_set_size_request (priv->cover_image, COVER_SIZE, COVER_SIZE);
gtk_widget_show (priv->cover_image);
- if (priv->interactive)
- gtk_container_add (GTK_CONTAINER (priv->cover_button), priv->cover_image);
- else
- priv->cover_button = priv->cover_image;
+ gtk_container_add (GTK_CONTAINER (priv->cover_button), priv->cover_image);
/* Status image */
priv->status_image = gtk_image_new_from_stock (GOO_STOCK_NO_DISC, GTK_ICON_SIZE_DIALOG);
- if (priv->interactive)
- gtk_widget_set_size_request (priv->status_image, COVER_SIZE, COVER_SIZE);
- else
- gtk_widget_set_size_request (priv->status_image, TRAY_COVER_SIZE, TRAY_COVER_SIZE);
+ gtk_widget_set_size_request (priv->status_image, COVER_SIZE, COVER_SIZE);
gtk_widget_show (priv->cover_image);
/*gtk_container_set_border_width (GTK_CONTAINER (priv->status_image), 6);*/
@@ -464,9 +294,8 @@ goo_player_info_construct (GooPlayerInfo *info)
gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), priv->cover_button, NULL);
priv->cover_frame = gtk_frame_new (NULL);
- gtk_container_set_border_width (GTK_CONTAINER (priv->cover_frame), 6);
- if (! priv->interactive)
- gtk_frame_set_shadow_type (GTK_FRAME (priv->cover_frame), GTK_SHADOW_ETCHED_IN);
+ gtk_style_context_add_class (gtk_widget_get_style_context (priv->cover_frame), "goobox-cover-frame");
+ gtk_container_set_border_width (GTK_CONTAINER (priv->cover_frame), 0);
gtk_widget_show (priv->cover_frame);
gtk_container_add (GTK_CONTAINER (priv->cover_frame), priv->notebook);
@@ -475,29 +304,14 @@ goo_player_info_construct (GooPlayerInfo *info)
/**/
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 0);
gtk_box_pack_start (GTK_BOX (vbox), priv->title1_label, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), priv->title2_label, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), priv->title3_label, FALSE, FALSE, 0);
- gtk_box_pack_end (GTK_BOX (vbox), time_box, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), priv->time_label, FALSE, FALSE, 0);
gtk_widget_show (vbox);
gtk_box_pack_start (GTK_BOX (info), vbox, TRUE, TRUE, 0);
-
- /**/
-
- g_signal_connect (priv->time_scale,
- "value_changed",
- G_CALLBACK (time_scale_value_changed_cb),
- info);
- g_signal_connect (priv->time_scale,
- "button_press_event",
- G_CALLBACK (time_scale_button_press_cb),
- info);
- g_signal_connect (priv->time_scale,
- "button_release_event",
- G_CALLBACK (time_scale_button_release_cb),
- info);
}
@@ -510,14 +324,10 @@ goo_player_info_finalize (GObject *object)
g_return_if_fail (GOO_IS_PLAYER_INFO (object));
info = GOO_PLAYER_INFO (object);
- if (info->priv != NULL) {
- g_free (info->priv->current_time);
- g_free (info->priv->total_time);
- if (info->priv->update_id != 0) {
- g_source_remove (info->priv->update_id);
- info->priv->update_id = 0;
- }
- info->priv = NULL;
+ g_free (info->priv->total_time);
+ if (info->priv->update_id != 0) {
+ g_source_remove (info->priv->update_id);
+ info->priv->update_id = 0;
}
G_OBJECT_CLASS (goo_player_info_parent_class)->finalize (object);
@@ -525,59 +335,6 @@ goo_player_info_finalize (GObject *object)
static void
-goo_player_info_set_time (GooPlayerInfo *info,
- gint64 current_time)
-{
- if (info->priv->dragging)
- return;
-
- g_free (info->priv->current_time);
- info->priv->current_time = _g_format_duration_for_display (current_time * 1000);
- sprintf (info->priv->time, _("%s / %s"), info->priv->current_time, info->priv->total_time);
- set_time (info, info->priv->time);
-
- g_signal_handlers_block_by_data (info->priv->time_scale, info);
- gtk_range_set_value (GTK_RANGE (info->priv->time_scale), (double) current_time / info->priv->track_length);
- g_signal_handlers_unblock_by_data (info->priv->time_scale, info);
-
- /* FIXME: this doesn't update the tooltip
- gtk_tooltip_trigger_tooltip_query (gdk_screen_get_display (gtk_status_icon_get_screen (goo_window_get_status_icon (info->priv->window))));
- */
-}
-
-
-static gboolean
-update_progress_cb (gpointer data)
-{
- GooPlayerInfo *info = data;
-
- if ((info->priv->fraction < 0.0) || (info->priv->fraction > 1.0))
- /* nothing */;
- else
- goo_player_info_set_time (info, info->priv->fraction * info->priv->track_length);
-
- return FALSE;
-}
-
-
-static void
-player_progress_cb (GooPlayer *player,
- double fraction,
- GooPlayerInfo *info)
-{
- info->priv->fraction = fraction;
- info->priv->update_progress_timeout = g_idle_add (update_progress_cb, info);
-}
-
-
-double
-goo_player_info_get_progress (GooPlayerInfo *info)
-{
- return info->priv->fraction;
-}
-
-
-static void
update_subtitle (GooPlayerInfo *info,
TrackInfo *track)
{
@@ -587,14 +344,14 @@ update_subtitle (GooPlayerInfo *info,
if ((album->title == NULL) || (album->artist == NULL)) {
g_free (info->priv->total_time);
- info->priv->total_time = _g_format_duration_for_display (track->length * 1000);
+ info->priv->total_time = (track->length > 0) ? _g_format_duration_for_display (track->length * 1000) : NULL;
set_title2 (info, info->priv->total_time);
}
else {
set_title2 (info, album->artist);
set_title3 (info, album->title);
- gtk_label_set_selectable (GTK_LABEL (info->priv->title2_label), info->priv->interactive);
- gtk_label_set_selectable (GTK_LABEL (info->priv->title3_label), info->priv->interactive);
+ gtk_label_set_selectable (GTK_LABEL (info->priv->title2_label), TRUE);
+ gtk_label_set_selectable (GTK_LABEL (info->priv->title3_label), TRUE);
}
}
@@ -644,6 +401,7 @@ goo_player_info_update_state (GooPlayerInfo *info)
if (info->priv->window == NULL)
return;
+
player = goo_window_get_player (info->priv->window);
if (player == NULL)
return;
@@ -651,24 +409,12 @@ goo_player_info_update_state (GooPlayerInfo *info)
state = goo_player_get_state (player);
album = goo_window_get_album (info->priv->window);
- if ((state == GOO_PLAYER_STATE_PLAYING)
- || (state == GOO_PLAYER_STATE_PAUSED))
- {
- if (info->priv->interactive)
- gtk_widget_show (priv->time_scale);
- gtk_widget_show (priv->time_label);
- gtk_widget_show (priv->playing_label);
- }
- else {
- gtk_widget_hide (priv->time_scale);
- gtk_widget_hide (priv->time_label);
- gtk_widget_hide (priv->playing_label);
- }
-
gtk_label_set_selectable (GTK_LABEL (priv->title1_label), FALSE);
gtk_label_set_selectable (GTK_LABEL (priv->title2_label), FALSE);
gtk_label_set_selectable (GTK_LABEL (priv->title3_label), FALSE);
+ set_total_time (info, priv->total_time);
+
if ((state == GOO_PLAYER_STATE_ERROR) || (state == GOO_PLAYER_STATE_NO_DISC))
{
show_simple_text (info, _("No disc"));
@@ -677,27 +423,7 @@ goo_player_info_update_state (GooPlayerInfo *info)
show_simple_text (info, _("Data disc"));
}
else {
- TrackInfo *track;
-
- track = album_info_get_track (album, goo_player_get_current_track (player));
-
- if (track != NULL) {
- char *state_s = "";
-
- show_all_labels (info);
-
- priv->track_length = track->length;
-
- if (state == GOO_PLAYER_STATE_PAUSED)
- state_s = _("Paused");
- set_playing (info, state_s);
-
- set_title1 (info, track->title);
- gtk_label_set_selectable (GTK_LABEL (priv->title1_label), info->priv->interactive);
-
- update_subtitle (info, track);
- }
- else if (state == GOO_PLAYER_STATE_EJECTING) {
+ if (state == GOO_PLAYER_STATE_EJECTING) {
show_simple_text (info, _("Ejecting CD"));
}
else if (state == GOO_PLAYER_STATE_UPDATING) {
@@ -723,20 +449,18 @@ goo_player_info_update_state (GooPlayerInfo *info)
year[0] = '\0';
set_title1 (info, album->title);
- gtk_label_set_selectable (GTK_LABEL (priv->title1_label), info->priv->interactive);
+ gtk_label_set_selectable (GTK_LABEL (priv->title1_label), TRUE);
if (album->artist != NULL) {
set_title2 (info, album->artist);
set_title3 (info, year);
- gtk_label_set_selectable (GTK_LABEL (priv->title2_label), info->priv->interactive);
+ gtk_label_set_selectable (GTK_LABEL (priv->title2_label), TRUE);
}
else {
set_title2 (info, year);
set_title3 (info, "");
}
}
-
- track_info_unref (track);
}
}
@@ -774,7 +498,7 @@ goo_player_info_set_total_time (GooPlayerInfo *info,
GooPlayerInfoPrivateData *priv = info->priv;
g_free (priv->total_time);
- priv->total_time = _g_format_duration_for_display (total_time * 1000);
+ priv->total_time = (total_time > 0) ? _g_format_duration_for_display (total_time * 1000) : NULL;
goo_player_info_update_state (info);
}
@@ -794,17 +518,8 @@ player_done_cb (GooPlayer *player,
goo_player_info_set_total_time (info, album->total_length);
break;
case GOO_PLAYER_ACTION_METADATA:
- goo_player_info_update_state (info);
- break;
case GOO_PLAYER_ACTION_SEEK_SONG:
goo_player_info_update_state (info);
- album = goo_player_get_album (player);
- goo_player_info_set_total_time (info, album_info_get_track (album, goo_player_get_current_track (player))->length);
- break;
- case GOO_PLAYER_ACTION_PLAY:
- case GOO_PLAYER_ACTION_STOP:
- case GOO_PLAYER_ACTION_MEDIUM_REMOVED:
- goo_player_info_set_time (info, 0);
break;
default:
break;
@@ -852,9 +567,6 @@ goo_player_info_set_cover (GooPlayerInfo *info,
else
goo_player_info_set_cover (info, "audio-cd");
}
-
- if (! info->priv->interactive)
- gtk_frame_set_shadow_type (GTK_FRAME (info->priv->cover_frame), cover_set ? GTK_SHADOW_NONE : GTK_SHADOW_ETCHED_IN);
}
@@ -888,9 +600,42 @@ window_update_cover_cb (GooWindow *window,
}
+static void
+goo_player_info_class_init (GooPlayerInfoClass *class)
+{
+ GObjectClass *gobject_class;
+ GtkWidgetClass *widget_class;
+
+ g_type_class_add_private (class, sizeof (GooPlayerInfoPrivateData));
+
+ gobject_class = G_OBJECT_CLASS (class);
+ gobject_class->finalize = goo_player_info_finalize;
+
+ widget_class = GTK_WIDGET_CLASS (class);
+ widget_class->get_preferred_width = goo_player_info_get_preferred_width;
+
+ goo_player_info_signals[COVER_CLICKED] =
+ g_signal_new ("cover_clicked",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GooPlayerInfoClass, cover_clicked),
+ NULL, NULL,
+ goo_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+}
+
+
+static void
+goo_player_info_init (GooPlayerInfo *info)
+{
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (info), GTK_ORIENTATION_HORIZONTAL);
+ info->priv = G_TYPE_INSTANCE_GET_PRIVATE (info, GOO_TYPE_PLAYER_INFO, GooPlayerInfoPrivateData);
+}
+
+
GtkWidget *
-goo_player_info_new (GooWindow *window,
- gboolean interactive)
+goo_player_info_new (GooWindow *window)
{
GooPlayerInfo *info;
GooPlayer *player;
@@ -903,14 +648,12 @@ goo_player_info_new (GooWindow *window,
info = GOO_PLAYER_INFO (g_object_new (GOO_TYPE_PLAYER_INFO, NULL));
info->priv->window = window;
- info->priv->interactive = interactive;
goo_player_info_construct (info);
g_signal_connect (window,
"update_cover",
G_CALLBACK (window_update_cover_cb),
info);
-
g_signal_connect (player,
"start",
G_CALLBACK (player_start_cb),
@@ -920,10 +663,6 @@ goo_player_info_new (GooWindow *window,
G_CALLBACK (player_done_cb),
info);
g_signal_connect (player,
- "progress",
- G_CALLBACK (player_progress_cb),
- info);
- g_signal_connect (player,
"state_changed",
G_CALLBACK (player_state_changed_cb),
info);
diff --git a/src/goo-player-info.h b/src/goo-player-info.h
index 8920beb..a0ebbcc 100644
--- a/src/goo-player-info.h
+++ b/src/goo-player-info.h
@@ -50,15 +50,10 @@ struct _GooPlayerInfoClass
/*<signals>*/
void (*cover_clicked) (GooPlayerInfo *info);
- void (*skip_to) (GooPlayerInfo *info,
- int seconds);
-
};
GType goo_player_info_get_type (void);
-GtkWidget * goo_player_info_new (GooWindow *window,
- gboolean interactive);
-double goo_player_info_get_progress (GooPlayerInfo *info);
+GtkWidget * goo_player_info_new (GooWindow *window);
GdkPixbuf * goo_player_info_get_cover (GooPlayerInfo *info);
#endif /* GOO_PLAYER_INFO_H */
diff --git a/src/goo-window.c b/src/goo-window.c
index 0407dbb..20b2119 100644
--- a/src/goo-window.c
+++ b/src/goo-window.c
@@ -33,9 +33,10 @@
#include "goo-marshal.h"
#include "goo-stock.h"
#include "goo-player.h"
+#include "goo-player-bar.h"
#include "goo-player-info.h"
#include "goo-window.h"
-#include "gth-toggle-menu-tool-button.h"
+#include "gth-toggle-menu-action.h"
#include "gth-user-dir.h"
#include "gtk-utils.h"
#include "gtk-file-chooser-preview.h"
@@ -64,8 +65,6 @@ struct _GooWindowPrivate {
GtkUIManager *ui;
GtkWidget *list_view;
GtkListStore *list_store;
- GtkWidget *toolbar;
- GtkWidget *list_expander;
GtkWidget *list_scrolled_window;
GtkTreeViewColumn *author_column;
@@ -74,11 +73,9 @@ struct _GooWindowPrivate {
GtkWidget *file_popup_menu;
GtkWidget *cover_popup_menu;
- GtkWidget *status_icon_popup_menu;
- GtkStatusIcon *status_icon;
- GtkWidget *status_tooltip_content;
GtkWidget *info;
+ GtkWidget *player_bar;
guint help_message_cid;
guint list_info_cid;
@@ -309,12 +306,12 @@ window_update_size (GooWindow *window)
GdkGeometry hints;
window_height_without_playlist = 0;
- vbox = gth_window_attach_get_content (GTH_WINDOW (window), 0);
+ vbox = gth_window_get_content (GTH_WINDOW (window), 0);
for (scan = gtk_container_get_children (GTK_CONTAINER (vbox)); scan; scan = scan->next) {
GtkWidget *child = scan->data;
GtkAllocation allocation;
- if (child == window->priv->list_expander)
+ if (child == window->priv->list_scrolled_window)
continue;
gtk_widget_get_allocation (child, &allocation);
@@ -375,7 +372,7 @@ goo_window_update_list (GooWindow *window)
/**/
- gtk_expander_set_expanded (GTK_EXPANDER (window->priv->list_expander), (window->priv->album->tracks != NULL));
+ gtk_widget_set_visible (window->priv->list_scrolled_window, (window->priv->album->tracks != NULL));
/**/
@@ -509,11 +506,6 @@ goo_window_finalize (GObject *object)
window->priv->cover_popup_menu = NULL;
}
- if (window->priv->status_icon_popup_menu != NULL) {
- gtk_widget_destroy (window->priv->status_icon_popup_menu);
- window->priv->status_icon_popup_menu = NULL;
- }
-
g_signal_handlers_disconnect_by_data (window->priv->player, window);
g_object_unref (window->priv->player);
@@ -541,7 +533,7 @@ add_columns (GooWindow *window,
/* The Number column. */
column = gtk_tree_view_column_new ();
- gtk_tree_view_column_set_title (column, _("#"));
+ /*gtk_tree_view_column_set_title (column, _("#"));*/
renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_column_pack_start (column,
@@ -566,7 +558,7 @@ add_columns (GooWindow *window,
/* Title */
column = gtk_tree_view_column_new ();
- gtk_tree_view_column_set_title (column, _("Title"));
+ /*gtk_tree_view_column_set_title (column, _("Title"));*/
gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_column_set_expand (column, TRUE);
@@ -589,7 +581,7 @@ add_columns (GooWindow *window,
/* Author */
window->priv->author_column = column = gtk_tree_view_column_new ();
- gtk_tree_view_column_set_title (column, _("Artist"));
+ /*gtk_tree_view_column_set_title (column, _("Artist"));*/
gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
gtk_tree_view_column_set_resizable (column, FALSE);
gtk_tree_view_column_set_expand (column, TRUE);
@@ -613,7 +605,7 @@ add_columns (GooWindow *window,
/* Time */
column = gtk_tree_view_column_new ();
- gtk_tree_view_column_set_title (column, _("Length"));
+ /*gtk_tree_view_column_set_title (column, _("Length"));*/
gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
gtk_tree_view_column_set_resizable (column, FALSE);
gtk_tree_view_column_set_sort_column_id (column, COLUMN_TIME);
@@ -630,18 +622,6 @@ add_columns (GooWindow *window,
static void
-pref_view_playlist_changed (GSettings *settings,
- const char *key,
- gpointer user_data)
-{
- GooWindow *window = user_data;
-
- g_return_if_fail (window != NULL);
- gtk_expander_set_expanded (GTK_EXPANDER (window->priv->list_expander), g_settings_get_boolean (settings, key));
-}
-
-
-static void
print_playlist (GooWindow *window)
{
GList *scan;
@@ -865,10 +845,7 @@ goo_window_unrealize (GtkWidget *widget)
/* save ui preferences. */
- playlist_visible = gtk_expander_get_expanded (GTK_EXPANDER (window->priv->list_expander));
- g_settings_set_boolean (window->priv->settings_ui, PREF_UI_PLAYLIST, playlist_visible);
-
- if (playlist_visible)
+ if (gtk_widget_get_visible (window->priv->list_scrolled_window))
save_window_size (window);
g_settings_set_enum (window->priv->settings_playlist, PREF_PLAYLIST_SORT_METHOD, window->priv->sort_method);
@@ -1158,37 +1135,21 @@ get_action_name (GooPlayerAction action)
static void
-set_action_label_and_icon (GooWindow *window,
- const char *action_name,
- const char *label,
- const char *tooltip,
- const char *stock_id,
- const char *action_prefix,
- ...)
+_gtk_action_set_label_and_icon (GooWindow *window,
+ const char *action_name,
+ const char *label,
+ const char *tooltip,
+ const char *icon_name)
{
+ GtkAction *action;
- va_list args;
-
- va_start (args, action_prefix);
-
- while (action_prefix != NULL) {
- char *path = g_strconcat (action_prefix, action_name, NULL);
- GtkAction *action = gtk_ui_manager_get_action (window->priv->ui, path);
-
- if (action != NULL)
- g_object_set (G_OBJECT (action),
- "label", label,
- "tooltip", tooltip,
- "icon-name", stock_id,
- NULL);
- g_free (path);
-
- action_prefix = va_arg (args, char*);
- }
-
- va_end (args);
-
- gtk_ui_manager_ensure_update (window->priv->ui);
+ action = gtk_action_group_get_action (window->priv->actions, action_name);
+ if (action != NULL)
+ g_object_set (G_OBJECT (action),
+ /*"label", label,*/
+ "tooltip", tooltip,
+ "icon-name", icon_name,
+ NULL);
}
@@ -1281,13 +1242,7 @@ player_start_cb (GooPlayer *player,
switch (action) {
case GOO_PLAYER_ACTION_PLAY:
- set_action_label_and_icon (window,
- "TogglePlay",
- _("_Pause"),
- _("Pause"),
- GOO_STOCK_PAUSE,
- "/ToolBar/",
- NULL);
+ _gtk_action_set_label_and_icon (window, "TogglePlay", _("_Pause"), _("Pause"), GOO_STOCK_PAUSE);
notify_current_state (window, action);
break;
@@ -1357,6 +1312,9 @@ goo_window_set_current_track (GooWindow *window,
static void
window_update_title (GooWindow *window)
{
+ gtk_window_set_title (GTK_WINDOW (window), _("CD Player"));
+
+#if 0
GooPlayerState state;
GString *title;
@@ -1381,6 +1339,7 @@ window_update_title (GooWindow *window)
gtk_window_set_title (GTK_WINDOW (window), title->str);
g_string_free (title, TRUE);
+#endif
}
@@ -1505,13 +1464,6 @@ goo_window_get_current_cd_autofetch (GooWindow *window)
}
-GtkStatusIcon *
-goo_window_get_status_icon (GooWindow *window)
-{
- return window->priv->status_icon;
-}
-
-
static void
auto_fetch_cover_image (GooWindow *window)
{
@@ -1598,13 +1550,7 @@ player_done_cb (GooPlayer *player,
case GOO_PLAYER_ACTION_PLAY:
case GOO_PLAYER_ACTION_STOP:
case GOO_PLAYER_ACTION_MEDIUM_REMOVED:
- set_action_label_and_icon (window,
- "TogglePlay",
- _("_Play"),
- _("Play"),
- GOO_STOCK_PLAY,
- "/ToolBar/",
- NULL);
+ _gtk_action_set_label_and_icon (window, "TogglePlay", _("_Play"), _("Play"), GOO_STOCK_PLAY);
if (action == GOO_PLAYER_ACTION_PLAY) {
set_current_track_icon (window, GOO_STOCK_PLAY);
window->priv->next_timeout_handle = g_idle_add (next_time_idle, window);
@@ -1616,13 +1562,7 @@ player_done_cb (GooPlayer *player,
case GOO_PLAYER_ACTION_PAUSE:
set_current_track_icon (window, GOO_STOCK_PAUSE);
- set_action_label_and_icon (window,
- "TogglePlay",
- _("_Play"),
- _("Play"),
- GOO_STOCK_PLAY,
- "/ToolBar/",
- NULL);
+ _gtk_action_set_label_and_icon (window, "TogglePlay", _("_Play"), _("Play"), GOO_STOCK_PLAY);
notify_current_state (window, action);
break;
@@ -1800,57 +1740,27 @@ sort_column_changed_cb (GtkTreeSortable *sortable,
static void
update_ui_from_expander_state (GooWindow *window)
{
+ GdkGeometry hints;
- GtkExpander *expander = GTK_EXPANDER (window->priv->list_expander);
-
- if (gtk_expander_get_expanded (expander)) {
- GdkGeometry hints;
-
- gtk_expander_set_label (expander, _(HIDE_TRACK_LIST));
- if (gtk_widget_get_realized (GTK_WIDGET (window)))
- gtk_window_resize (GTK_WINDOW (window),
- g_settings_get_int (window->priv->settings_ui, PREF_UI_WINDOW_WIDTH),
- g_settings_get_int (window->priv->settings_ui, PREF_UI_WINDOW_HEIGHT));
- gtk_window_set_has_resize_grip (GTK_WINDOW (window), TRUE);
-
- hints.max_height = window->priv->resizable_playlist ? G_MAXINT : -1;
- hints.max_width = G_MAXINT;
- gtk_window_set_geometry_hints (GTK_WINDOW (window),
- GTK_WIDGET (window),
- &hints,
- GDK_HINT_MAX_SIZE);
- }
- else {
- GdkGeometry hints;
-
- if (gtk_widget_get_realized (GTK_WIDGET (window)))
- save_window_size (window);
- gtk_window_set_has_resize_grip (GTK_WINDOW (window), FALSE);
- gtk_expander_set_label (expander, _(SHOW_TRACK_LIST));
+ if (gtk_widget_get_realized (GTK_WIDGET (window)))
+ gtk_window_resize (GTK_WINDOW (window),
+ g_settings_get_int (window->priv->settings_ui, PREF_UI_WINDOW_WIDTH),
+ g_settings_get_int (window->priv->settings_ui, PREF_UI_WINDOW_HEIGHT));
+ gtk_window_set_has_resize_grip (GTK_WINDOW (window), TRUE);
- hints.max_height = -1;
- hints.max_width = -1;
- gtk_window_set_geometry_hints (GTK_WINDOW (window),
- GTK_WIDGET (window),
- &hints,
- GDK_HINT_MAX_SIZE);
- }
+ hints.max_height = window->priv->resizable_playlist ? G_MAXINT : -1;
+ hints.max_width = G_MAXINT;
+ gtk_window_set_geometry_hints (GTK_WINDOW (window),
+ GTK_WIDGET (window),
+ &hints,
+ GDK_HINT_MAX_SIZE);
}
static void
-list_expander_expanded_cb (GtkExpander *expander,
- GParamSpec *pspec,
- GooWindow *window)
-{
- update_ui_from_expander_state (window);
- g_settings_set_boolean (window->priv->settings_ui, PREF_UI_PLAYLIST, gtk_expander_get_expanded (expander));
-}
-
-static void
-player_info_skip_to_cb (GooPlayerInfo *info,
- int seconds,
- GooWindow *window)
+player_bar_skip_to_cb (GooPlayerBar *info,
+ int seconds,
+ GooWindow *window)
{
debug (DEBUG_INFO, "[Window] skip to %d\n", seconds);
goo_player_skip_to (window->priv->player, (guint) seconds);
@@ -1923,95 +1833,6 @@ window_key_press_cb (GtkWidget *widget,
static void
-status_icon_activate_cb (GtkStatusIcon *status_icon,
- GooWindow *window)
-{
- goo_window_toggle_visibility (window);
-}
-
-
-static gboolean
-status_icon_query_tooltip_cb (GtkStatusIcon *status_icon,
- int x,
- int y,
- gboolean keyboard_mode,
- GtkTooltip *tooltip,
- gpointer user_data)
-{
- GooWindow *window = user_data;
- GdkPixbuf *image;
- GooPlayer *player;
- AlbumInfo *album;
- TrackInfo *track;
-
- if (keyboard_mode)
- return FALSE;
-
- player = goo_window_get_player (window);
-
- image = goo_player_info_get_cover (GOO_PLAYER_INFO (window->priv->info));
- if (image != NULL)
- gtk_tooltip_set_icon (tooltip, image);
- else if (goo_player_is_audio_cd (player))
- gtk_tooltip_set_icon_from_stock (tooltip, GOO_STOCK_AUDIO_CD, GTK_ICON_SIZE_DIALOG);
- else if (goo_player_get_state (player) == GOO_PLAYER_STATE_DATA_DISC)
- gtk_tooltip_set_icon_from_stock (tooltip, GOO_STOCK_DATA_DISC, GTK_ICON_SIZE_DIALOG);
- else
- gtk_tooltip_set_icon_from_stock (tooltip, GOO_STOCK_NO_DISC, GTK_ICON_SIZE_DIALOG);
-
- album = goo_window_get_album (window);
- track = album_info_get_track (album, goo_player_get_current_track (player));
-
- if (track != NULL) {
- char *current_time;
- char *total_time;
- char *time;
- char *markup;
-
- current_time = _g_format_duration_for_display (track->length * 1000 * goo_player_info_get_progress (GOO_PLAYER_INFO (window->priv->info)));
- total_time = _g_format_duration_for_display (track->length * 1000);
- time = g_strdup_printf (_("%s / %s"), current_time, total_time);
- markup = g_markup_printf_escaped ("<b>%s</b>\n<i>%s</i>\n%s", track->title, track->artist, time);
- gtk_tooltip_set_markup (tooltip, markup);
-
- g_free (markup);
- g_free (time);
- g_free (total_time);
- g_free (current_time);
- }
- else if ((album != NULL) && (album->title != NULL)) {
- char *markup;
-
- markup = g_markup_printf_escaped ("<b>%s</b>\n<i>%s</i>\n", album->title, album->artist);
- gtk_tooltip_set_markup (tooltip, markup);
-
- g_free (markup);
- }
- else
- gtk_tooltip_set_text (tooltip, _("CD Player"));
-
- return TRUE;
-}
-
-
-static void
-status_icon_popup_menu_cb (GtkStatusIcon *status_icon,
- guint button,
- guint activate_time,
- gpointer user_data)
-{
- GooWindow *window = user_data;
-
- gtk_menu_popup (GTK_MENU (window->priv->status_icon_popup_menu),
- NULL, NULL,
- gtk_status_icon_position_menu,
- window->priv->status_icon,
- button,
- activate_time);
-}
-
-
-static void
goo_window_init (GooWindow *window)
{
window->priv = GOO_WINDOW_GET_PRIVATE_DATA (window);
@@ -2132,16 +1953,18 @@ goo_window_construct (GooWindow *window,
BraseroDrive *drive)
{
- GtkWidget *toolbar;
GtkWidget *scrolled_window;
GtkWidget *vbox;
GtkWidget *hbox;
- GtkWidget *expander;
GtkTreeSelection *selection;
GtkActionGroup *actions;
+ GtkAction *action;
+ GtkAction *other_actions_action;
GtkUIManager *ui;
GError *error = NULL;
+ gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (window)), "goobox-main-window");
+
g_signal_connect (G_OBJECT (window),
"delete_event",
G_CALLBACK (window_delete_event_cb),
@@ -2202,6 +2025,7 @@ goo_window_construct (GooWindow *window,
add_columns (window, GTK_TREE_VIEW (window->priv->list_view));
gtk_tree_view_set_enable_search (GTK_TREE_VIEW (window->priv->list_view), TRUE);
gtk_tree_view_set_search_column (GTK_TREE_VIEW (window->priv->list_view), COLUMN_TITLE);
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (window->priv->list_view), FALSE);
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (window->priv->list_store),
COLUMN_TITLE, title_column_sort_func,
@@ -2244,6 +2068,7 @@ goo_window_construct (GooWindow *window,
GTK_POLICY_NEVER,
GTK_POLICY_NEVER);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_NONE);
+ gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 15);
gtk_widget_set_hexpand (scrolled_window, TRUE);
gtk_container_add (GTK_CONTAINER (scrolled_window), window->priv->list_view);
@@ -2251,11 +2076,25 @@ goo_window_construct (GooWindow *window,
window->priv->actions = actions = gtk_action_group_new ("Actions");
gtk_action_group_set_translation_domain (actions, NULL);
+
+ other_actions_action = g_object_new (GTH_TYPE_TOGGLE_MENU_ACTION,
+ "name", "OtherActions",
+ "label", _("Other actions"),
+ "tooltip", _("Other actions"),
+ "icon-name", "emblem-system-symbolic",
+ "menu-halign", GTK_ALIGN_START,
+ "show-arrow", FALSE,
+ NULL);
+ gtk_action_group_add_action (actions, other_actions_action);
+
gtk_action_group_add_actions (actions,
action_entries,
n_action_entries,
window);
+ action = gtk_action_group_get_action (actions, "TogglePlay");
+ g_object_set (action, "always-show-image", TRUE, NULL);
+
window->priv->ui = ui = gtk_ui_manager_new ();
gtk_ui_manager_insert_action_group (ui, actions, 0);
@@ -2267,118 +2106,48 @@ goo_window_construct (GooWindow *window,
g_error_free (error);
}
- window->priv->toolbar = toolbar = gtk_ui_manager_get_widget (ui, "/ToolBar");
- gtk_style_context_add_class (gtk_widget_get_style_context (window->priv->toolbar), GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
- gtk_widget_set_hexpand (toolbar, TRUE);
- gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), TRUE);
- gth_window_attach_toolbar (GTH_WINDOW (window), 0, window->priv->toolbar);
-
- {
- GtkAction *action;
-
- action = gtk_ui_manager_get_action (ui, "/ToolBar/TogglePlay");
- g_object_set (action, "is_important", TRUE, NULL);
- g_object_unref (action);
-
- action = gtk_ui_manager_get_action (ui, "/ToolBar/Play");
- g_object_set (action, "is_important", TRUE, NULL);
- g_object_unref (action);
-
- action = gtk_ui_manager_get_action (ui, "/ToolBar/Pause");
- g_object_set (action, "is_important", TRUE, NULL);
- g_object_unref (action);
-
- action = gtk_ui_manager_get_action (ui, "/ToolBar/Extract");
- g_object_set (action, "is_important", TRUE, NULL);
- g_object_unref (action);
- }
-
- {
- GtkSizeGroup *size_group;
- GtkWidget *toggle_play;
- GtkWidget *play_button;
- GtkWidget *pause_button;
-
- toggle_play = gtk_ui_manager_get_widget (window->priv->ui, "/ToolBar/TogglePlay");
- toggle_play = gtk_ui_manager_get_widget (window->priv->ui, "/ToolBar/TogglePlay");
-
- play_button = gtk_ui_manager_get_widget (window->priv->ui, "/ToolBar/Play");
- gtk_tool_item_set_visible_horizontal (GTK_TOOL_ITEM (play_button), FALSE);
-
- pause_button = gtk_ui_manager_get_widget (window->priv->ui, "/ToolBar/Pause");
- gtk_tool_item_set_visible_horizontal (GTK_TOOL_ITEM (pause_button), FALSE);
-
- size_group = gtk_size_group_new (GTK_SIZE_GROUP_BOTH);
-
- gtk_size_group_add_widget (size_group, toggle_play);
- gtk_size_group_add_widget (size_group, play_button);
- gtk_size_group_add_widget (size_group, pause_button);
- }
+ g_object_set (other_actions_action, "menu", gtk_ui_manager_get_widget (ui, "/OtherActionsMenu"), NULL);
+ g_object_unref (other_actions_action);
window->priv->file_popup_menu = gtk_ui_manager_get_widget (ui, "/ListPopupMenu");
window->priv->cover_popup_menu = gtk_ui_manager_get_widget (ui, "/CoverPopupMenu");
- /* Add the action menu button to the toolbar. */
-
- {
- GtkToolItem *item;
-
- item = gtk_separator_tool_item_new ();
- gtk_widget_show (GTK_WIDGET (item));
- gtk_toolbar_insert (GTK_TOOLBAR (window->priv->toolbar),
- item,
- ACTIONS_MENU_BUTTON_POSITION);
-
- item = gth_toggle_menu_tool_button_new ();
- gth_toggle_menu_tool_button_set_icon_name (GTH_TOGGLE_MENU_TOOL_BUTTON (item), "emblem-system-symbolic");
- gth_toggle_menu_tool_button_set_menu (GTH_TOGGLE_MENU_TOOL_BUTTON (item), gtk_ui_manager_get_widget (ui, "/ActionsMenu"));
- gtk_tool_item_set_tooltip_text (item, _("Other actions"));
- gtk_widget_show (GTK_WIDGET (item));
- gtk_toolbar_insert (GTK_TOOLBAR (window->priv->toolbar),
- item,
- ACTIONS_MENU_BUTTON_POSITION + 1);
- }
-
/**/
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 0);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_vexpand (hbox, FALSE);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), 10);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
- {
- window->priv->info = goo_player_info_new (window, TRUE);
- gtk_container_set_border_width (GTK_CONTAINER (window->priv->info), 0);
- g_signal_connect (window->priv->info,
- "skip_to",
- G_CALLBACK (player_info_skip_to_cb),
- window);
- g_signal_connect (window->priv->info,
- "cover_clicked",
- G_CALLBACK (player_info_cover_clicked_cb),
- window);
- gtk_box_pack_start (GTK_BOX (hbox), window->priv->info, TRUE, TRUE, 0);
- }
+ window->priv->info = goo_player_info_new (window);
+ gtk_container_set_border_width (GTK_CONTAINER (window->priv->info), 0);
+ g_signal_connect (window->priv->info,
+ "cover_clicked",
+ G_CALLBACK (player_info_cover_clicked_cb),
+ window);
+ gtk_box_pack_start (GTK_BOX (hbox), window->priv->info, TRUE, TRUE, 0);
/**/
- window->priv->list_expander = expander = gtk_expander_new_with_mnemonic (_(HIDE_TRACK_LIST));
- gtk_container_add (GTK_CONTAINER (window->priv->list_expander), scrolled_window);
- gtk_expander_set_expanded (GTK_EXPANDER (expander), FALSE /*g_settings_get_boolean (window->priv->settings_ui, PREF_UI_PLAYLIST)*/);
- g_signal_connect (expander,
- "notify::expanded",
- G_CALLBACK (list_expander_expanded_cb),
+ gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0);
+
+ window->priv->player_bar = goo_player_bar_new (window->priv->player, actions);
+ g_signal_connect (window->priv->player_bar,
+ "skip-to",
+ G_CALLBACK (player_bar_skip_to_cb),
window);
+ gtk_widget_show (window->priv->player_bar);
+ gtk_box_pack_start (GTK_BOX (vbox), window->priv->player_bar, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox),
- expander,
- TRUE, TRUE, 0);
+ /**/
gtk_widget_show_all (vbox);
+ gtk_widget_hide (window->priv->list_scrolled_window);
+
gth_window_attach_content (GTH_WINDOW (window), 0, vbox);
+ gth_window_set_current_page (GTH_WINDOW (window), 0);
gtk_widget_grab_focus (window->priv->list_view);
@@ -2388,38 +2157,8 @@ goo_window_construct (GooWindow *window,
g_settings_get_int (window->priv->settings_ui, PREF_UI_WINDOW_WIDTH),
g_settings_get_int (window->priv->settings_ui, PREF_UI_WINDOW_HEIGHT));
- /* The status icon. */
-
- if (! notification_has_persistence ()) {
- window->priv->status_icon = gtk_status_icon_new_from_icon_name ("goobox");
- gtk_status_icon_set_has_tooltip (window->priv->status_icon, TRUE);
- gtk_status_icon_set_title (window->priv->status_icon, _("CD Player"));
-
- window->priv->status_tooltip_content = goo_player_info_new (window, FALSE);
- gtk_container_set_border_width (GTK_CONTAINER (window->priv->status_tooltip_content), 0);
-
- g_signal_connect (G_OBJECT (window->priv->status_icon),
- "activate",
- G_CALLBACK (status_icon_activate_cb),
- window);
- g_signal_connect (G_OBJECT (window->priv->status_icon),
- "query-tooltip",
- G_CALLBACK (status_icon_query_tooltip_cb),
- window);
- g_signal_connect (G_OBJECT (window->priv->status_icon),
- "popup-menu",
- G_CALLBACK (status_icon_popup_menu_cb),
- window);
-
- window->priv->status_icon_popup_menu = gtk_ui_manager_get_widget (ui, "/TrayPopupMenu");
- }
-
/* Add notification callbacks. */
- g_signal_connect (window->priv->settings_ui,
- "changed::" PREF_UI_PLAYLIST,
- G_CALLBACK (pref_view_playlist_changed),
- window);
g_signal_connect (window->priv->settings_playlist,
"changed::" PREF_PLAYLIST_PLAYALL,
G_CALLBACK (pref_playlist_playall_changed),
@@ -2459,7 +2198,7 @@ goo_window_new (BraseroDrive *drive)
g_return_val_if_fail (drive != NULL, NULL);
window = (GooWindow*) g_object_new (GOO_TYPE_WINDOW,
- "application", g_application_get_default (),
+ "n-pages", 1,
NULL);
goo_window_construct (window, drive);
@@ -2959,13 +2698,7 @@ goo_window_toggle_visibility (GooWindow *window)
&window->priv->pos_y);
gtk_widget_hide (GTK_WIDGET (window));
- set_action_label_and_icon (window,
- "ToggleVisibility",
- _("_Show Window"),
- _("Show the main window"),
- NULL,
- "/TrayPopupMenu/",
- NULL);
+ _gtk_action_set_label_and_icon (window, "ToggleVisibility", _("_Show Window"), _("Show the main window"), NULL);
}
else {
gtk_window_move (GTK_WINDOW (window),
@@ -2973,13 +2706,7 @@ goo_window_toggle_visibility (GooWindow *window)
window->priv->pos_y);
gtk_window_present (GTK_WINDOW (window));
- set_action_label_and_icon (window,
- "ToggleVisibility",
- _("_Hide Window"),
- _("Hide the main window"),
- NULL,
- "/TrayPopupMenu/",
- NULL);
+ _gtk_action_set_label_and_icon (window, "ToggleVisibility", _("_Hide Window"), _("Hide the main window"), NULL);
}
}
diff --git a/src/goo-window.h b/src/goo-window.h
index 013e190..8d4e93b 100644
--- a/src/goo-window.h
+++ b/src/goo-window.h
@@ -94,7 +94,5 @@ void goo_window_set_hibernate (GooWindow *window,
void goo_window_set_current_cd_autofetch (GooWindow *window,
gboolean autofetch);
gboolean goo_window_get_current_cd_autofetch (GooWindow *window);
-GtkStatusIcon *
- goo_window_get_status_icon (GooWindow *window);
#endif /* GOO_WINDOW_H */
diff --git a/src/goobox.gresource.xml b/src/goobox.gresource.xml
index e5f1e62..e4dad6a 100644
--- a/src/goobox.gresource.xml
+++ b/src/goobox.gresource.xml
@@ -5,9 +5,10 @@
<file compressed="true">ui/cover-chooser.ui</file>
<file compressed="true">ui/extract.ui</file>
<file compressed="true">ui/format-options.ui</file>
+ <file compressed="true">ui/goobox.css</file>
<file compressed="true">ui/menu-toolbars.ui</file>
<file compressed="true">ui/preferences.ui</file>
<file compressed="true">ui/properties.ui</file>
<file compressed="true">ui/ripper.ui</file>
</gresource>
-</gresources>
\ No newline at end of file
+</gresources>
diff --git a/src/gth-toggle-menu-action.c b/src/gth-toggle-menu-action.c
index 3458d6c..5e96d57 100644
--- a/src/gth-toggle-menu-action.c
+++ b/src/gth-toggle-menu-action.c
@@ -32,12 +32,16 @@ G_DEFINE_TYPE (GthToggleMenuAction, gth_toggle_menu_action, GTK_TYPE_TOGGLE_ACTI
/* Properties */
enum {
PROP_0,
- PROP_MENU
+ PROP_SHOW_ARROW,
+ PROP_MENU,
+ PROP_MENU_HALIGN
};
struct _GthToggleMenuActionPrivate {
+ gboolean show_arrow;
GtkWidget *menu;
+ GtkAlign menu_halign;
GthShowMenuFunc show_menu_func;
gpointer show_menu_data;
GDestroyNotify show_menu_data_destroy;
@@ -48,6 +52,7 @@ static void
gth_toggle_menu_action_init (GthToggleMenuAction *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTH_TYPE_TOGGLE_MENU_ACTION, GthToggleMenuActionPrivate);
+ self->priv->show_arrow = TRUE;
self->priv->menu = gtk_menu_new ();
g_object_ref_sink (self->priv->menu);
}
@@ -63,12 +68,17 @@ gth_toggle_menu_action_set_property (GObject *object,
GthToggleMenuAction *self = GTH_TOGGLE_MENU_ACTION (object);
switch (property_id) {
+ case PROP_SHOW_ARROW:
+ self->priv->show_arrow = g_value_get_boolean (value);
+ break;
case PROP_MENU:
if (self->priv->menu != NULL)
g_object_unref (self->priv->menu);
self->priv->menu = g_value_dup_object (value);
break;
-
+ case PROP_MENU_HALIGN:
+ self->priv->menu_halign = g_value_get_enum (value);
+ break;
default:
break;
}
@@ -84,10 +94,15 @@ gth_toggle_menu_action_get_property (GObject *object,
GthToggleMenuAction *self = GTH_TOGGLE_MENU_ACTION (object);
switch (property_id) {
+ case PROP_SHOW_ARROW:
+ g_value_set_boolean (value, self->priv->show_arrow);
+ break;
case PROP_MENU:
g_value_set_object (value, self->priv->menu);
break;
-
+ case PROP_MENU_HALIGN:
+ g_value_set_enum (value, self->priv->menu_halign);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -111,12 +126,20 @@ gth_toggle_menu_action_create_tool_item (GtkAction *action)
GthToggleMenuAction *self = GTH_TOGGLE_MENU_ACTION (action);
GtkWidget *tool_item;
- tool_item = g_object_new (GTH_TYPE_TOGGLE_MENU_TOOL_BUTTON, NULL);
+ tool_item = g_object_new (GTH_TYPE_TOGGLE_MENU_TOOL_BUTTON,
+ "show-arrow", self->priv->show_arrow,
+ NULL);
if (self->priv->show_menu_func != NULL)
g_signal_connect (tool_item,
"show_menu",
G_CALLBACK (tool_item_show_menu_cb),
self);
+ else if (self->priv->menu != NULL) {
+ g_object_set (tool_item,
+ "menu", self->priv->menu,
+ "menu-halign", self->priv->menu_halign,
+ NULL);
+ }
return tool_item;
}
@@ -156,12 +179,27 @@ gth_toggle_menu_action_class_init (GthToggleMenuActionClass *klass)
/* properties */
g_object_class_install_property (object_class,
+ PROP_SHOW_ARROW,
+ g_param_spec_boolean ("show-arrow",
+ "Show Arrow",
+ "Whether to show an arrow",
+ TRUE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
PROP_MENU,
g_param_spec_object ("menu",
"Menu",
"The menu to show",
GTK_TYPE_MENU,
G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_MENU_HALIGN,
+ g_param_spec_enum ("menu-halign",
+ "Menu HAlign",
+ "Menu Horizontal Alignment",
+ GTK_TYPE_ALIGN,
+ GTK_ALIGN_START,
+ G_PARAM_READWRITE));
}
@@ -184,3 +222,17 @@ gth_toggle_menu_action_get_menu (GthToggleMenuAction *self)
{
return self->priv->menu;
}
+
+
+GtkAlign
+gth_toggle_menu_action_get_menu_halign (GthToggleMenuAction *self)
+{
+ return self->priv->menu_halign;
+}
+
+
+gboolean
+gth_toggle_menu_action_get_show_arrow (GthToggleMenuAction *self)
+{
+ return self->priv->show_arrow;
+}
diff --git a/src/gth-toggle-menu-action.h b/src/gth-toggle-menu-action.h
index 9753ce6..30fa3f2 100644
--- a/src/gth-toggle-menu-action.h
+++ b/src/gth-toggle-menu-action.h
@@ -55,6 +55,8 @@ void gth_toggle_menu_action_set_show_menu_func (GthToggleMenuAction *acti
gpointer data,
GDestroyNotify destroy);
GtkWidget * gth_toggle_menu_action_get_menu (GthToggleMenuAction *action);
+GtkAlign gth_toggle_menu_action_get_menu_halign (GthToggleMenuAction *self);
+gboolean gth_toggle_menu_action_get_show_arrow (GthToggleMenuAction *self);
G_END_DECLS
diff --git a/src/gth-toggle-menu-tool-button.c b/src/gth-toggle-menu-tool-button.c
index 323222b..ace6cc1 100644
--- a/src/gth-toggle-menu-tool-button.c
+++ b/src/gth-toggle-menu-tool-button.c
@@ -32,11 +32,14 @@ struct _GthToggleMenuToolButtonPrivate {
guint contents_invalid : 1;
char *stock_id;
char *icon_name;
+ gboolean show_arrow;
char *label_text;
- GtkWidget *toggle_button;
+ GtkWidget *menu_button;
GtkMenu *menu;
+ GtkAlign menu_halign;
GtkWidget *icon_widget;
GtkWidget *label_widget;
+ GtkWidget *arrow_widget;
};
enum {
@@ -50,8 +53,10 @@ enum {
PROP_USE_UNDERLINE,
PROP_STOCK_ID,
PROP_ICON_NAME,
+ PROP_SHOW_ARROW,
PROP_ACTIVE,
- PROP_MENU
+ PROP_MENU,
+ PROP_MENU_HALIGN
};
@@ -145,19 +150,23 @@ gth_toggle_menu_tool_button_construct_contents (GtkToolItem *tool_item)
gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (button->priv->label_widget)),
button->priv->label_widget);
- if (gtk_bin_get_child (GTK_BIN (button->priv->toggle_button)) != NULL)
+ if (gtk_bin_get_child (GTK_BIN (button->priv->menu_button)) != NULL)
/* Note: we are not destroying the label_widget or icon_widget
* here because they were removed from their containers above
*/
- gtk_widget_destroy (gtk_bin_get_child (GTK_BIN (button->priv->toggle_button)));
+ gtk_widget_destroy (gtk_bin_get_child (GTK_BIN (button->priv->menu_button)));
style = gtk_tool_item_get_toolbar_style (GTK_TOOL_ITEM (button));
- if (style != GTK_TOOLBAR_TEXT)
- need_icon = TRUE;
+ if (style != GTK_TOOLBAR_TEXT) {
+ if ((button->priv->stock_id != NULL) || (button->priv->icon_name != NULL))
+ need_icon = TRUE;
+ }
- if ((style != GTK_TOOLBAR_ICONS) && (style != GTK_TOOLBAR_BOTH_HORIZ))
- need_label = TRUE;
+ if ((style == GTK_TOOLBAR_TEXT) || (style == GTK_TOOLBAR_BOTH)) {
+ if ((button->priv->stock_id != NULL) || (button->priv->label_text != NULL))
+ need_label = TRUE;
+ }
if ((style == GTK_TOOLBAR_BOTH_HORIZ) &&
(gtk_tool_item_get_is_important (GTK_TOOL_ITEM (button))
@@ -167,24 +176,11 @@ gth_toggle_menu_tool_button_construct_contents (GtkToolItem *tool_item)
need_label = TRUE;
}
- if ((style == GTK_TOOLBAR_ICONS)
- && (button->priv->icon_widget == NULL)
- && (button->priv->stock_id == NULL)
- && button->priv->icon_name == NULL)
- {
- need_label = TRUE;
- need_icon = FALSE;
- style = GTK_TOOLBAR_TEXT;
- }
-
- if ((style == GTK_TOOLBAR_TEXT)
- && (button->priv->label_widget == NULL)
- && (button->priv->stock_id == NULL)
- && (button->priv->label_text == NULL))
- {
- need_label = FALSE;
- need_icon = TRUE;
- style = GTK_TOOLBAR_ICONS;
+ if ((style == GTK_TOOLBAR_BOTH) && (! need_label || ! need_icon)) {
+ if (need_icon && ! need_label)
+ style = GTK_TOOLBAR_ICONS;
+ else if (need_label && ! need_icon)
+ style = GTK_TOOLBAR_TEXT;
}
if (need_label) {
@@ -280,12 +276,14 @@ gth_toggle_menu_tool_button_construct_contents (GtkToolItem *tool_item)
}
}
- arrow = gtk_arrow_new ((text_orientation == GTK_ORIENTATION_HORIZONTAL) ? GTK_ARROW_DOWN : GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
+ button->priv->arrow_widget = arrow = gtk_arrow_new ((text_orientation == GTK_ORIENTATION_HORIZONTAL) ? GTK_ARROW_DOWN : GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
gtk_widget_show (arrow);
arrow_align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
- gtk_alignment_set_padding (GTK_ALIGNMENT (arrow_align), 0, 0, icon_spacing, 0);
- gtk_widget_show (arrow_align);
+ if (need_label || need_icon)
+ gtk_alignment_set_padding (GTK_ALIGNMENT (arrow_align), 0, 0, icon_spacing, 0);
+ if (button->priv->show_arrow)
+ gtk_widget_show (arrow_align);
gtk_container_add (GTK_CONTAINER (arrow_align), arrow);
size_group = gtk_tool_item_get_text_size_group (GTK_TOOL_ITEM (button));
@@ -294,50 +292,54 @@ gth_toggle_menu_tool_button_construct_contents (GtkToolItem *tool_item)
main_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, icon_spacing);
gtk_widget_show (main_box);
- gtk_container_add (GTK_CONTAINER (button->priv->toggle_button), main_box);
+ gtk_container_add (GTK_CONTAINER (button->priv->menu_button), main_box);
- if (style == GTK_TOOLBAR_BOTH_HORIZ)
- box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, icon_spacing);
- else
- box = gtk_box_new (GTK_ORIENTATION_VERTICAL, icon_spacing);
- gtk_widget_show (box);
+ if (need_label || need_icon) {
+ if (style == GTK_TOOLBAR_BOTH_HORIZ)
+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, icon_spacing);
+ else
+ box = gtk_box_new (GTK_ORIENTATION_VERTICAL, icon_spacing);
+ gtk_widget_show (box);
- gtk_box_pack_start (GTK_BOX (main_box), box, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (main_box), box, TRUE, TRUE, 0);
+ }
gtk_box_pack_end (GTK_BOX (main_box), arrow_align, FALSE, FALSE, 0);
- switch (style) {
- case GTK_TOOLBAR_ICONS:
- if (icon)
- gtk_box_pack_start (GTK_BOX (box), icon, TRUE, TRUE, 0);
- break;
-
- case GTK_TOOLBAR_BOTH:
- if (icon)
- gtk_box_pack_start (GTK_BOX (box), icon, TRUE, TRUE, 0);
- gtk_box_pack_end (GTK_BOX (box), label, FALSE, TRUE, 0);
- break;
-
- case GTK_TOOLBAR_BOTH_HORIZ:
- if (text_orientation == GTK_ORIENTATION_HORIZONTAL) {
+ if (need_icon || need_label) {
+ switch (style) {
+ case GTK_TOOLBAR_ICONS:
if (icon)
- gtk_box_pack_start (GTK_BOX (box), icon, label? FALSE : TRUE, TRUE, 0);
- if (label)
- gtk_box_pack_end (GTK_BOX (box), label, TRUE, TRUE, 0);
- }
- else {
+ gtk_box_pack_start (GTK_BOX (box), icon, TRUE, TRUE, 0);
+ break;
+
+ case GTK_TOOLBAR_BOTH:
if (icon)
- gtk_box_pack_end (GTK_BOX (box), icon, label ? FALSE : TRUE, TRUE, 0);
- if (label)
- gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
- }
- break;
+ gtk_box_pack_start (GTK_BOX (box), icon, TRUE, TRUE, 0);
+ gtk_box_pack_end (GTK_BOX (box), label, FALSE, TRUE, 0);
+ break;
+
+ case GTK_TOOLBAR_BOTH_HORIZ:
+ if (text_orientation == GTK_ORIENTATION_HORIZONTAL) {
+ if (icon)
+ gtk_box_pack_start (GTK_BOX (box), icon, label? FALSE : TRUE, TRUE, 0);
+ if (label)
+ gtk_box_pack_end (GTK_BOX (box), label, TRUE, TRUE, 0);
+ }
+ else {
+ if (icon)
+ gtk_box_pack_end (GTK_BOX (box), icon, label ? FALSE : TRUE, TRUE, 0);
+ if (label)
+ gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
+ }
+ break;
- case GTK_TOOLBAR_TEXT:
- gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
- break;
+ case GTK_TOOLBAR_TEXT:
+ gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
+ break;
+ }
}
- gtk_button_set_relief (GTK_BUTTON (button->priv->toggle_button),
+ gtk_button_set_relief (GTK_BUTTON (button->priv->menu_button),
gtk_tool_item_get_relief_style (GTK_TOOL_ITEM (button)));
gtk_tool_item_rebuild_menu (tool_item);
@@ -363,7 +365,7 @@ gth_toggle_menu_tool_button_update_icon_spacing (GthToggleMenuToolButton *button
GtkWidget *box;
guint spacing;
- box = gtk_bin_get_child (GTK_BIN (button->priv->toggle_button));
+ box = gtk_bin_get_child (GTK_BIN (button->priv->menu_button));
if (GTK_IS_BOX (box)) {
gtk_widget_style_get (GTK_WIDGET (button),
"icon-spacing", &spacing,
@@ -382,6 +384,21 @@ gth_toggle_menu_tool_button_style_updated (GtkWidget *widget)
static void
+gth_toggle_menu_tool_button_map (GtkWidget *widget)
+{
+ GthToggleMenuToolButton *button = GTH_TOGGLE_MENU_TOOL_BUTTON (widget);
+
+ GTK_WIDGET_CLASS (gth_toggle_menu_tool_button_parent_class)->map (widget);
+
+ if (gtk_menu_get_attach_widget (button->priv->menu) != NULL)
+ gtk_menu_detach (button->priv->menu);
+
+ g_object_set (button->priv->menu, "halign", button->priv->menu_halign, NULL);
+ g_object_set (button->priv->menu_button, "menu", button->priv->menu, NULL);
+}
+
+
+static void
gth_toggle_menu_tool_button_set_property (GObject *object,
guint prop_id,
const GValue *value,
@@ -402,12 +419,18 @@ gth_toggle_menu_tool_button_set_property (GObject *object,
case PROP_ICON_NAME:
gth_toggle_menu_tool_button_set_icon_name (button, g_value_get_string (value));
break;
+ case PROP_SHOW_ARROW:
+ gth_toggle_menu_tool_button_set_show_arrow (button, g_value_get_boolean (value));
+ break;
case PROP_ACTIVE:
gth_toggle_menu_tool_button_set_active (button, g_value_get_boolean (value));
break;
case PROP_MENU:
gth_toggle_menu_tool_button_set_menu (button, g_value_get_object (value));
break;
+ case PROP_MENU_HALIGN:
+ gth_toggle_menu_tool_button_set_menu_halign (button, g_value_get_enum (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -436,12 +459,18 @@ gth_toggle_menu_tool_button_get_property (GObject *object,
case PROP_ICON_NAME:
g_value_set_string (value, button->priv->icon_name);
break;
+ case PROP_SHOW_ARROW:
+ g_value_set_boolean (value, gth_toggle_menu_tool_button_get_show_arrow (button));
+ break;
case PROP_ACTIVE:
g_value_set_boolean (value, gth_toggle_menu_tool_button_get_active (button));
break;
case PROP_MENU:
g_value_set_object (value, button->priv->menu);
break;
+ case PROP_MENU_HALIGN:
+ g_value_set_enum (value, button->priv->menu_halign);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -463,150 +492,15 @@ gth_toggle_menu_tool_button_property_notify (GObject *object,
}
-/* Callback for the "deactivate" signal on the pop-up menu.
- * This is used so that we unset the state of the toggle button
- * when the pop-up menu disappears.
- */
-static int
-menu_deactivate_cb (GtkMenuShell *menu_shell,
- GthToggleMenuToolButton *button)
-{
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button->priv->toggle_button), FALSE);
- return TRUE;
-}
-
-
-static void
-menu_position_func (GtkMenu *menu,
- int *x,
- int *y,
- gboolean *push_in,
- GthToggleMenuToolButton *button)
-{
- GtkWidget *widget = GTK_WIDGET (button);
- GtkRequisition req;
- GtkRequisition menu_req;
- GtkOrientation orientation;
- GtkTextDirection direction;
- cairo_rectangle_int_t monitor;
- int monitor_num;
- GdkScreen *screen;
- GtkAllocation allocation;
-
- gtk_widget_get_preferred_size (GTK_WIDGET (button->priv->menu), &menu_req, NULL);
-
- orientation = gtk_tool_item_get_orientation (GTK_TOOL_ITEM (button));
- direction = gtk_widget_get_direction (widget);
-
- screen = gtk_widget_get_screen (GTK_WIDGET (menu));
- monitor_num = gdk_screen_get_monitor_at_window (screen, gtk_widget_get_window (widget));
- if (monitor_num < 0)
- monitor_num = 0;
- gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
- gtk_widget_get_allocation (widget, &allocation);
-
- if (orientation == GTK_ORIENTATION_HORIZONTAL) {
- gdk_window_get_origin (gtk_widget_get_window (widget), x, y);
- *x += allocation.x;
- *y += allocation.y;
-
- if (direction == GTK_TEXT_DIR_LTR)
- *x += MAX (allocation.width - menu_req.width, 0);
- else if (menu_req.width > allocation.width)
- *x -= menu_req.width - allocation.width;
-
- if ((*y + allocation.height + menu_req.height) <= monitor.y + monitor.height)
- *y += allocation.height;
- else if ((*y - menu_req.height) >= monitor.y)
- *y -= menu_req.height;
- else if (monitor.y + monitor.height - (*y + allocation.height) > *y)
- *y += allocation.height;
- else
- *y -= menu_req.height;
- }
- else {
- gdk_window_get_origin (gtk_button_get_event_window (GTK_BUTTON (widget)), x, y);
- gtk_widget_get_preferred_size (widget, &req, NULL);
-
- if (direction == GTK_TEXT_DIR_LTR)
- *x += allocation.width;
- else
- *x -= menu_req.width;
-
- if ((*y + menu_req.height > monitor.y + monitor.height) &&
- (*y + allocation.height - monitor.y > monitor.y + monitor.height - *y))
- {
- *y += allocation.height - menu_req.height;
- }
- }
-
- *push_in = FALSE;
-}
-
-
static void
-popup_menu_under_button (GthToggleMenuToolButton *button,
- GdkEventButton *event)
-{
- g_signal_emit (button, signals[SHOW_MENU], 0);
-
- if (button->priv->menu == NULL)
- return;
-
- if (gtk_menu_get_attach_widget (button->priv->menu) != NULL)
- gtk_menu_detach (button->priv->menu);
- gtk_menu_popup (button->priv->menu, NULL, NULL,
- (GtkMenuPositionFunc) menu_position_func,
- button,
- event ? event->button : 0,
- event ? event->time : gtk_get_current_event_time ());
-}
-
-
-static gboolean
-real_button_toggled_cb (GtkToggleButton *togglebutton,
- GthToggleMenuToolButton *button)
-{
- gboolean toggle_active = gtk_toggle_button_get_active (togglebutton);
-
- if (button->priv->menu == NULL)
- return FALSE;
-
- if (button->priv->active != toggle_active) {
- button->priv->active = toggle_active;
- g_object_notify (G_OBJECT (button), "active");
-
- if (button->priv->active && ! gtk_widget_get_visible (GTK_WIDGET (button->priv->menu))) {
- /* we get here only when the menu is activated by a key
- * press, so that we can select the first menu item */
- popup_menu_under_button (button, NULL);
- gtk_menu_shell_select_first (GTK_MENU_SHELL (button->priv->menu), FALSE);
- }
- }
-
- return FALSE;
-}
-
-
-static gboolean
-real_button_button_press_event_cb (GtkWidget *widget,
- GdkEventButton *event,
- GthToggleMenuToolButton *button)
+gth_toggle_menu_tool_button_finalize (GObject *object)
{
- if ((event->button == 1) && (button->priv->menu != NULL)) {
- popup_menu_under_button (button, event);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
-
- return TRUE;
- }
- else
- return FALSE;
-}
+ GthToggleMenuToolButton *button;
+ button = GTH_TOGGLE_MENU_TOOL_BUTTON (object);
+ if (button->priv->menu_button != NULL)
+ button->priv->menu_button = NULL;
-static void
-gth_toggle_menu_tool_button_finalize (GObject *object)
-{
G_OBJECT_CLASS (gth_toggle_menu_tool_button_parent_class)->finalize (object);
}
@@ -653,10 +547,12 @@ gth_toggle_menu_tool_button_create_menu_proxy (GtkToolItem *item)
if (menu_image != NULL)
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), menu_image);
- g_object_ref (button->priv->menu);
- if (gtk_menu_get_attach_widget (button->priv->menu) != NULL)
- gtk_menu_detach (button->priv->menu);
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), GTK_WIDGET (button->priv->menu));
+ if (button->priv->menu != NULL) {
+ g_object_ref (button->priv->menu);
+ if (gtk_menu_get_attach_widget (button->priv->menu) != NULL)
+ gtk_menu_detach (button->priv->menu);
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), GTK_WIDGET (button->priv->menu));
+ }
gtk_tool_item_set_proxy_menu_item (item, MENU_ID, menu_item);
@@ -689,6 +585,7 @@ gth_toggle_menu_tool_button_class_init (GthToggleMenuToolButtonClass *klass)
widget_class = (GtkWidgetClass *) klass;
widget_class->state_changed = gth_toggle_menu_tool_button_state_changed;
widget_class->style_updated = gth_toggle_menu_tool_button_style_updated;
+ widget_class->map = gth_toggle_menu_tool_button_map;
tool_item_class = (GtkToolItemClass *) klass;
tool_item_class->create_menu_proxy = gth_toggle_menu_tool_button_create_menu_proxy;
@@ -749,6 +646,13 @@ gth_toggle_menu_tool_button_class_init (GthToggleMenuToolButtonClass *klass)
NULL,
G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (object_class,
+ PROP_SHOW_ARROW,
+ g_param_spec_boolean ("show-arrow",
+ "Show arrow",
+ "Whether to display an arrow",
+ TRUE,
+ G_PARAM_READABLE | G_PARAM_WRITABLE));
+ g_object_class_install_property (object_class,
PROP_ACTIVE,
g_param_spec_boolean ("active",
"Active",
@@ -762,6 +666,14 @@ gth_toggle_menu_tool_button_class_init (GthToggleMenuToolButtonClass *klass)
"The dropdown menu",
GTK_TYPE_MENU,
G_PARAM_READABLE | G_PARAM_WRITABLE));
+ g_object_class_install_property (object_class,
+ PROP_MENU_HALIGN,
+ g_param_spec_enum ("menu-halign",
+ "Menu HAlign",
+ "Menu Horizontal Alignment",
+ GTK_TYPE_ALIGN,
+ GTK_ALIGN_START,
+ G_PARAM_READWRITE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("icon-spacing",
@@ -781,21 +693,13 @@ gth_toggle_menu_tool_button_init (GthToggleMenuToolButton *button)
button->priv->menu = NULL;
button->priv->contents_invalid = TRUE;
- button->priv->toggle_button = gtk_toggle_button_new ();
- gtk_button_set_focus_on_click (GTK_BUTTON (button->priv->toggle_button), FALSE);
- gtk_container_add (GTK_CONTAINER (button), button->priv->toggle_button);
- gtk_widget_show (button->priv->toggle_button);
-
- g_signal_connect (button->priv->toggle_button,
- "toggled",
- G_CALLBACK (real_button_toggled_cb),
- button);
- g_signal_connect (button->priv->toggle_button,
- "button-press-event",
- G_CALLBACK (real_button_button_press_event_cb),
- button);
-
- button->priv->active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button->priv->toggle_button));
+ button->priv->menu_button = gtk_menu_button_new ();
+ gtk_button_set_focus_on_click (GTK_BUTTON (button->priv->menu_button), FALSE);
+ gtk_container_add (GTK_CONTAINER (button), button->priv->menu_button);
+ gtk_widget_show (button->priv->menu_button);
+ gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (button)), GTK_STYLE_CLASS_MENUITEM);
+
+ button->priv->active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button->priv->menu_button));
}
@@ -831,6 +735,12 @@ gth_toggle_menu_tool_button_update (GtkActivatable *activatable,
else if (strcmp (property_name, "icon-name") == 0) {
gth_toggle_menu_tool_button_set_icon_name (button, gtk_action_get_icon_name (action));
}
+ else if (strcmp (property_name, "menu-halign") == 0) {
+ gth_toggle_menu_tool_button_set_menu_halign (button, gth_toggle_menu_action_get_menu_halign (GTH_TOGGLE_MENU_ACTION (action)));
+ }
+ else if (strcmp (property_name, "show-arrow") == 0) {
+ gth_toggle_menu_tool_button_set_show_arrow (button, gth_toggle_menu_action_get_show_arrow (GTH_TOGGLE_MENU_ACTION (action)));
+ }
}
}
@@ -906,7 +816,7 @@ gth_toggle_menu_tool_button_set_label (GthToggleMenuToolButton *button,
AtkObject *accessible;
elided_label = _gtk_toolbar_elide_underscores (label);
- accessible = gtk_widget_get_accessible (GTK_WIDGET (button->priv->toggle_button));
+ accessible = gtk_widget_get_accessible (GTK_WIDGET (button->priv->menu_button));
atk_object_set_name (accessible, elided_label);
g_free (elided_label);
@@ -996,6 +906,37 @@ gth_toggle_menu_tool_button_get_icon_name (GthToggleMenuToolButton *button)
void
+gth_toggle_menu_tool_button_set_show_arrow (GthToggleMenuToolButton *button,
+ gboolean show_arrow)
+{
+ g_return_if_fail (GTH_IS_TOGGLE_MENU_TOOL_BUTTON (button));
+
+ button->priv->show_arrow = show_arrow != FALSE;
+ g_object_notify (G_OBJECT (button), "show-arrow");
+}
+
+
+void
+gth_toggle_menu_tool_button_set_menu_halign (GthToggleMenuToolButton *button,
+ GtkAlign align)
+{
+ g_return_if_fail (GTH_IS_TOGGLE_MENU_TOOL_BUTTON (button));
+
+ button->priv->menu_halign = align;
+ g_object_notify (G_OBJECT (button), "menu-halign");
+}
+
+
+gboolean
+gth_toggle_menu_tool_button_get_show_arrow (GthToggleMenuToolButton *button)
+{
+ g_return_val_if_fail (GTH_IS_TOGGLE_MENU_TOOL_BUTTON (button), FALSE);
+
+ return button->priv->show_arrow;
+}
+
+
+void
gth_toggle_menu_tool_button_set_active (GthToggleMenuToolButton *button,
gboolean is_active)
{
@@ -1004,7 +945,7 @@ gth_toggle_menu_tool_button_set_active (GthToggleMenuToolButton *button,
is_active = is_active != FALSE;
if (button->priv->active != is_active)
- gtk_button_clicked (GTK_BUTTON (button->priv->toggle_button));
+ gtk_button_clicked (GTK_BUTTON (button->priv->menu_button));
}
@@ -1028,29 +969,16 @@ gth_toggle_menu_tool_button_set_menu (GthToggleMenuToolButton *button,
if ((button->priv->menu != NULL) && gtk_widget_get_visible (GTK_WIDGET (button->priv->menu)))
gtk_menu_shell_deactivate (GTK_MENU_SHELL (button->priv->menu));
- button->priv->menu = GTK_MENU (menu);
+ if (button->priv->menu != NULL)
+ g_object_unref (button->priv->menu);
+ button->priv->menu = g_object_ref (menu);
- if (button->priv->menu != NULL) {
- g_object_add_weak_pointer (G_OBJECT (button->priv->menu), (gpointer *) &button->priv->menu);
+ if (gtk_menu_get_attach_widget (button->priv->menu) != NULL)
+ gtk_menu_detach (button->priv->menu);
- gtk_widget_set_sensitive (button->priv->toggle_button, TRUE);
- g_signal_connect (button->priv->menu,
- "deactivate",
- G_CALLBACK (menu_deactivate_cb),
- button);
- }
- else
- gtk_widget_set_sensitive (button->priv->toggle_button, FALSE);
+ g_object_set (button->priv->menu, "halign", button->priv->menu_halign, NULL);
+ g_object_set (button->priv->menu_button, "menu", button->priv->menu, NULL);
}
g_object_notify (G_OBJECT (button), "menu");
}
-
-
-GtkWidget *
-gth_toggle_menu_tool_button_get_menu (GthToggleMenuToolButton *button)
-{
- g_return_val_if_fail (GTH_IS_TOGGLE_MENU_TOOL_BUTTON (button), NULL);
-
- return GTK_WIDGET (button->priv->menu);
-}
diff --git a/src/gth-toggle-menu-tool-button.h b/src/gth-toggle-menu-tool-button.h
index bfc28e1..283f8a9 100644
--- a/src/gth-toggle-menu-tool-button.h
+++ b/src/gth-toggle-menu-tool-button.h
@@ -68,6 +68,11 @@ const char * gth_toggle_menu_tool_button_get_stock_id (GthToggleMenuToolB
void gth_toggle_menu_tool_button_set_icon_name (GthToggleMenuToolButton *button,
const char *icon_name);
const char * gth_toggle_menu_tool_button_get_icon_name (GthToggleMenuToolButton *button);
+void gth_toggle_menu_tool_button_set_show_arrow (GthToggleMenuToolButton *button,
+ gboolean show_arrow);
+gboolean gth_toggle_menu_tool_button_get_show_arrow (GthToggleMenuToolButton *button);
+void gth_toggle_menu_tool_button_set_menu_halign (GthToggleMenuToolButton *button,
+ GtkAlign align);
void gth_toggle_menu_tool_button_set_active (GthToggleMenuToolButton *button,
gboolean is_active);
gboolean gth_toggle_menu_tool_button_get_active (GthToggleMenuToolButton *button);
diff --git a/src/gth-window.c b/src/gth-window.c
index a4c3313..f4343f5 100644
--- a/src/gth-window.c
+++ b/src/gth-window.c
@@ -16,8 +16,7 @@
* 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., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
@@ -27,27 +26,28 @@
#include "main.h"
-#define GTH_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTH_TYPE_WINDOW, GthWindowPrivate))
+G_DEFINE_TYPE (GthWindow, gth_window, GTK_TYPE_APPLICATION_WINDOW)
+
enum {
- GTH_WINDOW_DUMMY_PROPERTY,
- GTH_WINDOW_N_PAGES
+ PROP_0,
+ PROP_N_PAGES
};
-static GtkWindowClass *parent_class = NULL;
-
-
struct _GthWindowPrivate {
- int n_pages;
- int current_page;
- GtkWidget *layout;
- GtkWidget *notebook;
- GtkWidget *menubar;
- GtkWidget *toolbar;
- GtkWidget *statusbar;
- GtkWidget **toolbars;
- GtkWidget **contents;
+ int n_pages;
+ int current_page;
+ GtkWidget *grid;
+ GtkWidget *notebook;
+ GtkWidget *menubar;
+ GtkWidget *toolbar;
+ GtkWidget *infobar;
+ GtkWidget *statusbar;
+ GtkWidget **toolbars;
+ GtkWidget **contents;
+ GthWindowSize *window_size;
+ GtkWindowGroup *window_group;
};
@@ -57,17 +57,26 @@ gth_window_set_n_pages (GthWindow *self,
{
int i;
+ if (self->priv->n_pages != 0) {
+ g_critical ("The number of pages of a GthWindow can be set only once.");
+ return;
+ }
+
self->priv->n_pages = n_pages;
- self->priv->layout = gtk_grid_new ();
- gtk_widget_show (self->priv->layout);
- gtk_container_add (GTK_CONTAINER (self), self->priv->layout);
+ self->priv->grid = gtk_grid_new ();
+ gtk_widget_show (self->priv->grid);
+ gtk_container_add (GTK_CONTAINER (self), self->priv->grid);
self->priv->notebook = gtk_notebook_new ();
+ gtk_style_context_remove_class (gtk_widget_get_style_context (self->priv->notebook), GTK_STYLE_CLASS_NOTEBOOK);
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (self->priv->notebook), FALSE);
gtk_notebook_set_show_border (GTK_NOTEBOOK (self->priv->notebook), FALSE);
gtk_widget_show (self->priv->notebook);
- gtk_grid_attach (GTK_GRID (self->priv->layout), self->priv->notebook, 0, 2, 1, 1);
+ gtk_grid_attach (GTK_GRID (self->priv->grid),
+ self->priv->notebook,
+ 0, 2,
+ 1, 1);
self->priv->toolbars = g_new0 (GtkWidget *, n_pages);
self->priv->contents = g_new0 (GtkWidget *, n_pages);
@@ -81,14 +90,18 @@ gth_window_set_n_pages (GthWindow *self,
page,
NULL);
+ self->priv->contents[i] = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_widget_hide (self->priv->contents[i]);
+ gtk_box_pack_start (GTK_BOX (page), self->priv->contents[i], TRUE, TRUE, 0);
+
self->priv->toolbars[i] = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_show (self->priv->toolbars[i]);
gtk_box_pack_start (GTK_BOX (page), self->priv->toolbars[i], FALSE, FALSE, 0);
-
- self->priv->contents[i] = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_widget_show (self->priv->contents[i]);
- gtk_box_pack_start (GTK_BOX (page), self->priv->contents[i], TRUE, TRUE, 0);
}
+
+ self->priv->window_size = g_new0 (GthWindowSize, n_pages);
+ for (i = 0; i < n_pages; i++)
+ self->priv->window_size[i].saved = FALSE;
}
@@ -103,7 +116,7 @@ gth_window_set_property (GObject *object,
self = GTH_WINDOW (object);
switch (property_id) {
- case GTH_WINDOW_N_PAGES:
+ case PROP_N_PAGES:
gth_window_set_n_pages (self, g_value_get_int (value));
break;
default:
@@ -114,14 +127,37 @@ gth_window_set_property (GObject *object,
static void
+gth_window_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GthWindow *self;
+
+ self = GTH_WINDOW (object);
+
+ switch (property_id) {
+ case PROP_N_PAGES:
+ g_value_set_int (value, self->priv->n_pages);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+
+static void
gth_window_finalize (GObject *object)
{
GthWindow *window = GTH_WINDOW (object);
g_free (window->priv->toolbars);
g_free (window->priv->contents);
+ g_free (window->priv->window_size);
+ g_object_unref (window->priv->window_group);
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (gth_window_parent_class)->finalize (object);
}
@@ -145,10 +181,55 @@ static void
gth_window_real_set_current_page (GthWindow *window,
int page)
{
+ int i;
+
if (window->priv->current_page == page)
return;
+
window->priv->current_page = page;
gtk_notebook_set_current_page (GTK_NOTEBOOK (window->priv->notebook), page);
+
+ for (i = 0; i < window->priv->n_pages; i++)
+ if (i == page)
+ gtk_widget_show (window->priv->contents[i]);
+ else
+ gtk_widget_hide (window->priv->contents[i]);
+}
+
+
+static void
+gth_window_realize (GtkWidget *widget)
+{
+ GdkScreen *screen;
+ GBytes *bytes;
+ gconstpointer css_data;
+ gsize css_data_size;
+ GtkCssProvider *css_provider;
+ GError *error = NULL;
+
+ GTK_WIDGET_CLASS (gth_window_parent_class)->realize (widget);
+
+ screen = gtk_widget_get_screen (widget);
+ /*gtk_icon_theme_append_search_path (gtk_icon_theme_get_for_screen (screen), ICON_DIR);*/
+
+ bytes = g_resources_lookup_data ("/org/gnome/Goobox/ui/goobox.css", 0, &error);
+ if (bytes == NULL) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ css_data = g_bytes_get_data (bytes, &css_data_size);
+ css_provider = gtk_css_provider_new ();
+ if (! gtk_css_provider_load_from_data (css_provider, css_data, css_data_size, &error)) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+ gtk_style_context_add_provider_for_screen (screen,
+ GTK_STYLE_PROVIDER (css_provider),
+ GTK_STYLE_PROVIDER_PRIORITY_THEME);
+
+ g_object_unref (css_provider);
}
@@ -158,70 +239,48 @@ gth_window_class_init (GthWindowClass *klass)
GObjectClass *gobject_class;
GtkWidgetClass *widget_class;
- parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (klass, sizeof (GthWindowPrivate));
gobject_class = (GObjectClass*) klass;
gobject_class->set_property = gth_window_set_property;
+ gobject_class->get_property = gth_window_get_property;
gobject_class->finalize = gth_window_finalize;
widget_class = (GtkWidgetClass*) klass;
widget_class->delete_event = gth_window_delete_event;
+ widget_class->realize = gth_window_realize;
klass->close = gth_window_real_close;
klass->set_current_page = gth_window_real_set_current_page;
g_object_class_install_property (G_OBJECT_CLASS (klass),
- GTH_WINDOW_N_PAGES,
+ PROP_N_PAGES,
g_param_spec_int ("n-pages",
"n-pages",
"n-pages",
0,
G_MAXINT,
1,
- G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+ G_PARAM_READWRITE));
}
static void
gth_window_init (GthWindow *window)
{
- window->priv = GTH_WINDOW_GET_PRIVATE (window);
- window->priv->layout = NULL;
+ window->priv = G_TYPE_INSTANCE_GET_PRIVATE (window, GTH_TYPE_WINDOW, GthWindowPrivate);
+ window->priv->grid = NULL;
window->priv->contents = NULL;
window->priv->n_pages = 0;
- window->priv->current_page = -1;
+ window->priv->current_page = GTH_WINDOW_PAGE_UNDEFINED;
window->priv->menubar = NULL;
window->priv->toolbar = NULL;
+ window->priv->infobar = NULL;
window->priv->statusbar = NULL;
-}
-
+ window->priv->window_group = gtk_window_group_new ();
+ gtk_window_group_add_window (window->priv->window_group, GTK_WINDOW (window));
-GType
-gth_window_get_type (void)
-{
- static GType type = 0;
-
- if (! type) {
- GTypeInfo type_info = {
- sizeof (GthWindowClass),
- NULL,
- NULL,
- (GClassInitFunc) gth_window_class_init,
- NULL,
- NULL,
- sizeof (GthWindow),
- 0,
- (GInstanceInitFunc) gth_window_init
- };
-
- type = g_type_register_static (GTK_TYPE_APPLICATION_WINDOW,
- "GthWindow",
- &type_info,
- 0);
- }
-
- return type;
+ gtk_window_set_application (GTK_WINDOW (window), Main_Application);
}
@@ -253,18 +312,23 @@ gth_window_attach (GthWindow *window,
window->priv->toolbar = child;
position = 1;
break;
+ case GTH_WINDOW_INFOBAR:
+ window->priv->infobar = child;
+ position = 3;
+ break;
case GTH_WINDOW_STATUSBAR:
window->priv->statusbar = child;
- position = 3;
+ position = 4;
break;
default:
return;
}
- gtk_grid_attach (GTK_GRID (window->priv->layout),
- child,
- 0, position,
- 1, 1);
+ gtk_widget_set_hexpand (child, TRUE);
+ gtk_grid_attach (GTK_GRID (window->priv->grid),
+ child,
+ 0, position,
+ 1, 1);
}
@@ -280,6 +344,7 @@ gth_window_attach_toolbar (GthWindow *window,
g_return_if_fail (GTK_IS_WIDGET (child));
_gtk_container_remove_children (GTK_CONTAINER (window->priv->toolbars[page]), NULL, NULL);
+ gtk_widget_set_hexpand (child, TRUE);
gtk_container_add (GTK_CONTAINER (window->priv->toolbars[page]), child);
}
@@ -296,27 +361,12 @@ gth_window_attach_content (GthWindow *window,
g_return_if_fail (GTK_IS_WIDGET (child));
_gtk_container_remove_children (GTK_CONTAINER (window->priv->contents[page]), NULL, NULL);
+ gtk_widget_set_hexpand (child, TRUE);
+ gtk_widget_set_vexpand (child, TRUE);
gtk_container_add (GTK_CONTAINER (window->priv->contents[page]), child);
}
-GtkWidget *
-gth_window_attach_get_content (GthWindow *window,
- int page)
-{
- GList *children;
-
- g_return_val_if_fail (window != NULL, NULL);
- g_return_val_if_fail (GTH_IS_WINDOW (window), NULL);
- g_return_val_if_fail (page >= 0 && page < window->priv->n_pages, NULL);
-
- children = gtk_container_get_children (GTK_CONTAINER (window->priv->contents[page]));
- if (children != NULL)
- return children->data;
- else
- return NULL;
-}
-
void
gth_window_set_current_page (GthWindow *window,
int page)
@@ -369,3 +419,108 @@ gth_window_show_only_content (GthWindow *window,
show_widget (window->priv->statusbar);
}
}
+
+
+GtkWidget *
+gth_window_get_area (GthWindow *window,
+ GthWindowArea area)
+{
+ switch (area) {
+ case GTH_WINDOW_MENUBAR:
+ return window->priv->menubar;
+ break;
+ case GTH_WINDOW_TOOLBAR:
+ return window->priv->toolbar;
+ break;
+ case GTH_WINDOW_INFOBAR:
+ return window->priv->infobar;
+ break;
+ case GTH_WINDOW_STATUSBAR:
+ return window->priv->statusbar;
+ break;
+ default:
+ break;
+ }
+
+ return NULL;
+}
+
+
+GtkWidget *
+gth_window_get_content (GthWindow *window,
+ int page)
+{
+ g_return_val_if_fail (window != NULL, NULL);
+ g_return_val_if_fail (GTH_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (page >= 0 && page < window->priv->n_pages, NULL);
+
+ return window->priv->contents[page];
+}
+
+
+
+void
+gth_window_save_page_size (GthWindow *window,
+ int page,
+ int width,
+ int height)
+{
+ g_return_if_fail (window != NULL);
+ g_return_if_fail (GTH_IS_WINDOW (window));
+ g_return_if_fail (page >= 0 && page < window->priv->n_pages);
+
+ window->priv->window_size[page].width = width;
+ window->priv->window_size[page].height = height;
+ window->priv->window_size[page].saved = TRUE;
+}
+
+
+void
+gth_window_apply_saved_size (GthWindow *window,
+ int page)
+{
+ g_return_if_fail (window != NULL);
+ g_return_if_fail (GTH_IS_WINDOW (window));
+ g_return_if_fail (page >= 0 && page < window->priv->n_pages);
+
+ if (! window->priv->window_size[page].saved)
+ return;
+
+ gtk_window_resize (GTK_WINDOW (window),
+ window->priv->window_size[page].width,
+ window->priv->window_size[page].height);
+}
+
+
+void
+gth_window_clear_saved_size (GthWindow *window,
+ int page)
+{
+ g_return_if_fail (window != NULL);
+ g_return_if_fail (GTH_IS_WINDOW (window));
+ g_return_if_fail (page >= 0 && page < window->priv->n_pages);
+
+ window->priv->window_size[page].saved = FALSE;
+}
+
+
+gboolean
+gth_window_get_page_size (GthWindow *window,
+ int page,
+ int *width,
+ int *height)
+{
+ g_return_val_if_fail (window != NULL, FALSE);
+ g_return_val_if_fail (GTH_IS_WINDOW (window), FALSE);
+ g_return_val_if_fail (page >= 0 && page < window->priv->n_pages, FALSE);
+
+ if (! window->priv->window_size[page].saved)
+ return FALSE;
+
+ if (width != NULL)
+ *width = window->priv->window_size[page].width;
+ if (height != NULL)
+ *height = window->priv->window_size[page].height;
+
+ return TRUE;
+}
diff --git a/src/gth-window.h b/src/gth-window.h
index 3e2ad37..c10a661 100644
--- a/src/gth-window.h
+++ b/src/gth-window.h
@@ -16,8 +16,7 @@
* 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., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GTH_WINDOW_H
@@ -27,12 +26,21 @@
G_BEGIN_DECLS
+#define GTH_WINDOW_PAGE_UNDEFINED -1
+
typedef enum { /*< skip >*/
GTH_WINDOW_MENUBAR,
GTH_WINDOW_TOOLBAR,
+ GTH_WINDOW_INFOBAR,
GTH_WINDOW_STATUSBAR,
} GthWindowArea;
+typedef struct { /*< skip >*/
+ gboolean saved;
+ int width;
+ int height;
+} GthWindowSize;
+
#define GTH_TYPE_WINDOW (gth_window_get_type ())
#define GTH_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTH_TYPE_WINDOW, GthWindow))
#define GTH_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTH_TYPE_WINDOW, GthWindowClass))
@@ -72,19 +80,27 @@ void gth_window_attach_toolbar (GthWindow *window,
void gth_window_attach_content (GthWindow *window,
int page,
GtkWidget *child);
-GtkWidget * gth_window_attach_get_content (GthWindow *window,
- int page);
void gth_window_set_current_page (GthWindow *window,
int page);
int gth_window_get_current_page (GthWindow *window);
void gth_window_show_only_content (GthWindow *window,
gboolean only_content);
-
-/**/
-
-int gth_window_get_n_windows (void);
-GList * gth_window_get_window_list (void);
-GtkWidget * gth_window_get_current_window (void);
+GtkWidget * gth_window_get_area (GthWindow *window,
+ GthWindowArea area);
+GtkWidget * gth_window_get_content (GthWindow *window,
+ int n_page);
+void gth_window_save_page_size (GthWindow *window,
+ int page,
+ int width,
+ int height);
+void gth_window_apply_saved_size (GthWindow *window,
+ int page);
+gboolean gth_window_get_page_size (GthWindow *window,
+ int page,
+ int *width,
+ int *height);
+void gth_window_clear_saved_size (GthWindow *window,
+ int page);
G_END_DECLS
diff --git a/src/main.c b/src/main.c
index 9faa26a..cba8bd1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -209,6 +209,9 @@ goo_restore_session (EggSMClient *client,
/* -- main application -- */
+GtkApplication *Main_Application = NULL;
+
+
typedef struct {
GtkApplication __parent;
GSettings *settings;
@@ -246,7 +249,6 @@ goo_application_activate (GApplication *application)
GtkWidget *window;
window = goo_window_new (NULL);
- gtk_window_set_application (GTK_WINDOW (window), GTK_APPLICATION (application));
gtk_widget_show (window);
}
@@ -722,7 +724,7 @@ main (int argc, char *argv[])
/* run the main application */
- application = goo_application_new ();
+ application = Main_Application = goo_application_new ();
status = g_application_run (G_APPLICATION (application), argc, argv);
g_object_unref (application);
diff --git a/src/main.h b/src/main.h
index ec6f572..ebb136c 100644
--- a/src/main.h
+++ b/src/main.h
@@ -27,8 +27,9 @@
#include "goo-player.h"
#include "goo-window.h"
-extern int arg_auto_play;
-extern int arg_toggle_visibility;
+extern GtkApplication *Main_Application;
+extern int arg_auto_play;
+extern int arg_toggle_visibility;
GtkWidget * main_get_window_from_device (const char *device);
BraseroDrive * main_get_most_likely_drive (void);
diff --git a/src/preferences.h b/src/preferences.h
index 5de9892..6808dd7 100644
--- a/src/preferences.h
+++ b/src/preferences.h
@@ -38,7 +38,6 @@
#define PREF_GENERAL_USE_SJ "use-sound-juicer"
#define PREF_GENERAL_AUTOPLAY "autoplay"
-#define PREF_UI_PLAYLIST "playlist-visible"
#define PREF_UI_WINDOW_WIDTH "window-width"
#define PREF_UI_WINDOW_HEIGHT "window-height"
diff --git a/src/ui/Makefile.am b/src/ui/Makefile.am
index 5fe73da..85e7ae6 100644
--- a/src/ui/Makefile.am
+++ b/src/ui/Makefile.am
@@ -3,6 +3,7 @@ EXTRA_DIST = \
cover-chooser.ui \
extract.ui \
format-options.ui \
+ goobox.css \
menu-toolbars.ui \
preferences.ui \
properties.ui \
diff --git a/src/ui/cover-chooser.ui b/src/ui/cover-chooser.ui
index 3bbc216..33bd90d 100644
--- a/src/ui/cover-chooser.ui
+++ b/src/ui/cover-chooser.ui
@@ -20,32 +20,12 @@
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
- <object class="GtkButton" id="help_button">
- <property name="label">gtk-help</property>
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- <property name="secondary">True</property>
- </packing>
- </child>
- <child>
<object class="GtkButton" id="revert_button">
<property name="label">gtk-undo</property>
- <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
</object>
<packing>
@@ -57,12 +37,10 @@
<child>
<object class="GtkButton" id="ok_button">
<property name="label">gtk-apply</property>
- <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
</object>
<packing>
@@ -74,12 +52,10 @@
<child>
<object class="GtkButton" id="cancel_button">
<property name="label">gtk-close</property>
- <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
</object>
<packing>
@@ -127,11 +103,9 @@
</child>
<child>
<object class="GtkButton" id="cancel_search_button">
- <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="relief">none</property>
<child>
<object class="GtkImage" id="image1">
@@ -200,7 +174,6 @@
</object>
</child>
<action-widgets>
- <action-widget response="-11">help_button</action-widget>
<action-widget response="-7">revert_button</action-widget>
<action-widget response="-10">ok_button</action-widget>
<action-widget response="-7">cancel_button</action-widget>
diff --git a/src/ui/extract.ui b/src/ui/extract.ui
index 901e37f..7e20678 100644
--- a/src/ui/extract.ui
+++ b/src/ui/extract.ui
@@ -2,6 +2,7 @@
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkDialog" id="extract_dialog">
+ <property name="width_request">300</property>
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes">Extract Tracks</property>
@@ -22,12 +23,10 @@
<child>
<object class="GtkButton" id="cancel_button">
<property name="label">gtk-cancel</property>
- <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
</object>
<packing>
@@ -38,12 +37,10 @@
</child>
<child>
<object class="GtkButton" id="ok_button">
- <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<child>
<placeholder/>
</child>
@@ -54,24 +51,6 @@
<property name="position">1</property>
</packing>
</child>
- <child>
- <object class="GtkButton" id="help_button">
- <property name="label">gtk-help</property>
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- <property name="secondary">True</property>
- </packing>
- </child>
</object>
<packing>
<property name="expand">False</property>
@@ -87,19 +66,20 @@
<property name="border_width">5</property>
<property name="spacing">12</property>
<child>
- <object class="GtkVBox" id="vbox9">
+ <object class="GtkVBox" id="vbox11">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
- <object class="GtkLabel" id="label7">
+ <object class="GtkRadioButton" id="all_tracks_radiobutton">
+ <property name="label" translatable="yes">_All tracks</property>
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">Extract</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
@@ -108,85 +88,19 @@
</packing>
</child>
<child>
- <object class="GtkHBox" id="hbox5">
+ <object class="GtkRadioButton" id="selected_tracks_radiobutton">
+ <property name="label" translatable="yes">_Selected tracks</property>
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkLabel" id="label8">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes"> </property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkVBox" id="vbox10">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkVBox" id="vbox11">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkRadioButton" id="all_tracks_radiobutton">
- <property name="label" translatable="yes">_All tracks</property>
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="xalign">0</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkRadioButton" id="selected_tracks_radiobutton">
- <property name="label" translatable="yes">_Selected tracks</property>
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="xalign">0</property>
- <property name="draw_indicator">True</property>
- <property name="group">all_tracks_radiobutton</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">all_tracks_radiobutton</property>
</object>
<packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
@@ -209,7 +123,6 @@
<action-widgets>
<action-widget response="-6">cancel_button</action-widget>
<action-widget response="-5">ok_button</action-widget>
- <action-widget response="-11">help_button</action-widget>
</action-widgets>
</object>
</interface>
diff --git a/src/ui/goobox.css b/src/ui/goobox.css
new file mode 100644
index 0000000..c4e2f9f
--- /dev/null
+++ b/src/ui/goobox.css
@@ -0,0 +1,32 @@
+GtkWindow.goobox-main-window {
+ background-color: @theme_base_color;
+ color: @text_color;
+}
+
+.goobox-info-album {
+ font-size: 15;
+ font-weight: bold;
+}
+
+.goobox-info-artist {
+ font-size: 12;
+}
+
+.goobox-info-track {
+ color: mix (@theme_fg_color, @theme_bg_color, 0.50);
+}
+
+.goobox-info-time {
+ padding-top: 10px;
+ color: mix (@theme_fg_color, @theme_bg_color, 0.50);
+}
+
+.goobox-player-bar {
+ background-color: @bg_color;
+ border: 0;
+}
+
+.goobox-cover-frame GtkButton:hover {
+ border-image-width: 0;
+ border-radius: 0;
+}
diff --git a/src/ui/menu-toolbars.ui b/src/ui/menu-toolbars.ui
index dc07d92..032871e 100644
--- a/src/ui/menu-toolbars.ui
+++ b/src/ui/menu-toolbars.ui
@@ -1,12 +1,4 @@
<ui>
- <toolbar name="ToolBar">
- <toolitem action="TogglePlay"/>
- <toolitem action="Play"/>
- <toolitem action="Pause"/>
- <toolitem action="Next"/>
- <separator />
- <toolitem action="Extract"/>
- </toolbar>
<popup name="ListPopupMenu">
<menuitem action="PlaySelected"/>
<menuitem action="ExtractSelected"/>
@@ -26,7 +18,7 @@
<separator name="sep01"/>
<menuitem action="RemoveCover"/>
</popup>
- <popup name="ActionsMenu">
+ <popup name="OtherActionsMenu">
<menuitem action="CopyDisc"/>
<menuitem action="Eject"/>
<separator />
@@ -43,4 +35,4 @@
<accelerator action="ExtractAccel" />
<accelerator action="PropertiesAccel" />
<accelerator action="CloseAccel" />
-</ui>
\ No newline at end of file
+</ui>
diff --git a/src/ui/preferences.ui b/src/ui/preferences.ui
index 2274826..f25fca5 100644
--- a/src/ui/preferences.ui
+++ b/src/ui/preferences.ui
@@ -20,32 +20,12 @@
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
- <object class="GtkButton" id="help_button">
- <property name="label">gtk-help</property>
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- <property name="secondary">True</property>
- </packing>
- </child>
- <child>
<object class="GtkButton" id="close_button">
<property name="label">gtk-close</property>
- <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
</object>
<packing>
@@ -130,11 +110,9 @@
<child>
<object class="GtkCheckButton" id="autoplay_checkbutton">
<property name="label" translatable="yes">Automatically play newly inserted discs</property>
- <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
@@ -227,15 +205,15 @@
</child>
</object>
<packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
- <property name="fill">True</property>
+ <property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
@@ -297,11 +275,9 @@
<child>
<object class="GtkButton" id="filetype_properties_button">
<property name="label">gtk-properties</property>
- <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
</object>
<packing>
@@ -313,8 +289,8 @@
</child>
</object>
<packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
@@ -432,15 +408,15 @@
</child>
</object>
<packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
@@ -453,7 +429,7 @@
</child>
</object>
<packing>
- <property name="expand">True</property>
+ <property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
@@ -468,11 +444,9 @@
<child>
<object class="GtkCheckButton" id="save_playlist_checkbutton">
<property name="label" translatable="yes">_Save playlist</property>
- <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
@@ -516,7 +490,6 @@
</object>
</child>
<action-widgets>
- <action-widget response="-11">help_button</action-widget>
<action-widget response="-7">close_button</action-widget>
</action-widgets>
</object>
diff --git a/src/ui/properties.ui b/src/ui/properties.ui
index 7e8a62a..d3f7836 100644
--- a/src/ui/properties.ui
+++ b/src/ui/properties.ui
@@ -39,32 +39,12 @@
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
- <object class="GtkButton" id="help_button">
- <property name="label">gtk-help</property>
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- <property name="secondary">True</property>
- </packing>
- </child>
- <child>
<object class="GtkButton" id="undo_button">
<property name="label">gtk-undo</property>
- <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
</object>
<packing>
@@ -76,12 +56,10 @@
<child>
<object class="GtkButton" id="cancel_button">
<property name="label">gtk-cancel</property>
- <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
</object>
<packing>
@@ -93,12 +71,10 @@
<child>
<object class="GtkButton" id="ok_button">
<property name="label">gtk-ok</property>
- <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
</object>
<packing>
@@ -145,7 +121,7 @@
</object>
<packing>
<property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
+ <property name="y_options"/>
</packing>
</child>
<child>
@@ -178,7 +154,7 @@
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
+ <property name="y_options"/>
</packing>
</child>
<child>
@@ -237,7 +213,7 @@
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
+ <property name="y_options"/>
</packing>
</child>
<child>
@@ -247,11 +223,9 @@
<property name="spacing">6</property>
<child>
<object class="GtkCheckButton" id="year_checkbutton">
- <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="focus_on_click">False</property>
<property name="xalign">0.5</property>
@@ -306,12 +280,10 @@
</child>
<child>
<object class="GtkButton" id="search_button">
- <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Search for the remaining data</property>
- <property name="use_action_appearance">False</property>
<child>
<object class="GtkImage" id="image5">
<property name="visible">True</property>
@@ -397,11 +369,9 @@
<property name="spacing">12</property>
<child>
<object class="GtkButton" id="prev_album_button">
- <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="relief">none</property>
<child>
<object class="GtkImage" id="image3">
@@ -431,11 +401,9 @@
</child>
<child>
<object class="GtkButton" id="next_album_button">
- <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="relief">none</property>
<child>
<object class="GtkImage" id="image4">
@@ -532,7 +500,6 @@
</object>
</child>
<action-widgets>
- <action-widget response="-11">help_button</action-widget>
<action-widget response="-6">undo_button</action-widget>
<action-widget response="-6">cancel_button</action-widget>
<action-widget response="-5">ok_button</action-widget>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]