gossip r2812 - in trunk: . data/pixmaps src



Author: rhult
Date: Sun May 18 17:10:59 2008
New Revision: 2812
URL: http://svn.gnome.org/viewvc/gossip?rev=2812&view=rev

Log:
2008-05-18  Richard Hult  <richard imendio com>

	* data/pixmaps/Makefile.am: Add temporary dock icon for new
	message (copied from gnome-icon-theme, GPL), will need a better
	one.

	* src/Makefile.am:
	* src/gossip-app.c: (app_setup):
	* src/gossip-mac-dock.[ch]: Use the dock to display new messages
	on mac.


Added:
   trunk/data/pixmaps/gossip-mac-overlay-new-message.png   (contents, props changed)
   trunk/src/gossip-mac-dock.c
   trunk/src/gossip-mac-dock.h
Modified:
   trunk/ChangeLog
   trunk/data/pixmaps/Makefile.am
   trunk/src/gossip-app.c

Modified: trunk/data/pixmaps/Makefile.am
==============================================================================
--- trunk/data/pixmaps/Makefile.am	(original)
+++ trunk/data/pixmaps/Makefile.am	Sun May 18 17:10:59 2008
@@ -1,5 +1,4 @@
 imagedir = $(datadir)/gossip
-
 image_DATA =				\
 	gossip-logo.png			\
 	gossip-offline.png		\
@@ -12,9 +11,15 @@
 	gossip-typing.png		\
 	gossip-group-message.png 	\
 	gossip-file-transfer.png        \
+	gossip-mac-overlay-new-message.png \
 	vcard_16.png			\
 	vcard_48.png
 
+macdir = $(datadir)/gossip
+if HAVE_PLATFORM_OSX
+mac_DATA = gossip-mac-overlay-new-message.png
+endif
+
 icon16dir = $(datadir)/icons/hicolor/16x16/apps
 icon16_DATA = 16x16/gossip.png
 
@@ -53,4 +58,5 @@
 	$(icon32_DATA)  \
 	$(icon48_DATA)  \
 	$(svgicon_DATA) \
-	$(image_DATA)
+	$(image_DATA)	\
+	$(mac_DATA)

Added: trunk/data/pixmaps/gossip-mac-overlay-new-message.png
==============================================================================
Binary file. No diff available.

Modified: trunk/src/gossip-app.c
==============================================================================
--- trunk/src/gossip-app.c	(original)
+++ trunk/src/gossip-app.c	Sun May 18 17:10:59 2008
@@ -74,6 +74,10 @@
 #include "gossip-vcard-dialog.h"
 #include "ephy-spinner.h"
 
+#ifdef GDK_WINDOWING_QUARTZ
+#include "gossip-mac-dock.h"
+#endif
+
 #ifdef HAVE_DBUS
 #include "gossip-dbus.h"
 #endif
@@ -148,6 +152,11 @@
 	GtkWidget             *popup_menu_status_item;
 	GtkWidget             *popup_menu_show_list_item;
 
+	/* Dock */
+#ifdef GDK_WINDOWING_QUARTZ
+	GossipDock            *dock;
+#endif
+
 	/* Throbber */
 	GtkWidget             *throbber;
 
@@ -290,6 +299,7 @@
 					      GossipApp             *app);
 static void     app_status_icon_create_menu  (void);
 static void     app_status_icon_create       (void);
+static void     app_setup_dock               (void);
 static gboolean 
 app_status_icon_check_embedded_cb            (gpointer               user_data);
 static void     app_notify_show_offline_cb   (GossipConf            *conf,
@@ -906,6 +916,8 @@
 	/* Setup the contact list */
 	app_setup_contact_list (sw, show_offline_widget);
 
+	app_setup_dock ();
+
 	/* Set window to be hidden. If doesn't have status icon, show window
 	 * and mask "chat_hide_list".
 	 */
@@ -1478,6 +1490,29 @@
 }
 
 static void
+app_setup_dock (void)
+{
+#ifdef GDK_WINDOWING_QUARTZ
+	GossipAppPriv *priv;
+	GossipConf    *conf;
+	gboolean       hidden;
+
+	priv = GET_PRIV (app);
+
+	priv->dock = gossip_dock_get ();
+
+	conf = gossip_conf_get ();
+	gossip_conf_get_bool (conf,
+			      GOSSIP_PREFS_UI_MAIN_WINDOW_HIDDEN,
+			      &hidden);
+
+	if (!hidden) {
+		gtk_widget_show (priv->window);
+	}
+#endif
+}
+
+static void
 app_chat_show_offline_cb (GtkCheckMenuItem *item,
 			  GossipApp        *app)
 {

Added: trunk/src/gossip-mac-dock.c
==============================================================================
--- (empty file)
+++ trunk/src/gossip-mac-dock.c	Sun May 18 17:10:59 2008
@@ -0,0 +1,231 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008 Imendio AB
+ *
+ * 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 Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <ige-mac-integration.h>
+
+#include "libgossip/gossip-stock.h"
+#include "libgossip/gossip-paths.h"
+
+#include "gossip-app.h"
+#include "gossip-mac-dock.h"
+
+typedef struct {
+        GList *events;
+} GossipDockPriv;
+
+static void dock_finalize         (GObject            *object);
+static void dock_clicked_cb       (IgeMacDock         *dock);
+static void dock_event_added_cb   (GossipEventManager *manager,
+                                   GossipEvent        *event,
+                                   GossipDock         *dock);
+static void dock_event_removed_cb (GossipEventManager *manager,
+                                   GossipEvent        *event,
+                                   GossipDock         *dock);
+
+G_DEFINE_TYPE (GossipDock, gossip_dock, IGE_TYPE_MAC_DOCK);
+#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GOSSIP_TYPE_DOCK, GossipDockPriv))
+
+static void
+gossip_dock_class_init (GossipDockClass *klass)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->finalize = dock_finalize;
+
+        g_type_class_add_private (object_class, sizeof (GossipDockPriv));
+}
+
+static void
+gossip_dock_init (GossipDock *dock)
+{
+        /*gtk_dock_set_from_stock (GOSSIP_DOCK (dock),
+          GOSSIP_STOCK_OFFLINE);*/
+
+        g_signal_connect (gossip_app_get_event_manager (), "event-added",
+                          G_CALLBACK (dock_event_added_cb),
+                          dock);
+
+        g_signal_connect (gossip_app_get_event_manager (), "event-removed",
+                          G_CALLBACK (dock_event_removed_cb),
+                          dock);
+
+        g_signal_connect (dock, "clicked",
+                          G_CALLBACK (dock_clicked_cb),
+                          dock);
+}
+
+static void
+dock_finalize (GObject *object)
+{
+        GossipDockPriv *priv;
+
+        priv = GET_PRIV (object);
+
+        g_signal_handlers_disconnect_by_func (gossip_app_get_event_manager (),
+                                              dock_event_added_cb,
+                                              object);
+
+        g_signal_handlers_disconnect_by_func (gossip_app_get_event_manager (),
+                                              dock_event_removed_cb,
+                                              object);
+
+        G_OBJECT_CLASS (gossip_dock_parent_class)->finalize (object);
+}
+
+static GossipEvent *
+dock_get_next_event (GossipDock *dock)
+{
+        GossipDockPriv *priv;
+
+        priv = GET_PRIV (dock);
+
+	if (priv->events) {
+		return priv->events->data;
+	}
+
+	return NULL;
+}
+
+static void
+dock_clicked_cb (IgeMacDock *dock)
+{
+        GossipDockPriv *priv;
+
+        priv = GET_PRIV (dock);
+
+        if (!priv->events) {
+                gossip_app_set_visibility (TRUE);
+        } else {
+                gossip_event_manager_activate (gossip_app_get_event_manager (),
+                                               dock_get_next_event (GOSSIP_DOCK (dock)));
+        }
+}
+
+static GdkPixbuf *
+dock_get_event_pixbuf (GossipDock *dock)
+{
+        GossipDockPriv *priv;
+	GossipEvent    *event;
+	gchar          *path;
+	GdkPixbuf      *pixbuf;
+
+        priv = GET_PRIV (dock);
+
+        event = dock_get_next_event (dock);
+	if (!event) {
+		return NULL;
+	}
+
+	path = gossip_paths_get_image_path ("gossip-mac-overlay-new-message.png");
+	pixbuf = gdk_pixbuf_new_from_file (path, NULL);
+	g_free (path);
+
+	return pixbuf;
+}
+
+static void
+dock_update_overlay (GossipDock *dock)
+{
+	GdkPixbuf *pixbuf;
+
+	pixbuf = dock_get_event_pixbuf (dock);
+	if (pixbuf) {
+		ige_mac_dock_set_overlay_from_pixbuf (IGE_MAC_DOCK (dock), pixbuf);
+		g_object_unref (pixbuf);
+	} else {
+		gchar     *path;
+		GdkPixbuf *pixbuf;
+
+		path = gossip_paths_get_image_path ("gossip-logo.png");
+		pixbuf = gdk_pixbuf_new_from_file (path, NULL);
+		g_free (path);
+
+		if (pixbuf) {
+			ige_mac_dock_set_icon_from_pixbuf (IGE_MAC_DOCK (dock), pixbuf);
+			g_object_unref (pixbuf);
+		}
+	}
+}
+
+static void
+dock_add_event (GossipDock *dock, GossipEvent *event)
+{
+        GossipDockPriv *priv;
+        GList          *l;
+
+        priv = GET_PRIV (dock);
+
+        l = g_list_find_custom (priv->events, event, gossip_event_compare);
+        if (!l) {
+		priv->events = g_list_append (priv->events, g_object_ref (event));
+
+		dock_update_overlay (dock);
+	}
+}
+
+static void
+dock_remove_event (GossipDock *dock, GossipEvent *event)
+{
+        GossipDockPriv *priv;
+        GList          *l;
+
+        priv = GET_PRIV (dock);
+
+        l = g_list_find_custom (priv->events, event, gossip_event_compare);
+        if (l) {
+		priv->events = g_list_delete_link (priv->events, l);
+		g_object_unref (event);
+
+		dock_update_overlay (dock);
+	}
+}
+
+static void
+dock_event_added_cb (GossipEventManager *manager,
+                     GossipEvent        *event,
+                     GossipDock         *dock)
+{
+        dock_add_event (dock, event);
+}
+
+static void
+dock_event_removed_cb (GossipEventManager *manager,
+                       GossipEvent        *event,
+                       GossipDock         *dock)
+{
+        dock_remove_event (dock, event);
+}
+
+GossipDock *
+gossip_dock_get (void)
+{
+        static GossipDock *dock;
+
+        if (!dock) {
+                dock = g_object_new (GOSSIP_TYPE_DOCK, NULL);
+		dock_update_overlay (dock);
+        }
+
+        return dock;
+}

Added: trunk/src/gossip-mac-dock.h
==============================================================================
--- (empty file)
+++ trunk/src/gossip-mac-dock.h	Sun May 18 17:10:59 2008
@@ -0,0 +1,51 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008 Imendio AB
+ *
+ * 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 Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GOSSIP_DOCK_H__
+#define __GOSSIP_DOCK_H__
+
+#include <ige-mac-integration.h>
+
+G_BEGIN_DECLS
+
+#define GOSSIP_TYPE_DOCK         (gossip_dock_get_type ())
+#define GOSSIP_DOCK(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GOSSIP_TYPE_DOCK, GossipDock))
+#define GOSSIP_DOCK_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST ((k), GOSSIP_TYPE_DOCK, GossipDockClass))
+#define GOSSIP_IS_DOCK(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GOSSIP_TYPE_DOCK))
+#define GOSSIP_IS_DOCK_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GOSSIP_TYPE_DOCK))
+#define GOSSIP_DOCK_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GOSSIP_TYPE_DOCK, GossipDockClass))
+
+typedef struct _GossipDock      GossipDock;
+typedef struct _GossipDockClass GossipDockClass;
+
+struct _GossipDock {
+        IgeMacDock parent;
+};
+
+struct _GossipDockClass {
+        IgeMacDockClass parent_class;
+};
+
+GType       gossip_dock_get_type (void);
+GossipDock *gossip_dock_get      (void);
+
+G_END_DECLS
+
+#endif /* __GOSSIP_DOCK_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]