changeset 2494:59661bd074b4 trunk

[svn] Try to put some skinned window code in a common place.
author nenolod
date Sat, 10 Feb 2007 17:01:44 -0800
parents b7f48f00a342
children 6fb56e6bc6ec
files ChangeLog src/audacious/Makefile src/audacious/build_stamp.c src/audacious/ui_equalizer.c src/audacious/ui_main.c src/audacious/ui_playlist.c src/audacious/ui_skinned_cursor.c src/audacious/ui_skinned_cursor.h src/audacious/ui_skinned_window.c src/audacious/ui_skinned_window.h src/audacious/util.c
diffstat 11 files changed, 312 insertions(+), 65 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Feb 10 12:29:21 2007 -0800
+++ b/ChangeLog	Sat Feb 10 17:01:44 2007 -0800
@@ -1,3 +1,12 @@
+2007-02-10 20:29:21 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
+  revision [3996]
+  - patch from Mark Glines to ad https:// URI support to playlists.
+  
+  trunk/src/audacious/playlist.c   |    5 +++++
+  trunk/src/audacious/ui_credits.c |    1 +
+  2 files changed, 6 insertions(+)
+
+
 2007-02-10 06:30:10 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
   revision [3994]
   - use ConfigureNotify to set playlist location, a proper use of ICCCM.
--- a/src/audacious/Makefile	Sat Feb 10 12:29:21 2007 -0800
+++ b/src/audacious/Makefile	Sat Feb 10 17:01:44 2007 -0800
@@ -87,13 +87,15 @@
 	ui_manager.c \
 	ui_playlist.c \
 	ui_preferences.c \
+	ui_skinned_cursor.c \
+	ui_skinned_window.c \
 	ui_skinselector.c \
 	ui_urlopener.c \
 	urldecode.c \
 	util.c \
+	vfs.c \
 	vfs_buffer.c \
 	vfs_buffered_file.c \
-	vfs.c \
 	vfs_common.c \
 	visualization.c \
 	xconvert.c
--- a/src/audacious/build_stamp.c	Sat Feb 10 12:29:21 2007 -0800
+++ b/src/audacious/build_stamp.c	Sat Feb 10 17:01:44 2007 -0800
@@ -1,2 +1,2 @@
 #include <glib.h>
-const gchar *svn_stamp = "20070210-3994";
+const gchar *svn_stamp = "20070210-3996";
--- a/src/audacious/ui_equalizer.c	Sat Feb 10 12:29:21 2007 -0800
+++ b/src/audacious/ui_equalizer.c	Sat Feb 10 17:01:44 2007 -0800
@@ -52,6 +52,8 @@
 
 #include "images/audacious_eq.xpm"
 
+#include "ui_skinned_window.h"
+
 enum PresetViewCols {
     PRESET_VIEW_COL_NAME,
     PRESET_VIEW_N_COLS
@@ -422,15 +424,9 @@
         event->x /= 2;
         event->y /= 2;
     }
-    if (dock_is_moving(GTK_WINDOW(equalizerwin)))
-    {
-        dock_move_motion(GTK_WINDOW(equalizerwin), event);
-    }
-    else 
-    {
-        handle_motion_cb(equalizerwin_wlist, widget, event);
-        draw_equalizer_window(FALSE);
-    }
+
+    handle_motion_cb(equalizerwin_wlist, widget, event);
+    draw_equalizer_window(FALSE);
 
     gdk_flush();
 
@@ -748,7 +744,7 @@
     GdkPixbuf *icon;
     gint width, height;
 
-    equalizerwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+    equalizerwin = ui_skinned_window_new(GTK_WINDOW_TOPLEVEL);
     gtk_window_set_title(GTK_WINDOW(equalizerwin), _("Audacious Equalizer"));
     gtk_window_set_wmclass(GTK_WINDOW(equalizerwin), "equalizer", "Audacious");
     gtk_window_set_role(GTK_WINDOW(equalizerwin), "equalizer");
@@ -783,14 +779,6 @@
         gtk_window_move(GTK_WINDOW(equalizerwin),
                         cfg.equalizer_x, cfg.equalizer_y);
 
-    gtk_widget_set_events(equalizerwin,
-                          GDK_FOCUS_CHANGE_MASK | GDK_BUTTON_MOTION_MASK |
-                          GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
-                          GDK_VISIBILITY_NOTIFY_MASK);
-    gtk_widget_realize(equalizerwin);
-
-    util_set_cursor(equalizerwin);
-
     g_signal_connect(equalizerwin, "delete_event",
                      G_CALLBACK(equalizerwin_delete), NULL);
     g_signal_connect(equalizerwin, "button_press_event",
--- a/src/audacious/ui_main.c	Sat Feb 10 12:29:21 2007 -0800
+++ b/src/audacious/ui_main.c	Sat Feb 10 17:01:44 2007 -0800
@@ -82,6 +82,8 @@
 #include "util.h"
 #include "visualization.h"
 
+#include "ui_skinned_window.h"
+
 static GTimeVal cb_time; /* click delay for tristate is defined by TRISTATE_THRESHOLD */
 
 #define ITEM_SEPARATOR {"/-", NULL, NULL, 0, "<Separator>"}
@@ -441,8 +443,6 @@
 
     g_source_remove(mainwin_timeout_id);
 
-    util_set_cursor(NULL);
-
     bmp_config_save();
     gtk_accel_map_save(bmp_paths[BMP_PATH_ACCEL_FILE]);
 
@@ -1020,14 +1020,13 @@
     int x, y;
     GdkModifierType state;
 
+    /* If it's a hint, we had to query X, so override the 
+     * information we we're given... it's probably useless... --nenolod
+     */
     if (event->is_hint != FALSE)
     {
-        gdk_window_get_pointer(GDK_WINDOW(mainwin->window),
-        &x, &y, &state);
-
-    /* If it's a hint, we had to query X, so override the 
-         * information we we're given... it's probably useless... --nenolod
-     */
+        gdk_window_get_pointer(GDK_WINDOW(mainwin->window), &x, &y, &state);
+
         event->x = x;
         event->y = y;
         event->state = state;
@@ -1042,9 +1041,6 @@
         event->x /= 2;
         event->y /= 2;
     }
-    if (dock_is_moving(GTK_WINDOW(mainwin))) {
-        dock_move_motion(GTK_WINDOW(mainwin), event);
-    }
     else {
         handle_motion_cb(mainwin_wlist, widget, event);
         draw_main_window(FALSE);
@@ -3404,7 +3400,7 @@
 {
     gint width, height;
 
-    mainwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+    mainwin = ui_skinned_window_new(GTK_WINDOW_TOPLEVEL);
     gtk_window_set_title(GTK_WINDOW(mainwin), _("Audacious"));
     gtk_window_set_wmclass(GTK_WINDOW(mainwin), "player", "Audacious");
     gtk_window_set_role(GTK_WINDOW(mainwin), "player");
@@ -3419,7 +3415,6 @@
     }
 
     gtk_widget_set_size_request(mainwin, width, height);
-    gtk_widget_set_app_paintable(mainwin, TRUE);
 
     dock_window_list = dock_window_set_decorated(dock_window_list,
                                                  GTK_WINDOW(mainwin),
@@ -3428,15 +3423,6 @@
     if (cfg.player_x != -1 && cfg.save_window_position)
         gtk_window_move(GTK_WINDOW(mainwin), cfg.player_x, cfg.player_y);
 
-    gtk_widget_add_events(mainwin,
-                          GDK_FOCUS_CHANGE_MASK | GDK_BUTTON_MOTION_MASK |
-                          GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
-                          GDK_SCROLL_MASK | GDK_KEY_PRESS_MASK |
-                          GDK_VISIBILITY_NOTIFY_MASK);
-    gtk_widget_realize(mainwin);
-
-    util_set_cursor(mainwin);
-
     g_signal_connect(mainwin, "destroy", G_CALLBACK(mainwin_destroy), NULL);
     g_signal_connect(mainwin, "button_press_event",
                      G_CALLBACK(mainwin_mouse_button_press), NULL);
--- a/src/audacious/ui_playlist.c	Sat Feb 10 12:29:21 2007 -0800
+++ b/src/audacious/ui_playlist.c	Sat Feb 10 17:01:44 2007 -0800
@@ -53,6 +53,8 @@
 #include "ui_manager.h"
 #include "util.h"
 
+#include "ui_skinned_window.h"
+
 #include "icons-stock.h"
 #include "images/audacious_playlist.xpm"
 
@@ -1668,7 +1670,7 @@
 {
     GdkPixbuf *icon;
 
-    playlistwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+    playlistwin = ui_skinned_window_new(GTK_WINDOW_TOPLEVEL);
     gtk_window_set_title(GTK_WINDOW(playlistwin), _("Audacious Playlist Editor"));
     gtk_window_set_wmclass(GTK_WINDOW(playlistwin), "playlist", "Audacious");
     gtk_window_set_role(GTK_WINDOW(playlistwin), "playlist");
@@ -1701,8 +1703,6 @@
                           GDK_SCROLL_MASK | GDK_VISIBILITY_NOTIFY_MASK);
     gtk_widget_realize(playlistwin);
 
-    util_set_cursor(playlistwin);
-
     g_signal_connect(playlistwin, "delete_event",
                      G_CALLBACK(playlistwin_delete), NULL);
     g_signal_connect(playlistwin, "button_press_event",
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audacious/ui_skinned_cursor.c	Sat Feb 10 17:01:44 2007 -0800
@@ -0,0 +1,54 @@
+/*
+ * Audacious: A cross-platform multimedia player
+ * Copyright (c) 2007 William Pitcock <nenolod -at- sacredspiral.co.uk>
+ *
+ * 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; under version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include "platform/smartinclude.h"
+
+#include <gtk/gtkmain.h>
+#include <glib-object.h>
+#include <glib/gmacros.h>
+#include <gtk/gtkmarshal.h>
+#include <gtk/gtkwindow.h>
+
+#include "main.h"
+#include "dock.h"
+#include "ui_skinned_window.h"
+#include "ui_skinned_cursor.h"
+
+void
+ui_skinned_cursor_set(GtkWidget * window)
+{
+    static GdkCursor *cursor = NULL;
+
+    if (window == NULL)
+    {
+        if (cursor != NULL)
+        {
+            gdk_cursor_unref(cursor);
+            cursor = NULL;
+        }
+
+        return;
+    }
+
+    if (cursor == NULL)
+        cursor = gdk_cursor_new(GDK_LEFT_PTR);
+
+    gdk_window_set_cursor(window->window, cursor);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audacious/ui_skinned_cursor.h	Sat Feb 10 17:01:44 2007 -0800
@@ -0,0 +1,25 @@
+/*
+ * Audacious: A cross-platform multimedia player
+ * Copyright (c) 2007 William Pitcock <nenolod -at- sacredspiral.co.uk>
+ *
+ * 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; under version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef UI_SKINNED_CURSOR_H
+#define UI_SKINNED_CURSOR_H
+
+void ui_skinned_cursor_set(GtkWidget * window);
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audacious/ui_skinned_window.c	Sat Feb 10 17:01:44 2007 -0800
@@ -0,0 +1,157 @@
+/*
+ * Audacious: A cross-platform multimedia player
+ * Copyright (c) 2007 William Pitcock <nenolod -at- sacredspiral.co.uk>
+ *
+ * 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; under version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include "platform/smartinclude.h"
+
+#include <gtk/gtkmain.h>
+#include <glib-object.h>
+#include <glib/gmacros.h>
+#include <gtk/gtkmarshal.h>
+#include <gtk/gtkwindow.h>
+
+#include "main.h"
+#include "dock.h"
+#include "ui_skinned_window.h"
+#include "ui_skinned_cursor.h"
+
+static void ui_skinned_window_class_init(SkinnedWindowClass *klass);
+static void ui_skinned_window_init(GtkWidget *widget);
+static GtkWindowClass *parent = NULL;
+
+GType
+ui_skinned_window_get_type(void)
+{
+  static GType window_type = 0;
+
+  if (!window_type)
+    {
+      static const GTypeInfo window_info =
+      {
+        sizeof (SkinnedWindowClass),
+        NULL,           /* base_init */
+        NULL,           /* base_finalize */
+        (GClassInitFunc) ui_skinned_window_class_init,
+        NULL,           /* class_finalize */
+        NULL,           /* class_data */
+        sizeof (SkinnedWindow),
+        0,              /* n_preallocs */
+        (GInstanceInitFunc) ui_skinned_window_init
+      };
+
+      window_type =
+        g_type_register_static (GTK_TYPE_WINDOW, "SkinnedWindow",
+                                &window_info, 0);
+    }
+
+  return window_type;
+}
+
+static gboolean
+ui_skinned_window_configure(GtkWidget *widget,
+                            GdkEventConfigure *event)
+{
+    GtkWidgetClass *widget_class;
+    SkinnedWindow *window = SKINNED_WINDOW(widget);
+
+    widget_class = (GtkWidgetClass*) parent;
+
+    if (widget_class->configure_event != NULL)
+        widget_class->configure_event(widget, event);
+
+    window->x = event->x;
+    window->y = event->y;
+
+    return FALSE;
+}
+
+static gboolean
+ui_skinned_window_motion_notify_event(GtkWidget *widget,
+                                      GdkEventMotion *event)
+{
+    GtkWidgetClass *widget_class;
+
+    widget_class = (GtkWidgetClass*) parent;
+
+    if (widget_class->motion_notify_event != NULL)
+        widget_class->motion_notify_event(widget, event);
+
+    if (dock_is_moving(GTK_WINDOW(widget)))
+        dock_move_motion(GTK_WINDOW(widget), event);
+
+    return FALSE;
+}
+
+static void
+ui_skinned_window_class_init(SkinnedWindowClass *klass)
+{
+    GtkWidgetClass *widget_class;
+
+    widget_class = (GtkWidgetClass*) klass;
+
+    parent = gtk_type_class(gtk_window_get_type());
+
+    widget_class->configure_event = ui_skinned_window_configure;
+    widget_class->motion_notify_event = ui_skinned_window_motion_notify_event;
+}
+
+void
+ui_skinned_window_hide(SkinnedWindow *window)
+{
+    g_return_if_fail(SKINNED_CHECK_WINDOW(window));
+
+    gtk_window_get_position(GTK_WINDOW(window), &window->x, &window->y);
+    gtk_widget_hide(GTK_WIDGET(window));
+}
+
+void
+ui_skinned_window_show(SkinnedWindow *window)
+{
+    g_return_if_fail(SKINNED_CHECK_WINDOW(window));
+
+    gtk_window_move(GTK_WINDOW(window), window->x, window->y);
+    gtk_widget_show_all(GTK_WIDGET(window));
+}
+
+static void
+ui_skinned_window_init(GtkWidget *widget)
+{
+    SkinnedWindow *window;
+    window = SKINNED_WINDOW(widget);
+}
+
+GtkWidget *
+ui_skinned_window_new(GtkWindowType type)
+{
+    GtkWidget *widget = g_object_new(ui_skinned_window_get_type(), NULL);
+
+    gtk_widget_add_events(GTK_WIDGET(widget),
+                          GDK_FOCUS_CHANGE_MASK | GDK_BUTTON_MOTION_MASK |
+                          GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
+                          GDK_SCROLL_MASK | GDK_KEY_PRESS_MASK |
+                          GDK_VISIBILITY_NOTIFY_MASK);
+    gtk_widget_realize(GTK_WIDGET(widget));
+
+    dock_window_list = dock_window_set_decorated(dock_window_list,
+	GTK_WINDOW(widget), cfg.show_wm_decorations);
+    gtk_widget_set_app_paintable(GTK_WIDGET(widget), TRUE);
+
+    ui_skinned_cursor_set(GTK_WIDGET(widget));
+
+    return widget;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audacious/ui_skinned_window.h	Sat Feb 10 17:01:44 2007 -0800
@@ -0,0 +1,46 @@
+/*
+ * Audacious: A cross-platform multimedia player
+ * Copyright (c) 2007 William Pitcock <nenolod -at- sacredspiral.co.uk>
+ *
+ * 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; under version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef UI_SKINNED_WINDOW_H
+#define UI_SKINNED_WINDOW_H
+
+#define SKINNED_WINDOW(obj)          GTK_CHECK_CAST (obj, ui_skinned_window_get_type (), SkinnedWindow)
+#define SKINNED_WINDOW_CLASS(klass)  GTK_CHECK_CLASS_CAST (klass, ui_skinned_window_get_type (), SkinnedWindowClass)
+#define SKINNED_CHECK_WINDOW(obj)    GTK_CHECK_TYPE (obj, ui_skinned_window_get_type ())
+#define SKINNED_TYPE_WINDOW          (ui_skinned_window_get_type())
+
+typedef struct _SkinnedWindow SkinnedWindow;
+typedef struct _SkinnedWindowClass SkinnedWindowClass;
+
+struct _SkinnedWindow
+{
+  GtkWindow window;
+
+  GtkWidget *canvas;
+  gint x,y;
+};
+
+struct _SkinnedWindowClass
+{
+  GtkWindowClass        parent_class;
+};
+
+extern GtkWidget *ui_skinned_window_new(GtkWindowType type);
+
+#endif
--- a/src/audacious/util.c	Sat Feb 10 12:29:21 2007 -0800
+++ b/src/audacious/util.c	Sat Feb 10 17:01:44 2007 -0800
@@ -598,26 +598,6 @@
 }
 #endif
 
-void
-util_set_cursor(GtkWidget * window)
-{
-    static GdkCursor *cursor = NULL;
-
-    if (!window) {
-        if (cursor) {
-            gdk_cursor_unref(cursor);
-            cursor = NULL;
-        }
-
-        return;
-    }
-
-    if (!cursor)
-        cursor = gdk_cursor_new(GDK_LEFT_PTR);
-
-    gdk_window_set_cursor(window->window, cursor);
-}
-
 /* text_get_extents() taken from The GIMP (C) Spencer Kimball, Peter
  * Mattis et al */
 gboolean