Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=fun.git;a=commitdiff;h=607f722896a25daa7d2a0bb9f36fdb58411e7ac4

commit 607f722896a25daa7d2a0bb9f36fdb58411e7ac4
Author: Priyank <[EMAIL PROTECTED]>
Date:   Thu Dec 20 01:19:53 2007 +0530

fun-tooltip: made notification stuff private (can be accessed only using 
fun_tooltip_* functions)
* Added new function to update the notification timeout 
fun_tooltip_set_timeout()

diff --git a/src/fun-tooltip.c b/src/fun-tooltip.c
index cc17dc7..5de3885 100644
--- a/src/fun-tooltip.c
+++ b/src/fun-tooltip.c
@@ -21,13 +21,15 @@
*/

#include <gtk/gtk.h>
+#include <libnotify/notification.h>
+#include <libnotify/notify.h>
#include "fun-config.h"
#include "fun-tooltip.h"

-NotifyNotification *fun_tooltip_new (GtkStatusIcon *icon)
+static NotifyNotification *tooltip = NULL;
+
+void fun_tooltip_new (GtkStatusIcon *icon)
{
-       NotifyNotification      *tooltip = NULL;
-
tooltip = notify_notification_new ("Frugalware Update Notifier",
NULL,
"fun",
@@ -36,11 +38,11 @@ NotifyNotification *fun_tooltip_new (GtkStatusIcon *icon)
notify_notification_set_timeout (tooltip, 
(fun_config_get_value_int("notification_timeout")*1000));
notify_notification_set_urgency (tooltip, NOTIFY_URGENCY_NORMAL);
notify_notification_attach_to_status_icon (tooltip, icon);
-
-       return tooltip;
+
+       return;
}

-void fun_tooltip_set_text (NotifyNotification *tooltip, const gchar *summary, 
const gchar *body)
+void fun_tooltip_set_text (const gchar *summary, const gchar *body)
{
if (tooltip)
notify_notification_update (tooltip, summary, body, "fun");
@@ -48,7 +50,14 @@ void fun_tooltip_set_text (NotifyNotification *tooltip, 
const gchar *summary, co
return;
}

-void fun_tooltip_show (GtkStatusIcon *icon, NotifyNotification *tooltip)
+void fun_tooltip_set_notification_timeout (guint timeout)
+{
+       notify_notification_set_timeout (tooltip, timeout*1000);
+
+       return;
+}
+
+void fun_tooltip_show (GtkStatusIcon *icon)
{
if (tooltip)
{
@@ -63,7 +72,7 @@ void fun_tooltip_show (GtkStatusIcon *icon, 
NotifyNotification *tooltip)
return;
}

-void fun_tooltip_destroy (NotifyNotification *tooltip)
+void fun_tooltip_destroy (void)
{
g_object_unref (tooltip);
notify_uninit ();
@@ -71,4 +80,3 @@ void fun_tooltip_destroy (NotifyNotification *tooltip)

return;
}
-
diff --git a/src/fun-tooltip.h b/src/fun-tooltip.h
index 429cb6c..7c395e1 100644
--- a/src/fun-tooltip.h
+++ b/src/fun-tooltip.h
@@ -2,22 +2,23 @@
#define _FUN_TOOLTIP_H

#include <gtk/gtk.h>
-#include <libnotify/notification.h>
-#include <libnotify/notify.h>

/* Fun Tooltip Functions */

/* Create a new tooltip */
-NotifyNotification *fun_tooltip_new (GtkStatusIcon *icon);
+void fun_tooltip_new (GtkStatusIcon *icon);

-/* Sets the tooltip text (label1) */
-void fun_tooltip_set_text (NotifyNotification *tooltip, const gchar *summary, 
const gchar *body);
+/* Sets the tooltip text */
+void fun_tooltip_set_text (const gchar *summary, const gchar *body);

-/* Show the tooltip */
-void fun_tooltip_show (GtkStatusIcon *icon, NotifyNotification *tooltip);
+/* Sets the tooltip timeout (seconds) */
+void fun_tooltip_set_timeout (guint timeout);
+
+/* Show the    tooltip */
+void fun_tooltip_show (GtkStatusIcon *icon);

/* Destroy the tooltip object and free the memory */
-void fun_tooltip_destroy (NotifyNotification *tooltip);
+void fun_tooltip_destroy (void);

#endif

diff --git a/src/fun-ui.c b/src/fun-ui.c
index 9b1c5c2..ad5fbf0 100644
--- a/src/fun-ui.c
+++ b/src/fun-ui.c
@@ -38,13 +38,9 @@ static void fun_main_window_hide (void);
static void fun_launch_gfpm (void);
static void fun_populate_updates_tvw (gchar *plist);

-#define FUN_ICON                       "fun.png"
-#define FUN_TOOLTIP_ICON       "fun.png"
-
extern GladeXML *xml;

-static GtkStatusIcon           *icon = NULL;
-static NotifyNotification      *tooltip = NULL;
+static GtkStatusIcon   *icon = NULL;

static GtkWidget                *fun_about_dlg = NULL;
static GtkWidget                *fun_main_window = NULL;
@@ -110,8 +106,8 @@ fun_systray_create (void)
icon = gtk_status_icon_new_from_icon_name ("fun");

/* set the default tooltip */
-       tooltip = fun_tooltip_new (icon);
-       fun_tooltip_set_text (tooltip, "Frugalware Update Notifier", NULL);
+       fun_tooltip_new (icon);
+       fun_tooltip_set_text ("Frugalware Update Notifier", NULL);

g_signal_connect (icon, "activate", G_CALLBACK (fun_main_window_show), NULL);
g_signal_connect (icon, "popup-menu", G_CALLBACK (cb_fun_systray_icon_clicked), 
NULL);
@@ -231,9 +227,8 @@ fun_ui_cleanup (void)
g_object_unref (icon);
gtk_widget_destroy (GTK_WIDGET(fun_config_dlg));
gtk_widget_destroy (GTK_WIDGET(fun_main_window));
-       fun_tooltip_destroy (tooltip);
+       fun_tooltip_destroy ();
icon = NULL;
-       tooltip = NULL;

return;
}
@@ -468,9 +463,9 @@ fun_timeout_func (void)
if (fun_dbus_perform_service (PERFORM_UPDATE, NULL, &plist, NULL)==TRUE)
{
//g_print ("\nlist is\n %s", plist);
-               fun_tooltip_set_text (tooltip, _("Updates are available"), 
_("Yeah updates are available"));
+               fun_tooltip_set_text (_("Updates are available"), _("Yeah 
updates are available"));
//fun_tooltip_set_text2 (tooltip, _("Click here to know more.."), TRUE);
-               fun_tooltip_show (icon, tooltip);
+               fun_tooltip_show (icon);
/* display the notification popup for notification_timeout seconds */
/* we do this by registering a timeout for x seconds which will simply hide the
* tooltip when fired and destroy itself */
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to