Re: [gpm] [Patch] Remove the icon attachment when showing the battery capacity warning



On Sat, 2009-05-16 at 16:34 +0530, Pramod Dematagoda wrote:
> On Fri, 2009-05-15 at 17:28 +0100, Richard Hughes wrote:
> > On Fri, May 15, 2009 at 4:34 PM, Pramod Dematagoda
> > <pmd lotr gandalf gmail com> wrote:
> > > But the situation is this, this notification is being shown when GNOME
> > > starts loading, and in my laptop, this is when there is nothing visible
> > > in the screen at all apart from the wallpaper, so the notification gets
> > > attached to an icon which does not seem to exist at that time, which
> > > probably explains why the notification is just seen floating instead of
> > > showing up somewhere sensible. So this problem may not necessarily be
> > > something wrong with notification-daemon but with the issue that GPM
> > > shows the notification just too quickly to be attached to a present
> > > icon. If you could suggest what would be best in this case, I'll see
> > > what I can do. :)
> > 
> > Ohh, in that case we just need to add a delay to the icon showing up.
> > There are other notifications that do this already IIRC, just search
> > for g_timeout_add.
> > 
> > Richard.
> 
> Hello Richard,
> 
> I have tried implementing what you suggested, but I am unsure as to
> where exactly I ought to stuff the g_timeout_add to, when I find one
> function to set the tray icon, I find another that seems to have some
> part in the fray, a few that I've found:-
> 
> 1) gpm_tray_icon_init - gpm-tray-icon.c : 615
> 
> 2) gpm_notify_use_status_icon - gpm-notify.c : 209
> 
> so some guidance as to what to make of this would be really helpful. :)
> 
> Thanks.
> 
> Pramod Dematagoda
> 
Please disregard my last email. I looked around a bit more this time and
I think I cracked it with this new patch which attaches the status icon
to notifications after a 10 second wait and which seems to work just as
expected on my laptop.

Pramod Dematagoda
Index: gpm-tray-icon.c
===================================================================
--- gpm-tray-icon.c	(revision 3399)
+++ gpm-tray-icon.c	(working copy)
@@ -607,6 +607,20 @@
 }
 
 /**
+ * This attaches the notification to the status icon after a 10 second wait.
+ * This is only done once during the initialisation of GPM.
+ **/
+static gboolean
+gpm_tray_status_icon_handler(gpointer temp)
+{
+	GpmTrayIcon *icon = (GpmTrayIcon *) temp;
+
+	gpm_notify_use_status_icon (icon->priv->notify, icon->priv->status_icon);
+
+	return FALSE;
+}
+
+/**
  * gpm_tray_icon_init:
  *
  * Initialise the tray object
@@ -644,8 +658,13 @@
 				 "activate",
 				 G_CALLBACK (gpm_tray_icon_activate_cb),
 				 icon, 0);
-	gpm_notify_use_status_icon (icon->priv->notify, icon->priv->status_icon);
 
+	/* Attach the status icon after a wait of 10 seconds, it allows for the GNOME session to have loaded properly
+	 * before showing any notifications and making a hash of things.
+	 */
+
+	g_timeout_add_seconds( 10, gpm_tray_status_icon_handler , icon );
+
 	/* only show the suspend and hibernate icons if we can do the action,
 	   and the policy allows the actions in the menu */
 	allowed_in_menu = gconf_client_get_bool (icon->priv->conf, GPM_CONF_UI_SHOW_ACTIONS_IN_MENU, NULL);


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