gossip r2814 - in trunk: . src
- From: rhult svn gnome org
- To: svn-commits-list gnome org
- Subject: gossip r2814 - in trunk: . src
- Date: Mon, 19 May 2008 20:42:45 +0000 (UTC)
Author: rhult
Date: Mon May 19 20:42:45 2008
New Revision: 2814
URL: http://svn.gnome.org/viewvc/gossip?rev=2814&view=rev
Log:
2008-05-19 Richard Hult <richard imendio com>
* src/gossip-chat-manager.c: (gossip_chat_manager_show_chat): Add
missing space.
* src/gossip-chat-window.c: Refactor the title/status updating a
bit in an attempt to make it more clear. Not sure if that
succeeded ;)
- Also add support for the mac dock.
* src/gossip-mac-dock.c: Handle unread chat messages from chat
windows in addition to the event manager events.
Modified:
trunk/ChangeLog
trunk/src/gossip-chat-manager.c
trunk/src/gossip-chat-window.c
trunk/src/gossip-mac-dock.c
trunk/src/gossip-mac-dock.h
Modified: trunk/src/gossip-chat-manager.c
==============================================================================
--- trunk/src/gossip-chat-manager.c (original)
+++ trunk/src/gossip-chat-manager.c Mon May 19 20:42:45 2008
@@ -323,5 +323,5 @@
gossip_chat_present (GOSSIP_CHAT (chat));
- gossip_chat_manager_remove_events(manager, contact);
+ gossip_chat_manager_remove_events (manager, contact);
}
Modified: trunk/src/gossip-chat-window.c
==============================================================================
--- trunk/src/gossip-chat-window.c (original)
+++ trunk/src/gossip-chat-window.c Mon May 19 20:42:45 2008
@@ -29,6 +29,7 @@
#ifdef GDK_WINDOWING_QUARTZ
#include <ige-mac-menu.h>
+#import <AppKit/AppKit.h>
#endif
#include <libgossip/gossip-contact.h>
@@ -54,6 +55,10 @@
#include "gossip-sound.h"
#include "gossip-ui-utils.h"
+#ifdef GDK_WINDOWING_QUARTZ
+#include "gossip-mac-dock.h"
+#endif
+
#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GOSSIP_TYPE_CHAT_WINDOW, GossipChatWindowPriv))
#define DEBUG_DOMAIN "ChatWindow"
@@ -129,10 +134,9 @@
GossipChat *chat);
static GtkWidget * chat_window_create_label (GossipChatWindow *window,
GossipChat *chat);
-static void chat_window_update_status (GossipChatWindow *window,
- GossipChat *chat);
-static void chat_window_update_title (GossipChatWindow *window,
+static void chat_window_update_chat_status (GossipChatWindow *window,
GossipChat *chat);
+static void chat_window_update_title (GossipChatWindow *window);
static void chat_window_update_menu (GossipChatWindow *window);
static gboolean chat_window_save_geometry_timeout_cb (GossipChatWindow *window);
static gboolean chat_window_configure_event_cb (GtkWidget *widget,
@@ -706,8 +710,8 @@
}
static void
-chat_window_update_status (GossipChatWindow *window,
- GossipChat *chat)
+chat_window_update_chat_status (GossipChatWindow *window,
+ GossipChat *chat)
{
GtkImage *image;
GdkPixbuf *pixbuf;
@@ -718,13 +722,11 @@
g_object_unref (pixbuf);
- chat_window_update_title (window, chat);
chat_window_update_tooltip (window, chat);
}
static void
-chat_window_update_title (GossipChatWindow *window,
- GossipChat *chat)
+chat_window_update_title (GossipChatWindow *window)
{
GossipChatWindowPriv *priv;
GdkPixbuf *pixbuf = NULL;
@@ -1349,7 +1351,8 @@
index - 1);
chat_window_update_menu (window);
- chat_window_update_status (window, chat);
+ chat_window_update_title (window);
+ chat_window_update_chat_status (window, chat);
}
static void
@@ -1370,7 +1373,8 @@
index + 1);
chat_window_update_menu (window);
- chat_window_update_status (window, chat);
+ chat_window_update_title (window);
+ chat_window_update_chat_status (window, chat);
}
static void
@@ -1421,7 +1425,7 @@
GossipChatWindow *window)
{
chat_window_update_menu (window);
- chat_window_update_status (window, chat);
+ chat_window_update_chat_status (window, chat);
}
static void
@@ -1454,6 +1458,56 @@
}
static void
+chat_window_chat_mark_as_unread (GossipChatWindow *window,
+ GossipChat *chat)
+{
+ GossipChatWindowPriv *priv;
+
+ priv = GET_PRIV (window);
+
+ if (g_list_find (priv->chats_new_msg, chat)) {
+ return;
+ }
+
+ priv->chats_new_msg = g_list_prepend (priv->chats_new_msg, chat);
+
+ chat_window_update_chat_status (window, chat);
+
+#ifdef GDK_WINDOWING_QUARTZ
+ /* We make the window focused if the app is not the active one to
+ * avoid changing the focus between the previously focused one and
+ * the new one when the dock is clicked...
+ */
+ if (![NSApp isActive]) {
+ gdk_window_focus (priv->dialog->window, 0);
+ }
+
+ gossip_dock_mark_as_unread (gossip_dock_get (), chat);
+#endif
+}
+
+static void
+chat_window_chat_mark_as_read (GossipChatWindow *window,
+ GossipChat *chat)
+{
+ GossipChatWindowPriv *priv;
+
+ priv = GET_PRIV (window);
+
+ if (!g_list_find (priv->chats_new_msg, chat)) {
+ return;
+ }
+
+ priv->chats_new_msg = g_list_remove (priv->chats_new_msg, chat);
+
+ chat_window_update_chat_status (window, chat);
+
+#ifdef GDK_WINDOWING_QUARTZ
+ gossip_dock_mark_as_read (gossip_dock_get (), chat);
+#endif
+}
+
+static void
chat_window_name_changed_cb (GossipChat *chat,
const gchar *name,
GossipChatWindow *window)
@@ -1480,7 +1534,7 @@
priv->chats_composing = g_list_remove (priv->chats_composing, chat);
}
- chat_window_update_status (window, chat);
+ chat_window_update_chat_status (window, chat);
}
static void
@@ -1523,10 +1577,8 @@
gossip_request_user_attention ();
}
- if (!is_backlog &&
- !g_list_find (priv->chats_new_msg, chat)) {
- priv->chats_new_msg = g_list_prepend (priv->chats_new_msg, chat);
- chat_window_update_status (window, chat);
+ if (!is_backlog) {
+ chat_window_chat_mark_as_unread (window, chat);
}
}
@@ -1583,10 +1635,10 @@
}
priv->current_chat = chat;
- priv->chats_new_msg = g_list_remove (priv->chats_new_msg, chat);
+ chat_window_chat_mark_as_read (window, chat);
+ chat_window_update_title (window);
chat_window_update_menu (window);
- chat_window_update_status (window, chat);
}
static void
@@ -1660,6 +1712,8 @@
/* Get list of chats up to date */
priv->chats = g_list_append (priv->chats, chat);
+
+ chat_window_update_chat_status (window, chat);
}
static void
@@ -1719,11 +1773,13 @@
priv->chats_new_msg = g_list_remove (priv->chats_new_msg, chat);
priv->chats_composing = g_list_remove (priv->chats_composing, chat);
+ chat_window_chat_mark_as_read (window, chat);
+
if (priv->chats == NULL) {
g_object_unref (window);
} else {
chat_window_update_menu (window);
- chat_window_update_title (window, NULL);
+ chat_window_update_title (window);
}
}
@@ -1738,13 +1794,10 @@
priv = GET_PRIV (window);
- priv->chats_new_msg = g_list_remove (priv->chats_new_msg, priv->current_chat);
+ chat_window_chat_mark_as_read (window, priv->current_chat);
chat_window_set_urgency_hint (window, FALSE);
- /* Update the title, since we now mark all unread messages as read. */
- chat_window_update_status (window, priv->current_chat);
-
#ifdef GDK_WINDOWING_QUARTZ
ige_mac_menu_set_menu_bar (GTK_MENU_SHELL (priv->menu_bar));
gtk_widget_hide (priv->menu_bar);
Modified: trunk/src/gossip-mac-dock.c
==============================================================================
--- trunk/src/gossip-mac-dock.c (original)
+++ trunk/src/gossip-mac-dock.c Mon May 19 20:42:45 2008
@@ -59,9 +59,6 @@
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);
@@ -90,10 +87,13 @@
dock_event_removed_cb,
object);
+ g_list_foreach (priv->events, (GFunc) g_free, NULL);
+ g_list_free (priv->events);
+
G_OBJECT_CLASS (gossip_dock_parent_class)->finalize (object);
}
-static GossipEvent *
+static GObject *
dock_get_next_event (GossipDock *dock)
{
GossipDockPriv *priv;
@@ -111,88 +111,98 @@
dock_clicked_cb (IgeMacDock *dock)
{
GossipDockPriv *priv;
+ GObject *event;
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)));
+ event = dock_get_next_event (GOSSIP_DOCK (dock));
+
+ if (!event) {
+ if (!gossip_app_is_window_visible ()) {
+ gossip_app_set_visibility (TRUE);
+ }
}
+ else if (GOSSIP_IS_EVENT (event)) {
+ gossip_event_manager_activate (gossip_app_get_event_manager (),
+ GOSSIP_EVENT (event));
+ }
+ else if (GOSSIP_IS_CHAT (event)) {
+ gossip_chat_present (GOSSIP_CHAT (event));
+ } else {
+ g_warning ("Got unhandled event type.");
+ }
}
-static GdkPixbuf *
-dock_get_event_pixbuf (GossipDock *dock)
+static void
+dock_update_overlay (GossipDock *dock)
{
GossipDockPriv *priv;
- GossipEvent *event;
+ GObject *event;
gchar *path;
GdkPixbuf *pixbuf;
priv = GET_PRIV (dock);
event = dock_get_next_event (dock);
- if (!event) {
- return NULL;
+ if (event) {
+ path = gossip_paths_get_image_path ("gossip-mac-overlay-new-message.png");
+ } else {
+ path = gossip_paths_get_image_path ("gossip-logo.png");
}
- 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) {
+ if (event) {
ige_mac_dock_set_overlay_from_pixbuf (IGE_MAC_DOCK (dock), pixbuf);
- g_object_unref (pixbuf);
} else {
- gchar *path;
- GdkPixbuf *pixbuf;
+ ige_mac_dock_set_icon_from_pixbuf (IGE_MAC_DOCK (dock), pixbuf);
+ }
- path = gossip_paths_get_image_path ("gossip-logo.png");
- pixbuf = gdk_pixbuf_new_from_file (path, NULL);
- g_free (path);
+ g_object_unref (pixbuf);
+}
- if (pixbuf) {
- ige_mac_dock_set_icon_from_pixbuf (IGE_MAC_DOCK (dock), pixbuf);
- g_object_unref (pixbuf);
- }
+static gint
+event_compare (gconstpointer a,
+ gconstpointer b)
+{
+ if (GOSSIP_IS_EVENT (a) && GOSSIP_IS_EVENT (b)) {
+ return gossip_event_compare (a, b);
+ }
+
+ if (a == b) {
+ return 0;
}
+
+ return 1;
}
static void
-dock_add_event (GossipDock *dock, GossipEvent *event)
+dock_add_event (GossipDock *dock,
+ GObject *event)
{
GossipDockPriv *priv;
GList *l;
priv = GET_PRIV (dock);
- l = g_list_find_custom (priv->events, event, gossip_event_compare);
+ l = g_list_find_custom (priv->events, event, 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)
+dock_remove_event (GossipDock *dock,
+ GObject *event)
{
GossipDockPriv *priv;
GList *l;
priv = GET_PRIV (dock);
- l = g_list_find_custom (priv->events, event, gossip_event_compare);
+ l = g_list_find_custom (priv->events, event, event_compare);
if (l) {
priv->events = g_list_delete_link (priv->events, l);
g_object_unref (event);
@@ -206,7 +216,7 @@
GossipEvent *event,
GossipDock *dock)
{
- dock_add_event (dock, event);
+ dock_add_event (dock, G_OBJECT (event));
}
static void
@@ -214,7 +224,7 @@
GossipEvent *event,
GossipDock *dock)
{
- dock_remove_event (dock, event);
+ dock_remove_event (dock, G_OBJECT (event));
}
GossipDock *
@@ -229,3 +239,25 @@
return dock;
}
+
+void
+gossip_dock_mark_as_unread (GossipDock *dock,
+ gpointer data)
+{
+ GossipDockPriv *priv;
+
+ priv = GET_PRIV (dock);
+
+ dock_add_event (dock, data);
+}
+
+void
+gossip_dock_mark_as_read (GossipDock *dock,
+ gpointer data)
+{
+ GossipDockPriv *priv;
+
+ priv = GET_PRIV (dock);
+
+ dock_remove_event (dock, data);
+}
Modified: trunk/src/gossip-mac-dock.h
==============================================================================
--- trunk/src/gossip-mac-dock.h (original)
+++ trunk/src/gossip-mac-dock.h Mon May 19 20:42:45 2008
@@ -43,8 +43,12 @@
IgeMacDockClass parent_class;
};
-GType gossip_dock_get_type (void);
-GossipDock *gossip_dock_get (void);
+GType gossip_dock_get_type (void);
+GossipDock *gossip_dock_get (void);
+void gossip_dock_mark_as_unread (GossipDock *dock,
+ gpointer data);
+void gossip_dock_mark_as_read (GossipDock *dock,
+ gpointer data);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]