Little fixes.
authorHong Jen Yee (PCMan) <pcman.tw@gmail.com>
Mon, 26 Jan 2009 13:39:20 +0000 (13:39 +0000)
committerHong Jen Yee (PCMan) <pcman.tw@gmail.com>
Mon, 26 Jan 2009 13:39:20 +0000 (13:39 +0000)
Support launching terminal apps in launchbar.
Bump version number to 0.3.999.

configure.ac
src/plugins/launchbar.c
src/plugins/taskbar.c

index 092f02e..bda4351 100644 (file)
@@ -1,5 +1,5 @@
 AC_PREREQ(2.53)
-AC_INIT(lxpanel, 0.3.99, http://lxde.org/)
+AC_INIT(lxpanel, 0.3.999, http://lxde.org/)
 AM_INIT_AUTOMAKE
 AC_CONFIG_SRCDIR([src/bg.c])
 AC_CONFIG_HEADER([config.h])
index 7bccb74..2b3d2ec 100644 (file)
@@ -75,6 +75,7 @@ typedef struct btn_t {
     gchar *tooltip;
 /*  NOTE: Users can override the values specified in desktop file,
           and we should process these special cases. */
+    guchar use_terminal : 1;
     guchar customize_image : 1;
     guchar customize_action : 1;
     guchar customize_tooltip : 1;
@@ -111,21 +112,23 @@ static gboolean
 on_button_event(GtkWidget *widget, GdkEventButton *event, btn_t *b )
 {
     GtkWidget *image;
-
     if( event->button == 1 )    /* left button */
     {
         image = gtk_bin_get_child(GTK_BIN(widget));
         g_assert(b != NULL);
-        if (event->type == GDK_BUTTON_RELEASE) {
+        if (event->type == GDK_BUTTON_RELEASE)
+        {
             if ((event->x >=0 && event->x < widget->allocation.width)
-                  && (event->y >=0 && event->y < widget->allocation.height)) {
-
-                g_spawn_command_line_async(b->action, NULL);
+                  && (event->y >=0 && event->y < widget->allocation.height))
+            {
+                lxpanel_launch_app(b->action, NULL, b->use_terminal);
             }
             gtk_misc_set_padding (GTK_MISC(image), 0, 0);
 
             //system(b->action);
-        } else if (event->type == GDK_BUTTON_PRESS) {
+        }
+        else if (event->type == GDK_BUTTON_PRESS)
+        {
 
             gtk_misc_set_padding (GTK_MISC(image), 0, 3);
             //ERR("here\n");
@@ -244,23 +247,28 @@ read_button(Plugin *p, char** fp)
                 ERR( "launchbar: illegal token %s\n", s.str);
                 RET(0);
             }
-            if (s.type == LINE_VAR) {
+            if (s.type == LINE_VAR)
+            {
                 if( !g_ascii_strcasecmp(s.t[0], "id") )
                     btn->desktop_id = g_strdup(s.t[1]);
-                else if (!g_ascii_strcasecmp(s.t[0], "image")) {
+                else if (!g_ascii_strcasecmp(s.t[0], "image"))
+                {
                     btn->customize_image = 1;
                     btn->image = g_strdup(s.t[1]);
                     fname = expand_tilda(s.t[1]);
                 }
-                else if (!g_ascii_strcasecmp(s.t[0], "tooltip")) {
+                else if (!g_ascii_strcasecmp(s.t[0], "tooltip"))
+                {
                     btn->customize_tooltip = 1;
                     btn->tooltip = g_strdup(s.t[1]);
                 }
-                else if (!g_ascii_strcasecmp(s.t[0], "action")) {
+                else if (!g_ascii_strcasecmp(s.t[0], "action"))
+                {
                     btn->customize_action = 1;
                     btn->action = g_strdup(s.t[1]);
                 }
-                else {
+                else
+                {
                     ERR( "launchbar: unknown var %s\n", s.t[0]);
                     goto error;
 
@@ -273,7 +281,8 @@ read_button(Plugin *p, char** fp)
         }
     }
 
-    if( btn->desktop_id ) {
+    if( btn->desktop_id )
+    {
         gchar *desktop_file = NULL;
         gchar *full_id = NULL;
         GKeyFile* desktop = g_key_file_new();
@@ -288,12 +297,16 @@ read_button(Plugin *p, char** fp)
             if( !fname && icon )
                 fname = icon;
 
-            if( ! btn->customize_action ) {
+            if( ! btn->customize_action )
+            {
                 gchar* exec;
                 exec = g_key_file_get_string( desktop, desktop_ent, "Exec", NULL);
                 btn->action = translate_exec_to_cmd( exec, icon, title, desktop_file );
                 g_free( exec );
             }
+
+            btn->use_terminal = g_key_file_get_boolean(desktop, desktop_ent, "Terminal", NULL);
+
             if( ! btn->customize_tooltip )
                 btn->tooltip = title;
             if( fname != icon )
index e8d6a2f..eeda084 100644 (file)
@@ -583,8 +583,7 @@ get_wm_icon(Window tkwin, int iw, int ih)
         LOG(LOG_WARN, "lxpanel : Can't read _NET_WM_ICON, try to read pixmap icon\n");
 
         hints = XGetWMHints(GDK_DISPLAY(), tkwin);
-        
-        result = (hints != NULL)?Success:0;
+        result = (hints != NULL) ? Success : 0;
 
         if(result == Success)
         {
@@ -592,35 +591,33 @@ get_wm_icon(Window tkwin, int iw, int ih)
                 xpixmap = hints->icon_pixmap;
             if ((hints->flags & IconMaskHint))
                 xmask = hints->icon_mask;
-
             XFree(hints);
-            
             result = (xpixmap != None)?Success:0;
         }
 
         if(result != Success)
         {
-            Pixmap *icons;
+            Pixmap *icons = NULL;
             LOG(LOG_WARN, "lxpanel : can't get icon using HINTS try to use KWM_WIN_ICON\n");
-        
+            Atom kwin_win_icon_atom = gdk_x11_get_xatom_by_name("KWM_WIN_ICON");
             result = XGetWindowProperty(GDK_DISPLAY(), tkwin,
-                                        gdk_x11_get_xatom_by_name("KWM_WIN_ICON"),
+                                        kwin_win_icon_atom,
                                         0, G_MAXLONG,
                                         False,
-                                        gdk_x11_get_xatom_by_name("KWM_WIN_ICON"),
+                                        kwin_win_icon_atom,
                                         &type, &format, &nitems,
                                         &bytes_after, (void*)&icons);
-            if(type != gdk_x11_get_xatom_by_name("KWM_WIN_ICON"))
+            if(type != kwin_win_icon_atom)
             {
+                if( icons )
+                    XFree(icons);
                 result = 0;
             }
-        
             if(result == Success)
             {
                 xpixmap = icons[0];
                 xmask   = icons[1];
-            
-                result = (xpixmap != None)?Success:0;
+                result = (xpixmap != None) ? Success : 0;
             }
         }
 
@@ -640,7 +637,6 @@ get_wm_icon(Window tkwin, int iw, int ih)
         {
             DBG("tkwin=%x icon pixmap w=%d h=%d\n", tkwin, w, h);
             pixmap = _wnck_gdk_pixbuf_get_from_pixmap (NULL, xpixmap, 0, 0, 0, 0, w, h);
-            
             result = pixmap?Success:0;
         }
 
@@ -661,7 +657,7 @@ get_wm_icon(Window tkwin, int iw, int ih)
             }
         }
     }
-    
+
     if (!pixmap)
         RET(NULL);