* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/*
# include "config.h"
#endif
-#include <gtk/gtksignal.h>
-#include <gtk/gtkbutton.h>
-#include <gtk/gtkmisc.h>
+#include <glib.h>
#include <gtk/gtk.h>
-#include <gtk/gtkbox.h>
-#include <gtk/gtkmain.h>
-
+#include "utils.h"
#include "gtkvscrollbutton.h"
#define SCROLL_TIMER_LENGTH 20
static void gtk_vscrollbutton_class_init(GtkVScrollbuttonClass * klass);
static void gtk_vscrollbutton_init(GtkVScrollbutton * vscrollbutton);
-GtkType gtk_vscrollbutton_get_type (void);
+GType gtk_vscrollbutton_get_type (void);
GtkWidget *gtk_vscrollbutton_new (GtkAdjustment *adjustment);
static gint gtk_vscrollbutton_button_release (GtkWidget *widget,
static void gtk_vscrollbutton_set_sensitivity (GtkAdjustment *adjustment,
GtkVScrollbutton *scrollbutton);
-GtkType gtk_vscrollbutton_get_type(void)
+GType gtk_vscrollbutton_get_type(void)
{
- static GtkType vscrollbutton_type = 0;
+ static GType vscrollbutton_type = 0;
if (!vscrollbutton_type) {
- static const GtkTypeInfo vscrollbutton_info = {
- "GtkVScrollbutton",
- sizeof(GtkVScrollbutton),
- sizeof(GtkVScrollbuttonClass),
- (GtkClassInitFunc) gtk_vscrollbutton_class_init,
- (GtkObjectInitFunc) gtk_vscrollbutton_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
+ static const GTypeInfo vscrollbutton_info = {
+ sizeof (GtkVScrollbuttonClass),
+
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+
+ (GClassInitFunc) gtk_vscrollbutton_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+
+ sizeof (GtkVScrollbutton),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gtk_vscrollbutton_init,
};
- vscrollbutton_type =
- gtk_type_unique(GTK_TYPE_VBOX, &vscrollbutton_info);
+ vscrollbutton_type = g_type_register_static (GTK_TYPE_VBOX, "GtkVScrollbutton", &vscrollbutton_info, (GTypeFlags)0);
}
return vscrollbutton_type;
{
}
+static GdkCursor *hand_cursor = NULL;
+
+static gboolean vscroll_visi_notify(GtkWidget *widget,
+ GdkEventVisibility *event,
+ gpointer data)
+{
+ gdk_window_set_cursor(widget->window, hand_cursor);
+ return FALSE;
+}
+
+static gboolean vscroll_leave_notify(GtkWidget *widget,
+ GdkEventCrossing *event,
+ gpointer data)
+{
+ gdk_window_set_cursor(widget->window, NULL);
+ return FALSE;
+}
+
+static gboolean vscroll_enter_notify(GtkWidget *widget,
+ GdkEventCrossing *event,
+ gpointer data)
+{
+ gdk_window_set_cursor(widget->window, hand_cursor);
+ return FALSE;
+}
+
+
static void gtk_vscrollbutton_init(GtkVScrollbutton *scrollbutton)
{
GtkWidget *arrow;
- scrollbutton->upbutton = gtk_button_new();
- scrollbutton->downbutton = gtk_button_new();
+
+ if (!hand_cursor)
+ hand_cursor = gdk_cursor_new(GDK_HAND2);
+
+ scrollbutton->upbutton = gtk_event_box_new();
+ scrollbutton->downbutton = gtk_event_box_new();
arrow = gtk_arrow_new(GTK_ARROW_UP, GTK_SHADOW_NONE);
gtk_widget_show(arrow);
gtk_container_add(GTK_CONTAINER(scrollbutton->upbutton), arrow);
gtk_widget_show(scrollbutton->downbutton);
gtk_widget_show(scrollbutton->upbutton);
+ g_signal_connect(G_OBJECT(scrollbutton->upbutton), "motion-notify-event",
+ G_CALLBACK(vscroll_visi_notify), NULL);
+ g_signal_connect(G_OBJECT(scrollbutton->upbutton), "leave-notify-event",
+ G_CALLBACK(vscroll_leave_notify), NULL);
+ g_signal_connect(G_OBJECT(scrollbutton->upbutton), "enter-notify-event",
+ G_CALLBACK(vscroll_enter_notify), NULL);
+ g_signal_connect(G_OBJECT(scrollbutton->downbutton), "motion-notify-event",
+ G_CALLBACK(vscroll_visi_notify), NULL);
+ g_signal_connect(G_OBJECT(scrollbutton->downbutton), "leave-notify-event",
+ G_CALLBACK(vscroll_leave_notify), NULL);
+ g_signal_connect(G_OBJECT(scrollbutton->downbutton), "enter-notify-event",
+ G_CALLBACK(vscroll_enter_notify), NULL);
+
g_signal_connect(G_OBJECT(scrollbutton->upbutton),
"button_press_event",
G_CALLBACK(gtk_vscrollbutton_button_press),
GtkWidget *gtk_vscrollbutton_new(GtkAdjustment *adjustment)
{
GtkWidget *vscrollbutton;
- vscrollbutton = GTK_WIDGET(gtk_type_new(gtk_vscrollbutton_get_type()));
+ vscrollbutton = g_object_new (gtk_vscrollbutton_get_type(),
+ NULL);
gtk_vscrollbutton_set_adjustment(GTK_VSCROLLBUTTON(vscrollbutton),
adjustment);
g_signal_connect(G_OBJECT(GTK_VSCROLLBUTTON(vscrollbutton)->adjustment),
void gtk_vscrollbutton_set_adjustment(GtkVScrollbutton *scrollbutton,
GtkAdjustment *adjustment)
{
- g_return_if_fail(scrollbutton != NULL);
- g_return_if_fail(GTK_IS_VSCROLLBUTTON(scrollbutton));
+ cm_return_if_fail(scrollbutton != NULL);
+ cm_return_if_fail(GTK_IS_VSCROLLBUTTON(scrollbutton));
if (!adjustment)
adjustment =
GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
else
- g_return_if_fail(GTK_IS_ADJUSTMENT(adjustment));
+ cm_return_if_fail(GTK_IS_ADJUSTMENT(adjustment));
if (scrollbutton->adjustment != adjustment) {
if (scrollbutton->adjustment) {
scrollbutton->adjustment = adjustment;
g_object_ref(G_OBJECT(adjustment));
- gtk_object_sink(GTK_OBJECT(adjustment));
+#if GLIB_CHECK_VERSION(2,10,0)
+ g_object_ref_sink (G_OBJECT(adjustment));
+#else
+ gtk_object_ref (G_OBJECT (adjustment));
+ gtk_object_sink (G_OBJECT (adjustment));
+#endif
}
}
gfloat new_value;
gint return_val;
- g_return_val_if_fail(scrollbutton != NULL, FALSE);
- g_return_val_if_fail(GTK_IS_VSCROLLBUTTON(scrollbutton), FALSE);
+ cm_return_val_if_fail(scrollbutton != NULL, FALSE);
+ cm_return_val_if_fail(GTK_IS_VSCROLLBUTTON(scrollbutton), FALSE);
new_value = scrollbutton->adjustment->value;
return_val = TRUE;
* above, we might have been removed, and another added.
*/
g_source_remove(scrollbutton->timer);
- scrollbutton->timer = gtk_timeout_add(SCROLL_LATER_DELAY,
- (GtkFunction)
- gtk_real_vscrollbutton_timer,
- scrollbutton);
+ scrollbutton->timer = g_timeout_add(SCROLL_LATER_DELAY,
+ (GtkFunction)
+ gtk_real_vscrollbutton_timer,
+ scrollbutton);
}
g_object_unref(G_OBJECT(scrollbutton));
return FALSE; /* don't keep calling this function */
static void gtk_vscrollbutton_add_timer(GtkVScrollbutton *scrollbutton)
{
- g_return_if_fail(scrollbutton != NULL);
- g_return_if_fail(GTK_IS_VSCROLLBUTTON(scrollbutton));
+ cm_return_if_fail(scrollbutton != NULL);
+ cm_return_if_fail(GTK_IS_VSCROLLBUTTON(scrollbutton));
if (!scrollbutton->timer) {
scrollbutton->need_timer = TRUE;
- scrollbutton->timer = gtk_timeout_add(SCROLL_INITIAL_DELAY,
- (GtkFunction)
- gtk_vscrollbutton_timer_1st_time,
- scrollbutton);
+ scrollbutton->timer = g_timeout_add(SCROLL_INITIAL_DELAY,
+ (GtkFunction)
+ gtk_vscrollbutton_timer_1st_time,
+ scrollbutton);
}
}
static void gtk_vscrollbutton_remove_timer(GtkVScrollbutton *scrollbutton)
{
- g_return_if_fail(scrollbutton != NULL);
- g_return_if_fail(GTK_IS_VSCROLLBUTTON(scrollbutton));
+ cm_return_if_fail(scrollbutton != NULL);
+ cm_return_if_fail(GTK_IS_VSCROLLBUTTON(scrollbutton));
if (scrollbutton->timer) {
- gtk_timeout_remove(scrollbutton->timer);
+ g_source_remove(scrollbutton->timer);
scrollbutton->timer = 0;
}
scrollbutton->need_timer = FALSE;
return_val = FALSE;
if (scrollbutton->need_timer)
scrollbutton->timer =
- gtk_timeout_add(SCROLL_TIMER_LENGTH,
- (GtkFunction) gtk_real_vscrollbutton_timer,
- (gpointer) scrollbutton);
+ g_timeout_add(SCROLL_TIMER_LENGTH,
+ (GtkFunction) gtk_real_vscrollbutton_timer,
+ (gpointer) scrollbutton);
else {
GDK_THREADS_LEAVE();
return FALSE;