marlin r1291 - trunk/marlin
- From: iain svn gnome org
- To: svn-commits-list gnome org
- Subject: marlin r1291 - trunk/marlin
- Date: Thu, 2 Oct 2008 23:55:52 +0000 (UTC)
Author: iain
Date: Thu Oct 2 23:55:52 2008
New Revision: 1291
URL: http://svn.gnome.org/viewvc/marlin?rev=1291&view=rev
Log:
Bring sample-view up to date too
Modified:
trunk/marlin/ChangeLog
trunk/marlin/marlin-sample-view.c
Modified: trunk/marlin/marlin-sample-view.c
==============================================================================
--- trunk/marlin/marlin-sample-view.c (original)
+++ trunk/marlin/marlin-sample-view.c Thu Oct 2 23:55:52 2008
@@ -2,7 +2,7 @@
/*
* Authors: Iain Holmes <iain gnome org>
*
- * Copyright 2002 - 2006 Iain Holmes
+ * Copyright 2002 - 2008 Iain Holmes
*
* This file is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU Library General Public
@@ -102,16 +102,16 @@
guint32 add_id, remove_id, move_id; /* Signal handlers for the
add-marker, remove-marker and
move-marker signals */
-
+
MarlinSampleSelection *selection; /* Taken from the sample
FIXME: Should this be
a property of the view
rather than the sample? */
guint32 changed_id; /* Signal handler for selection-changed */
-
+
guint64 number_of_frames; /* Taken from the sample */
guint number_of_channels; /* Taken from the sample */
-
+
guint frames_per_pixel; /* Number of frames represented in one pixel */
int xofs; /* The x offset in pixels */
@@ -128,7 +128,7 @@
gboolean in_selection;
gboolean expand; /* Are we expanding an already added selection? */
gboolean made_selection; /* We made a selection when we clicked */
-
+
guint32 scroll_timeout_id;
/* List of struct _VMarkers */
@@ -144,14 +144,14 @@
gboolean moving_selection; /* Are we grabbing the selection? */
guint64 grab_position; /* Position we grabbed the selection at
when we are moving it */
-
+
gboolean using_hand; /* Is the hand being shown? */
MarlinCoverage sel_coverage, orig_coverage;
guint64 sel_start, sel_finish, orig_start, orig_finish;
guint64 sel_initial;
MarlinUndoContext *sel_ctxt; /* For when we start and finish drags */
-
+
int base_offset;
MarlinSampleDrawContext *dc;
@@ -170,9 +170,11 @@
int drag_drop_point;
};
-static GtkWidgetClass *parent_class = NULL;
static guint signals[LAST_SIGNAL];
+#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MARLIN_SAMPLE_VIEW_TYPE, MarlinSampleViewPrivate))
+G_DEFINE_TYPE (MarlinSampleView, marlin_sample_view, GTK_TYPE_WIDGET);
+
#define DEFAULT_FRAMES_PER_PIXEL 4096
#define DEFAULT_CHANNELS 2
@@ -210,12 +212,12 @@
cursor->gc = gdk_gc_new (widget->window);
gdk_gc_copy (cursor->gc, widget->style->black_gc);
-
+
gdk_gc_set_function (cursor->gc, GDK_INVERT);
-
+
return cursor;
}
-
+
static void
destroy_cursor (MarlinCursorInfo *cursor)
{
@@ -261,14 +263,14 @@
if (view->priv->position_to_markers == NULL) {
view->priv->position_to_markers = g_hash_table_new (NULL, NULL);
}
-
+
for (p = marks; p; p = p->next) {
struct _VMarker *vm = g_new (struct _VMarker, 1);
vm->marker = p->data;
vm->real_position = vm->marker->position;
vm->real_name = g_strdup (vm->marker->name);
-
+
view->priv->markers = g_list_prepend (view->priv->markers, vm);
g_hash_table_insert (view->priv->marker_to_view, p->data, vm);
}
@@ -279,12 +281,8 @@
{
MarlinSampleView *view;
MarlinSampleViewPrivate *priv;
-
- view = MARLIN_SAMPLE_VIEW (object);
- if (view->priv == NULL) {
- return;
- }
+ view = MARLIN_SAMPLE_VIEW (object);
priv = view->priv;
gdk_cursor_unref (priv->i_bar);
@@ -334,10 +332,7 @@
marlin_sample_draw_context_free (priv->dc);
- g_free (priv);
- priv = NULL;
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (marlin_sample_view_parent_class)->finalize (object);
}
static void
@@ -355,7 +350,7 @@
priv->hadj->page_size = widget->allocation.width;
priv->hadj->page_increment = widget->allocation.width / 2;
priv->hadj->step_increment = 20;
-
+
priv->hadj->lower = 0;
if (priv->number_of_frames == 0) {
priv->hadj->upper = widget->allocation.width;
@@ -3067,12 +3062,12 @@
}
static void
-class_init (MarlinSampleViewClass *klass)
+marlin_sample_view_class_init (MarlinSampleViewClass *klass)
{
GObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkBindingSet *binding_set;
-
+
object_class = G_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
@@ -3090,11 +3085,11 @@
widget_class->motion_notify_event = motion_notify_event;
widget_class->focus_in_event = focus_in_event;
widget_class->focus_out_event = focus_out_event;
-
+
klass->set_scroll_adjustments = set_scroll_adjustments;
klass->move_cursor = real_move_cursor;
-
- parent_class = g_type_class_peek_parent (klass);
+
+ g_type_class_add_private (object_class, sizeof (MarlinSampleViewPrivate));
/* Properties */
g_object_class_install_property (object_class,
@@ -3125,9 +3120,9 @@
g_param_spec_uint64 ("play_position",
"", "",
0, G_MAXUINT64,
- 0,
+ 0,
G_PARAM_READWRITE));
-
+
g_object_class_install_property (object_class,
PROP_CURSOR_COVERAGE,
g_param_spec_enum ("cursor_coverage",
@@ -3225,7 +3220,7 @@
GTK_MOVEMENT_LOGICAL_POSITIONS, 1);
add_move_binding (binding_set, GDK_KP_Left, 0,
GTK_MOVEMENT_LOGICAL_POSITIONS, -1);
-
+
add_move_binding (binding_set, GDK_Right, GDK_CONTROL_MASK,
GTK_MOVEMENT_LOGICAL_POSITIONS, 5);
add_move_binding (binding_set, GDK_Left, GDK_CONTROL_MASK,
@@ -3234,7 +3229,7 @@
GTK_MOVEMENT_LOGICAL_POSITIONS, 5);
add_move_binding (binding_set, GDK_KP_Left, GDK_CONTROL_MASK,
GTK_MOVEMENT_LOGICAL_POSITIONS, -5);
-
+
add_move_binding (binding_set, GDK_Page_Up, 0,
GTK_MOVEMENT_LOGICAL_POSITIONS, 50);
add_move_binding (binding_set, GDK_Page_Down, 0,
@@ -3243,7 +3238,7 @@
GTK_MOVEMENT_LOGICAL_POSITIONS, 50);
add_move_binding (binding_set, GDK_KP_Page_Down, 0,
GTK_MOVEMENT_LOGICAL_POSITIONS, -50);
-
+
add_move_binding (binding_set, GDK_Page_Up, GDK_CONTROL_MASK,
GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1);
add_move_binding (binding_set, GDK_Page_Down, GDK_CONTROL_MASK,
@@ -3252,7 +3247,7 @@
GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1);
add_move_binding (binding_set, GDK_KP_Page_Down, GDK_CONTROL_MASK,
GTK_MOVEMENT_DISPLAY_LINE_ENDS, -1);
-
+
/* Using GTK_MOVEMENT_DISPLAY_LINE_ENDS as if it were
GTK_MOVEMENT_DISPLAY_PAGE_ENDS */
add_move_binding (binding_set, GDK_Home, 0,
@@ -3275,14 +3270,14 @@
}
static void
-init (MarlinSampleView *view)
+marlin_sample_view_init (MarlinSampleView *view)
{
MarlinSampleViewPrivate *priv;
PangoRectangle rect;
-
+
GTK_WIDGET_SET_FLAGS (view, GTK_CAN_FOCUS);
-
- view->priv = g_new0 (MarlinSampleViewPrivate, 1);
+
+ view->priv = GET_PRIVATE (view);
priv = view->priv;
priv->frames_per_pixel = DEFAULT_FRAMES_PER_PIXEL;
@@ -3304,41 +3299,20 @@
priv->base_offset = 0;
- priv->dc = marlin_sample_draw_context_new (NULL,
+ priv->dc = marlin_sample_draw_context_new (NULL,
DEFAULT_FRAMES_PER_PIXEL,
TRUE);
-
if (!gtk_style_lookup_color (GTK_WIDGET (view)->style, "marker",
&priv->marker_colour)) {
GdkColormap *cmap = gdk_colormap_get_system ();
g_print ("Using default\n");
priv->marker_colour.red = 65535;
-
- gdk_colormap_alloc_color (cmap, &priv->marker_colour,
- FALSE, TRUE);
- }
-}
-GType
-marlin_sample_view_get_type (void)
-{
- static GType type = 0;
-
- if (type == 0) {
- GTypeInfo info = {
- sizeof (MarlinSampleViewClass), NULL, NULL,
- (GClassInitFunc) class_init, NULL, NULL,
- sizeof (MarlinSampleView), 0, (GInstanceInitFunc) init
- };
-
- type = g_type_register_static (GTK_TYPE_WIDGET,
- "MarlinSampleView",
- &info, 0);
+ gdk_colormap_alloc_color (cmap, &priv->marker_colour,
+ FALSE, TRUE);
}
-
- return type;
}
GtkWidget *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]