Aurélien Gâteau has proposed merging lp:~agateau/notify-osd/take2 into
lp:notify-osd.
Requested reviews:
Notify OSD Developers (notify-osd-developers)
- Make fallback dialog independent of Bubble class.
- Also contains a few GError fixes.
--
https://code.launchpad.net/~agateau/notify-osd/take2/+merge/6416
Your team Notify OSD Developers is subscribed to branch lp:notify-osd.
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2009-04-16 14:02:12 +0000
+++ src/Makefile.am 2009-05-07 16:25:47 +0000
@@ -16,6 +16,7 @@
notify_osd_sources = \
bubble.c \
defaults.c \
+ dialog.c \
main.c \
observer.c \
stack.c \
@@ -38,6 +39,7 @@
notify_osd_headers = \
bubble.h \
defaults.h \
+ dialog.h \
observer.h \
stack.h \
stack-glue.h \
=== modified file 'src/bubble.c'
--- src/bubble.c 2009-04-28 15:17:10 +0000
+++ src/bubble.c 2009-05-07 16:25:47 +0000
@@ -3393,6 +3393,3 @@
bubble_start_timer (self);
bubble_start_timer (other);
}
-
-#include "dialog.c"
-
=== modified file 'src/dialog.c'
--- src/dialog.c 2009-04-08 15:07:36 +0000
+++ src/dialog.c 2009-05-07 16:25:47 +0000
@@ -26,24 +26,41 @@
**
*******************************************************************************/
-/* Note: this file is actually #include'd as a part of bubble.c
- but kept separate because this is not really a true "bubble".
- */
+#include "dialog.h"
+
+#include <gtk/gtk.h>
+
+#include "dbus.h"
+#include "util.h"
+
+typedef struct _DialogInfo DialogInfo;
+
+struct _DialogInfo
+{
+ int id;
+ gchar* sender;
+};
+
+static void
+dialog_info_destroy (DialogInfo *dialog_info)
+{
+ g_free(dialog_info->sender);
+ g_free(dialog_info);
+}
static void
handle_close (GtkWidget *dialog,
guint response_id,
gpointer user_data)
{
- Bubble *bubble = g_object_get_data (G_OBJECT (dialog),
- "_bubble");
-
- GET_PRIVATE (bubble)->visible = FALSE;
-
- dbus_send_close_signal (bubble_get_sender (bubble),
- bubble_get_id (bubble),
+ DialogInfo *dialog_info = g_object_get_data (G_OBJECT (dialog),
+ "_dialog_info");
+
+ dbus_send_close_signal (dialog_info->sender,
+ dialog_info->id,
2);
+ dialog_info_destroy (dialog_info);
gtk_widget_destroy (GTK_WIDGET(dialog));
}
@@ -54,18 +71,16 @@
{
gchar *action = g_object_get_data (G_OBJECT (button),
"_libnotify_action");
- Bubble *bubble = g_object_get_data (G_OBJECT (dialog),
- "_bubble");
-
- GET_PRIVATE (bubble)->visible = FALSE;
+ DialogInfo *dialog_info = g_object_get_data (G_OBJECT (dialog),
+ "_dialog_info");
/* send a "click" signal... <sigh> */
- dbus_send_action_signal (bubble_get_sender (bubble),
- bubble_get_id (bubble),
+ dbus_send_action_signal (dialog_info->sender,
+ dialog_info->id,
action);
- dbus_send_close_signal (bubble_get_sender (bubble),
- bubble_get_id (bubble),
+ dbus_send_close_signal (dialog_info->sender,
+ dialog_info->id,
3);
gtk_widget_destroy (GTK_WIDGET(dialog));
@@ -109,51 +124,15 @@
}
}
-/* control if there are non-default actions requested with this
- notification
-*/
-gboolean
-dialog_check_actions_and_timeout (gchar **actions, gint timeout)
-{
- int i = 0;
- gboolean turn_into_dialog = FALSE;
-
- if (actions != NULL)
- {
- for (i = 0; actions[i] != NULL; i += 2)
- {
- if (actions[i+1] == NULL)
- {
- g_debug ("incorrect action callback with no label");
- break;
- }
-
-/* if (! g_strcmp0 (actions[i], "default"))
- break;
-*/
- turn_into_dialog = TRUE;
- g_debug ("notification request turned into a dialog "
- "box, because it contains at least one action "
- "callback (%s: \"%s\")",
- actions[i], actions[i+1]);
- }
-
- if (timeout == 0)
- {
- turn_into_dialog = TRUE;
- g_debug ("notification request turned into a dialog "
- "box, because of its infinite timeout");
- }
- }
-
- return turn_into_dialog;
-}
-
-
-GObject*
-bubble_show_dialog (Bubble *bubble,
- const char *app_name,
- gchar **actions)
+void
+fallback_dialog_show (
+ Defaults* d,
+ const gchar* sender,
+ const gchar* app_name,
+ int id,
+ const gchar* title_text,
+ const gchar* _body_message,
+ gchar** actions)
{
GtkWidget* dialog;
GtkWidget* hbox;
@@ -161,14 +140,16 @@
GtkWidget* title;
GtkWidget* body;
GtkWidget* image;
- Defaults* d = bubble->defaults;
gchar* body_message;
gchar* new_body_message;
guint gap = EM2PIXELS (defaults_get_margin_size (d), d);
- BubblePrivate* priv;
gboolean success;
GError* error = NULL;
+ DialogInfo* dialog_info = g_malloc(sizeof(DialogInfo));
+ dialog_info->id = id;
+ dialog_info->sender = g_strdup(sender);
+
dialog = gtk_dialog_new ();
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
@@ -177,8 +158,6 @@
"border-width", 12,
NULL);
- priv = GET_PRIVATE (bubble);
-
/* We deliberately use the gtk-dialog-warning icon rather than
* the specified one to discourage people from trying to use
* the notification system as a way of showing custom alert
@@ -193,12 +172,12 @@
NULL);
title = gtk_label_new (NULL);
- gtk_label_set_text (GTK_LABEL (title), priv->title->str);
+ gtk_label_set_text (GTK_LABEL (title), title_text);
gtk_label_set_line_wrap (GTK_LABEL (title), TRUE);
body = gtk_label_new (NULL);
- body_message = filter_text (priv->message_body->str);
+ body_message = filter_text (_body_message);
success = pango_parse_markup (body_message,
-1,
0,
@@ -270,8 +249,8 @@
dialog);
g_object_set_data (G_OBJECT (dialog),
- "_bubble",
- bubble);
+ "_dialog_info",
+ dialog_info);
g_signal_connect (G_OBJECT (dialog),
"button-release-event",
@@ -284,10 +263,4 @@
NULL);
gtk_widget_show_all (dialog);
-
- /* pretend its visible, so that the purge algorithm
- does not try to unreference the bubble */
- priv->visible = TRUE;
-
- return G_OBJECT (dialog);
}
=== added file 'src/dialog.h'
--- src/dialog.h 1970-01-01 00:00:00 +0000
+++ src/dialog.h 2009-05-07 16:25:47 +0000
@@ -0,0 +1,48 @@
+/*******************************************************************************
+**3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
+** 10 20 30 40 50 60 70 80
+**
+** notify-osd
+**
+** stack.c - manages the stack/queue of incoming notifications
+**
+** Copyright 2009 Canonical Ltd.
+**
+** Authors:
+** Mirco "MacSlow" Mueller <[email protected]>
+** David Barth <[email protected]>
+**
+** Contributor(s):
+** Abhishek Mukherjee <[email protected]> (append fixes, rev. 280)
+**
+** This program is free software: you can redistribute it and/or modify it
+** under the terms of the GNU General Public License version 3, as published
+** by the Free Software Foundation.
+**
+** This program is distributed in the hope that it will be useful, but
+** WITHOUT ANY WARRANTY; without even the implied warranties of
+** MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
+**
+*******************************************************************************/
+#ifndef DIALOG_H
+#define DIALOG_H
+
+#include <glib.h>
+
+#include "defaults.h"
+
+void
+fallback_dialog_show(
+ Defaults* defaults,
+ const gchar* sender,
+ const gchar* app_name,
+ int id,
+ const gchar* summary,
+ const gchar* body,
+ gchar** actions);
+
+#endif /* DIALOG_H */
=== modified file 'src/dnd.c'
--- src/dnd.c 2009-03-19 11:06:18 +0000
+++ src/dnd.c 2009-05-07 16:55:11 +0000
@@ -111,7 +111,7 @@
gboolean
dnd_is_screensaver_inhibited ()
{
- GError *error;
+ GError *error = NULL;
gboolean inhibited = FALSE;
char **list;
@@ -139,7 +139,7 @@
gboolean
dnd_is_screensaver_active ()
{
- GError *error;
+ GError *error = NULL;
gboolean active = FALSE;;
if (! get_screensaver_proxy ())
=== modified file 'src/stack.c'
--- src/stack.c 2009-04-09 10:44:07 +0000
+++ src/stack.c 2009-05-07 16:25:47 +0000
@@ -36,11 +36,15 @@
#include "stack.h"
#include "bubble.h"
#include "apport.h"
+#include "dialog.h"
#include "dnd.h"
#include "log.h"
G_DEFINE_TYPE (Stack, stack, G_TYPE_OBJECT);
+/* fwd declaration */
+void close_handler (GObject* n, Stack* stack);
+
/*-- internal API ------------------------------------------------------------*/
static void
@@ -52,9 +56,12 @@
static
void
-delete_entry (gpointer data,
+disconnect_bubble (gpointer data,
gpointer user_data)
{
+ Bubble* bubble = BUBBLE(data);
+ Stack* stack = STACK(user_data);
+ g_signal_handlers_disconnect_by_func (G_OBJECT(bubble), G_CALLBACK (close_handler), stack);
}
@@ -62,7 +69,7 @@
stack_finalize (GObject* gobject)
{
if (STACK(gobject)->list != NULL)
- g_list_foreach (STACK(gobject)->list, delete_entry, NULL);
+ g_list_foreach (STACK(gobject)->list, disconnect_bubble, gobject);
if (STACK(gobject)->defaults != NULL)
g_object_unref (STACK(gobject)->defaults);
if (STACK(gobject)->observer != NULL)
@@ -292,12 +299,6 @@
g_list_foreach (stack->list, _trigger_bubble_redraw, NULL);
}
-/* fwd declaration */
-void close_handler (GObject* n, Stack* stack);
-
-/* this is in dialog.c */
-gboolean dialog_check_actions_and_timeout (gchar **actions, gint timeout);
-
static Bubble *sync_bubble = NULL;
#include "display.c"
@@ -493,6 +494,46 @@
return pixbuf;
}
+/* control if there are non-default actions requested with this
+ notification
+*/
+static gboolean
+dialog_check_actions_and_timeout (gchar **actions, gint timeout)
+{
+ int i = 0;
+ gboolean turn_into_dialog = FALSE;
+
+ if (actions != NULL)
+ {
+ for (i = 0; actions[i] != NULL; i += 2)
+ {
+ if (actions[i+1] == NULL)
+ {
+ g_debug ("incorrect action callback with no label");
+ break;
+ }
+
+/* if (! g_strcmp0 (actions[i], "default"))
+ break;
+*/
+ turn_into_dialog = TRUE;
+ g_debug ("notification request turned into a dialog "
+ "box, because it contains at least one action "
+ "callback (%s: \"%s\")",
+ actions[i], actions[i+1]);
+ }
+
+ if (timeout == 0)
+ {
+ turn_into_dialog = TRUE;
+ g_debug ("notification request turned into a dialog "
+ "box, because of its infinite timeout");
+ }
+ }
+
+ return turn_into_dialog;
+}
+
gboolean
stack_notify_handler (Stack* self,
const gchar* app_name,
@@ -512,6 +553,30 @@
GdkPixbuf* pixbuf = NULL;
gboolean new_bubble = FALSE;
+ gboolean turn_into_dialog = dialog_check_actions_and_timeout (actions, timeout);
+
+ if (turn_into_dialog)
+ /* || bubble_is_urgent (bubble)) */
+ {
+ /* TODO: apport_report (app_name, summary, actions, timeout); */
+ gchar* sender = dbus_g_method_get_sender (context);
+
+ fallback_dialog_show (
+ self->defaults,
+ sender,
+ app_name,
+ id,
+ summary,
+ body,
+ actions);
+
+ g_free(sender);
+
+ dbus_g_method_return (context, id);
+
+ return TRUE;
+ }
+
/* check if a bubble exists with same id */
bubble = find_bubble_by_id (self, id);
if (bubble == NULL)
@@ -618,25 +683,6 @@
(*icon == '\0' && data != NULL) ?
"..." : icon);
- gboolean turn_into_dialog = dialog_check_actions_and_timeout (actions, timeout);
-
- if (turn_into_dialog)
- /* || bubble_is_urgent (bubble)) */
- {
- /* TODO: apport_report (app_name, summary, actions, timeout); */
-
- GObject *dialog = G_OBJECT (
- bubble_show_dialog (bubble, app_name, actions));
- g_signal_connect (dialog,
- "destroy-event",
- G_CALLBACK (close_handler),
- self);
-
- dbus_g_method_return (context, bubble_get_id (bubble));
-
- return TRUE;
- }
-
bubble_determine_layout (bubble);
bubble_recalc_size (bubble);
=== modified file 'tests/Makefile.am'
--- tests/Makefile.am 2009-04-03 13:19:09 +0000
+++ tests/Makefile.am 2009-05-07 16:25:47 +0000
@@ -12,6 +12,7 @@
test_modules_SOURCES = \
../src/bubble.c \
../src/defaults.c \
+ ../src/dialog.c \
../src/observer.c \
../src/stack.c \
../src/dbus.c \
_______________________________________________
Mailing list: https://launchpad.net/~dx-team
Post to : [email protected]
Unsubscribe : https://launchpad.net/~dx-team
More help : https://help.launchpad.net/ListHelp