Commit 66f7bdad authored by Colin Walters's avatar Colin Walters Committed by Colin Walters
Browse files

More cut&paste stuff. Deletion appears to work now.

2003-07-28  Colin Walters  <walters@verbum.org>

	* HACKING:
	* lib/Makefile.am:
	* shell/rb-shell-clipboard.c: (rb_shell_clipboard_set_property),
	(rb_shell_clipboard_sync), (rb_shell_clipboard_cmd_cut),
	(rb_shell_clipboard_cmd_copy), (rb_shell_clipboard_cmd_paste),
	(rb_shell_clipboard_cmd_delete), (node_destroyed_cb),
	(rb_shell_clipboard_nodeview_changed_cb):
	* shell/rb-shell-player.c:
	* sources/rb-iradio-source.c: (rb_iradio_source_class_init),
	(impl_get_browser_key), (impl_delete):
	* sources/rb-library-source.c: (rb_library_source_class_init),
	(rb_library_source_browser_views_activated_cb), (impl_delete):
	* sources/rb-source.c: (rb_source_class_init), (default_copy):
	* sources/rb-source.h:

	More cut&paste stuff.  Deletion appears to work now.
parent 643e8ff6
2003-07-28 Colin Walters <walters@verbum.org>
* HACKING:
* lib/Makefile.am:
* shell/rb-shell-clipboard.c: (rb_shell_clipboard_set_property),
(rb_shell_clipboard_sync), (rb_shell_clipboard_cmd_cut),
(rb_shell_clipboard_cmd_copy), (rb_shell_clipboard_cmd_paste),
(rb_shell_clipboard_cmd_delete), (node_destroyed_cb),
(rb_shell_clipboard_nodeview_changed_cb):
* shell/rb-shell-player.c:
* sources/rb-iradio-source.c: (rb_iradio_source_class_init),
(impl_get_browser_key), (impl_delete):
* sources/rb-library-source.c: (rb_library_source_class_init),
(rb_library_source_browser_views_activated_cb), (impl_delete):
* sources/rb-source.c: (rb_source_class_init), (default_copy):
* sources/rb-source.h:
More cut&paste stuff. Deletion appears to work now.
2003-07-28 Colin Walters <walters@verbum.org>
* AUTHORS:
......
......@@ -4,8 +4,18 @@ need to stick to in order to get your patch accepted:
- use 8-space tabs for indentation
- curly brackets are NOT on a new line, except for function definitions.
(we are slowly converting the code)
- if statements are written like this: "if (this != that)"
- g_list_next/previous is preferred to list->next or list->previous
- every function should have a prototype
- callback functions have a suffix _cb
Here is a correctly indented sample:
Important comment blocks are written like this:
/**
* bla_bla_cb: This is an example comment block
*/
Here is a correctly indented code sample:
void
foo (const char *bla, gpointer cow)
......@@ -18,17 +28,6 @@ foo (const char *bla, gpointer cow)
...
}
- if statements are written like this: "if (this != that)"
- g_list_next/previous is preferred to list->next or list->previous
- every function should have a prototype
- callback functions have a suffix _cb
Important comment blocks are written like this:
/**
* bla_bla_cb: This is an example comment block
*/
You may commit small, obvious fixes to this module. Anything larger
should be run by Colin Walters <walters@debian.org>, unless you
know I've given you blanket commit permission.
......@@ -29,6 +29,8 @@ librb_la_SOURCES = \
rb-cut-and-paste-code.h \
rb-thread-helpers.c \
rb-thread-helpers.h \
rb-util.c \
rb-util.h \
rb-windows-ini-file.c \
rb-windows-ini-file.h \
rb-enums.h \
......
/*
* Copyright (C) 2003 Colin Walters <walters@verbum.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
*/
#include "rb-util.h"
gboolean
rb_true_function (gpointer dummy, ...)
{
return TRUE;
}
gboolean
rb_false_function (gpointer dummy, ...)
{
return FALSE;
}
/*
* Copyright (C) 2003 Colin Walters <walters@verbum.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
*/
#ifndef __RB_UTIL_H
#define __RB_UTIL_H
#include <stdarg.h>
#include <glib/gtypes.h>
G_BEGIN_DECLS
gboolean rb_true_function (gpointer dummy, ...);
gboolean rb_false_function (gpointer dummy, ...);
G_END_DECLS
#endif /* __RB_UTIL_H */
......@@ -21,6 +21,7 @@
#include "rb-shell-clipboard.h"
#include "rb-node.h"
#include "rb-debug.h"
#include "rb-bonobo-helpers.h"
static void rb_shell_clipboard_class_init (RBShellClipboardClass *klass);
......@@ -51,6 +52,8 @@ static void rb_shell_clipboard_set (RBShellClipboard *clipboard,
GList *nodes);
static void node_destroyed_cb (RBNode *node,
RBShellClipboard *clipboard);
static void rb_shell_clipboard_nodeview_changed_cb (RBNodeView *view,
RBShellClipboard *clipboard);
#define CMD_PATH_CUT "/commands/Cut"
#define CMD_PATH_COPY "/commands/Copy"
......@@ -184,9 +187,28 @@ rb_shell_clipboard_set_property (GObject *object,
switch (prop_id)
{
case PROP_SOURCE:
if (clipboard->priv->source != NULL)
{
RBNodeView *songs = rb_source_get_node_view (clipboard->priv->source);
g_signal_handlers_disconnect_by_func (G_OBJECT (songs),
G_CALLBACK (rb_shell_clipboard_nodeview_changed_cb),
clipboard);
}
clipboard->priv->source = g_value_get_object (value);
rb_debug ("selected source %p", g_value_get_object (value));
rb_shell_clipboard_sync (clipboard);
if (clipboard->priv->source != NULL)
{
RBNodeView *songs = rb_source_get_node_view (clipboard->priv->source);
g_signal_connect (G_OBJECT (songs),
"changed",
G_CALLBACK (rb_shell_clipboard_nodeview_changed_cb),
clipboard);
}
break;
case PROP_COMPONENT:
clipboard->priv->component = g_value_get_object (value);
......@@ -254,6 +276,8 @@ rb_shell_clipboard_sync (RBShellClipboard *clipboard)
gboolean can_paste = have_selection;
gboolean can_delete = have_selection;
gboolean can_copy = have_selection;
rb_debug ("syncing clipboard");
if (have_selection)
can_cut = can_paste = rb_source_can_cut (clipboard->priv->source);
......@@ -267,8 +291,8 @@ rb_shell_clipboard_sync (RBShellClipboard *clipboard)
CMD_PATH_CUT,
can_cut);
rb_bonobo_set_sensitive (clipboard->priv->component,
CMD_PATH_PASTE,
can_paste);
CMD_PATH_DELETE,
can_delete);
rb_bonobo_set_sensitive (clipboard->priv->component,
CMD_PATH_COPY,
can_copy);
......@@ -276,7 +300,7 @@ rb_shell_clipboard_sync (RBShellClipboard *clipboard)
can_paste = can_paste && g_list_length (clipboard->priv->nodes) > 0;
rb_bonobo_set_sensitive (clipboard->priv->component,
CMD_PATH_DELETE,
CMD_PATH_PASTE,
can_paste);
/* We do it here because the song list view doesnt know about
* the global paste status */
......@@ -289,6 +313,7 @@ rb_shell_clipboard_cmd_cut (BonoboUIComponent *component,
RBShellClipboard *clipboard,
const char *verbname)
{
rb_debug ("cut");
rb_shell_clipboard_set (clipboard,
rb_source_cut (clipboard->priv->source));
}
......@@ -298,6 +323,7 @@ rb_shell_clipboard_cmd_copy (BonoboUIComponent *component,
RBShellClipboard *clipboard,
const char *verbname)
{
rb_debug ("copy");
rb_shell_clipboard_set (clipboard,
rb_source_copy (clipboard->priv->source));
}
......@@ -307,6 +333,7 @@ rb_shell_clipboard_cmd_paste (BonoboUIComponent *component,
RBShellClipboard *clipboard,
const char *verbname)
{
rb_debug ("paste");
rb_source_paste (clipboard->priv->source, clipboard->priv->nodes);
}
......@@ -315,6 +342,7 @@ rb_shell_clipboard_cmd_delete (BonoboUIComponent *component,
RBShellClipboard *clipboard,
const char *verbname)
{
rb_debug ("delete");
rb_source_delete (clipboard->priv->source);
}
......@@ -355,3 +383,11 @@ node_destroyed_cb (RBNode *node,
rb_shell_clipboard_sync (clipboard);
}
static void
rb_shell_clipboard_nodeview_changed_cb (RBNodeView *view,
RBShellClipboard *clipboard)
{
rb_debug ("nodeview changed");
rb_shell_clipboard_sync (clipboard);
}
......@@ -133,7 +133,6 @@ static void cancel_buffering_clicked_cb (GtkWidget *button,
gpointer data);
void buffering_end_cb (MonkeyMediaPlayer *player, gpointer data);
void buffering_begin_cb (MonkeyMediaPlayer *player, gpointer data);
static gboolean have_song_selection (RBShellPlayer *shell);
#define MENU_PATH_PLAY "/menu/Controls/Play"
#define TRAY_PATH_PLAY "/popups/TrayPopup/Play"
......
......@@ -34,6 +34,7 @@
#include "rb-glade-helpers.h"
#include "rb-stock-icons.h"
#include "rb-node-view.h"
#include "rb-util.h"
#include "rb-file-helpers.h"
#include "rb-preferences.h"
#include "rb-dialog.h"
......@@ -85,10 +86,8 @@ static const char *impl_get_description (RBSource *source);
static GdkPixbuf *impl_get_pixbuf (RBSource *source);
static RBNodeView *impl_get_node_view (RBSource *source);
static void impl_search (RBSource *source, const char *text);
static void impl_delete (RBSource *source);
static void impl_song_properties (RBSource *source);
static gboolean impl_can_pause (RBSource *player);
static gboolean impl_have_artist_album (RBSource *player);
static gboolean impl_have_url (RBSource *player);
static RBSourceEOFType impl_handle_eos (RBSource *asource);
static void impl_buffering_done (RBSource *asource);
......@@ -202,11 +201,13 @@ rb_iradio_source_class_init (RBIRadioSourceClass *klass)
source_class->impl_get_pixbuf = impl_get_pixbuf;
source_class->impl_search = impl_search;
source_class->impl_get_node_view = impl_get_node_view;
source_class->impl_can_delete = (RBSourceFeatureFunc) rb_true_function;
source_class->impl_delete = impl_delete;
source_class->impl_song_properties = impl_song_properties;
source_class->impl_can_pause = impl_can_pause;
source_class->impl_can_pause = (RBSourceFeatureFunc) rb_false_function;
source_class->impl_handle_eos = impl_handle_eos;
source_class->impl_have_artist_album = impl_have_artist_album;
source_class->impl_have_url = impl_have_url;
source_class->impl_have_artist_album = (RBSourceFeatureFunc) rb_false_function;
source_class->impl_have_url = (RBSourceFeatureFunc) rb_true_function;
source_class->impl_buffering_done = impl_buffering_done;
g_object_class_install_property (object_class,
......@@ -420,24 +421,6 @@ impl_get_node_view (RBSource *asource)
return source->priv->stations;
}
gboolean
impl_can_pause (RBSource *source)
{
return FALSE;
}
static gboolean
impl_have_artist_album (RBSource *source)
{
return FALSE;
}
static gboolean
impl_have_url (RBSource *source)
{
return TRUE;
}
static RBSourceEOFType
impl_handle_eos (RBSource *asource)
{
......@@ -506,6 +489,16 @@ impl_get_browser_key (RBSource *asource)
return CONF_STATE_SHOW_BROWSER;
}
static void
impl_delete (RBSource *asource)
{
RBIRadioSource *source = RB_IRADIO_SOURCE (asource);
GList *l;
for (l = rb_node_view_get_selection (source->priv->stations); l != NULL; l = g_list_next (l))
rb_iradio_backend_remove_node (source->priv->backend, l->data);
}
static void
impl_song_properties (RBSource *asource)
{
......
......@@ -34,6 +34,7 @@
#include "rb-glade-helpers.h"
#include "rb-stock-icons.h"
#include "rb-node-view.h"
#include "rb-util.h"
#include "rb-file-helpers.h"
#include "rb-dialog.h"
#include "rb-volume.h"
......@@ -99,14 +100,12 @@ static const char *impl_get_description (RBSource *source);
static GdkPixbuf *impl_get_pixbuf (RBSource *source);
static RBNodeView *impl_get_node_view (RBSource *source);
static GList *impl_get_extra_views (RBSource *source);
static void impl_delete (RBSource *source);
static void impl_search (RBSource *source, const char *text);
static GtkWidget *impl_get_config_widget (RBSource *source);
static void impl_song_properties (RBSource *source);
static gboolean impl_can_pause (RBSource *player);
static gboolean impl_have_artist_album (RBSource *player);
static const char * impl_get_artist (RBSource *player);
static const char * impl_get_album (RBSource *player);
static gboolean impl_have_url (RBSource *player);
/* Misc */
static const char *impl_get_status_fast (RBLibrarySource *source);
......@@ -230,11 +229,15 @@ rb_library_source_class_init (RBLibrarySourceClass *klass)
source_class->impl_get_extra_views = impl_get_extra_views;
source_class->impl_get_config_widget = impl_get_config_widget;
source_class->impl_song_properties = impl_song_properties;
source_class->impl_can_pause = impl_can_pause;
source_class->impl_have_artist_album = impl_have_artist_album;
source_class->impl_can_pause = (RBSourceFeatureFunc) rb_true_function;
source_class->impl_can_cut = (RBSourceFeatureFunc) rb_false_function;
source_class->impl_can_copy = (RBSourceFeatureFunc) rb_true_function;
source_class->impl_can_delete = (RBSourceFeatureFunc) rb_true_function;
source_class->impl_delete = impl_delete;
source_class->impl_have_artist_album = (RBSourceFeatureFunc) rb_true_function;
source_class->impl_get_artist = impl_get_artist;
source_class->impl_get_album = impl_get_album;
source_class->impl_have_url = impl_have_url;
source_class->impl_have_url = (RBSourceFeatureFunc) rb_false_function;
g_object_class_install_property (object_class,
PROP_LIBRARY,
......@@ -715,18 +718,6 @@ impl_get_config_widget (RBSource *asource)
return source->priv->config_widget;
}
gboolean
impl_can_pause (RBSource *source)
{
return TRUE;
}
static gboolean
impl_have_artist_album (RBSource *source)
{
return TRUE;
}
static const char *
impl_get_artist (RBSource *asource)
{
......@@ -755,12 +746,6 @@ impl_get_album (RBSource *asource)
return NULL;
}
static gboolean
impl_have_url (RBSource *source)
{
return FALSE;
}
static const char *
impl_get_status (RBSource *asource)
{
......@@ -868,6 +853,16 @@ rb_library_source_browser_views_activated_cb (GtkWidget *widget,
eel_gconf_set_integer (CONF_UI_LIBRARY_BROWSER_VIEWS, index);
}
static void
impl_delete (RBSource *asource)
{
RBLibrarySource *source = RB_LIBRARY_SOURCE (asource);
GList *l;
for (l = rb_node_view_get_selection (source->priv->songs); l != NULL; l = g_list_next (l))
rb_library_remove_node (source->priv->library, l->data);
}
static void
impl_song_properties (RBSource *asource)
{
......
......@@ -42,13 +42,14 @@ static void rb_source_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
const char * default_get_browser_key (RBSource *status);
GList *default_get_extra_views (RBSource *source);
gboolean default_can_cut (RBSource *source);
void default_song_properties (RBSource *source);
GtkWidget * default_get_config_widget (RBSource *source);
RBSourceEOFType default_handle_eos (RBSource *source);
void default_buffering_done (RBSource *source);
static const char * default_get_browser_key (RBSource *status);
static GList *default_get_extra_views (RBSource *source);
static gboolean default_can_cut (RBSource *source);
static GList *default_copy (RBSource *source);
static void default_song_properties (RBSource *source);
static GtkWidget * default_get_config_widget (RBSource *source);
static RBSourceEOFType default_handle_eos (RBSource *source);
static void default_buffering_done (RBSource *source);
struct RBSourcePrivate
{
......@@ -125,6 +126,7 @@ rb_source_class_init (RBSourceClass *klass)
klass->impl_can_cut = default_can_cut;
klass->impl_can_delete = default_can_cut;
klass->impl_can_copy = default_can_cut;
klass->impl_copy = default_copy;
klass->impl_song_properties = default_song_properties;
klass->impl_handle_eos = default_handle_eos;
klass->impl_buffering_done = default_buffering_done;
......@@ -278,7 +280,7 @@ rb_source_get_status (RBSource *status)
return klass->impl_get_status (status);
}
const char *
static const char *
default_get_browser_key (RBSource *status)
{
return NULL;
......@@ -312,7 +314,7 @@ rb_source_get_node_view (RBSource *source)
return klass->impl_get_node_view (source);
}
GList *
static GList *
default_get_extra_views (RBSource *source)
{
return NULL;
......@@ -350,7 +352,7 @@ rb_source_search (RBSource *source, const char *text)
klass->impl_search (source, text);
}
GtkWidget *
static GtkWidget *
default_get_config_widget (RBSource *source)
{
return NULL;
......@@ -364,7 +366,7 @@ rb_source_get_config_widget (RBSource *source)
return klass->impl_get_config_widget (source);
}
gboolean
static gboolean
default_can_cut (RBSource *source)
{
return FALSE;
......@@ -401,6 +403,12 @@ rb_source_cut (RBSource *source)
return klass->impl_cut (source);
}
static GList *
default_copy (RBSource *source)
{
return g_list_copy (rb_node_view_get_selection (rb_source_get_node_view (source)));
}
GList *
rb_source_copy (RBSource *source)
......@@ -426,7 +434,7 @@ rb_source_delete (RBSource *source)
klass->impl_delete (source);
}
void
static void
default_song_properties (RBSource *source)
{
rb_error_dialog (_("No properties available."));
......@@ -448,7 +456,7 @@ rb_source_can_pause (RBSource *source)
return klass->impl_can_pause (source);
}
RBSourceEOFType
static RBSourceEOFType
default_handle_eos (RBSource *source)
{
return RB_SOURCE_EOF_NEXT;
......@@ -494,7 +502,7 @@ rb_source_have_url (RBSource *source)
return klass->impl_have_url (source);
}
void
static void
default_buffering_done (RBSource *source)
{
rb_debug ("No implementation of buffering_done for active source");
......
......@@ -96,6 +96,8 @@ typedef struct
} RBSourceClass;
typedef gboolean (*RBSourceFeatureFunc) (RBSource *source);
GType rb_source_get_type (void);
void rb_source_notify_filter_changed (RBSource *source);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment