* Restore old behavior which depressed taskbar button when the button represent$
authorHong Jen Yee (PCMan) <pcman.tw@gmail.com>
Sat, 1 Aug 2009 16:48:22 +0000 (16:48 +0000)
committerHong Jen Yee (PCMan) <pcman.tw@gmail.com>
Sat, 1 Aug 2009 16:48:22 +0000 (16:48 +0000)
* Hide signal strength display in netstatus icon if it's not a wireless iface.
* Replace tab characters with spaces.

src/gtk-run.c
src/plugins/netstatus/netstatus.c
src/plugins/taskbar.c

index 0f9a1eb..8925695 100644 (file)
@@ -30,9 +30,9 @@ static GSList* app_list = NULL; /* all known apps in menu cache */
 
 typedef struct _ThreadData
 {
-       gboolean cancel; /* is the loading cancelled */
-       GSList* files; /* all executable files found */
-       GtkEntry* entry;
+    gboolean cancel; /* is the loading cancelled */
+    GSList* files; /* all executable files found */
+    GtkEntry* entry;
 }ThreadData;
 
 static ThreadData* thread_data = NULL; /* thread data used to load availble programs in PATH */
@@ -165,19 +165,19 @@ static void setup_auto_complete_with_data(ThreadData* data)
 
 void thread_data_free(ThreadData* data)
 {
-       g_slist_foreach(data->files, (GFunc)g_free, NULL);
-       g_slist_free(data->files);
-       g_slice_free(ThreadData, data);
+    g_slist_foreach(data->files, (GFunc)g_free, NULL);
+    g_slist_free(data->files);
+    g_slice_free(ThreadData, data);
 }
 
 static gboolean on_thread_finished(ThreadData* data)
 {
-       /* don't setup entry completion if the thread is already cancelled. */
-       if( !data->cancel )
-               setup_auto_complete_with_data(thread_data);
-       thread_data_free(data);
-       thread_data = NULL; /* global thread_data pointer */
-       return FALSE;
+    /* don't setup entry completion if the thread is already cancelled. */
+    if( !data->cancel )
+        setup_auto_complete_with_data(thread_data);
+    thread_data_free(data);
+    thread_data = NULL; /* global thread_data pointer */
+    return FALSE;
 }
 
 static gpointer thread_func(ThreadData* data)
@@ -197,8 +197,8 @@ static gpointer thread_func(ThreadData* data)
             char* filename = g_build_filename( *dirname, name, NULL );
             if( g_file_test( filename, G_FILE_TEST_IS_EXECUTABLE ) )
             {
-                               if(thread_data->cancel)
-                                       break;
+                if(thread_data->cancel)
+                    break;
                 if( !g_slist_find_custom( list, name, (GCompareFunc)strcmp ) )
                     list = g_slist_prepend( list, g_strdup( name ) );
             }
@@ -208,28 +208,28 @@ static gpointer thread_func(ThreadData* data)
     }
     g_strfreev( dirnames );
 
-       data->files = list;
-       /* install an idle handler to free associated data */
-       g_idle_add((GSourceFunc)on_thread_finished, data);
+    data->files = list;
+    /* install an idle handler to free associated data */
+    g_idle_add((GSourceFunc)on_thread_finished, data);
 
-       return NULL;
+    return NULL;
 }
 
 static void setup_auto_complete( GtkEntry* entry )
 {
-       gboolean cache_is_available = FALSE;
-       /* FIXME: consider saving the list of commands as on-disk cache. */
-       if( cache_is_available )
-       {
-               /* load cached program list */
-       }
-       else
-       {
-               /* load in another working thread */
-               thread_data = g_slice_new0(ThreadData); /* the data will be freed in idle handler later. */
-               thread_data->entry = entry;
-               g_thread_create((GThreadFunc)thread_func, thread_data, FALSE, NULL);
-       }
+    gboolean cache_is_available = FALSE;
+    /* FIXME: consider saving the list of commands as on-disk cache. */
+    if( cache_is_available )
+    {
+        /* load cached program list */
+    }
+    else
+    {
+        /* load in another working thread */
+        thread_data = g_slice_new0(ThreadData); /* the data will be freed in idle handler later. */
+        thread_data->entry = entry;
+        g_thread_create((GThreadFunc)thread_func, thread_data, FALSE, NULL);
+    }
 }
 
 static void on_response( GtkDialog* dlg, gint response, gpointer user_data )
@@ -247,9 +247,9 @@ static void on_response( GtkDialog* dlg, gint response, gpointer user_data )
         }
     }
 
-       /* cancel running thread if needed */
-       if( thread_data ) /* the thread is still running */
-               thread_data->cancel = TRUE; /* cancel the thread */
+    /* cancel running thread if needed */
+    if( thread_data ) /* the thread is still running */
+        thread_data->cancel = TRUE; /* cancel the thread */
 
     gtk_widget_destroy( (GtkWidget*)dlg );
     win = NULL;
@@ -299,8 +299,8 @@ void gtk_run()
                                        GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                        GTK_STOCK_OK, GTK_RESPONSE_OK,
                                        NULL );
-       gtk_dialog_set_alternative_button_order((GtkDialog*)win, 
-                                                       GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1);
+    gtk_dialog_set_alternative_button_order((GtkDialog*)win, 
+                            GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1);
     gtk_dialog_set_default_response( (GtkDialog*)win, GTK_RESPONSE_OK );
     entry = gtk_entry_new();
 
index 36af85f..41eae77 100644 (file)
@@ -149,7 +149,7 @@ netstatus_constructor(Plugin *p, char** fp)
     g_signal_connect( ns->mainw, "button-press-event",
                       G_CALLBACK(on_button_press), p );
 
-    gtk_widget_show_all(ns->mainw);
+    gtk_widget_show(ns->mainw);
 
     p->pwid = ns->mainw;
 
index 628feea..e36a2c1 100644 (file)
@@ -296,12 +296,12 @@ static void task_draw_label(Task * tk)
 {
     TaskClass * tc = tk->res_class;
     if ((tk->tb->grouped_tasks) && (tc != NULL) && (tc->visible_task == tk) && (tc->visible_count > 1))
-        {
+       {
         char * label = g_strdup_printf("(%d) %s", tc->visible_count, tc->visible_name);
         gtk_widget_set_tooltip_text(tk->button, label);
         panel_draw_label_text(tk->tb->plug->panel, tk->label, label, (tk->entered_state || tk->flash_state), tk->tb->flat_button);
         g_free(label);
-        }
+       }
     else
     {
         char * name = tk->iconified ? tk->name_iconified : tk->name;
@@ -1240,7 +1240,16 @@ static void task_update_style(Task * tk, TaskbarPlugin * tb)
     else
         gtk_widget_show(tk->label);
 
-    gtk_button_set_relief(GTK_BUTTON(tk->button), ((tb->flat_button) ? GTK_RELIEF_NONE : GTK_RELIEF_NORMAL));
+    if( tb->flat_button )
+    {
+        gtk_toggle_button_set_active((GtkToggleButton*)tk->button, FALSE);
+        gtk_button_set_relief(GTK_BUTTON(tk->button), GTK_RELIEF_NONE);
+    }
+    else
+    {
+        gtk_toggle_button_set_active((GtkToggleButton*)tk->button, tk->focused);
+        gtk_button_set_relief(GTK_BUTTON(tk->button), GTK_RELIEF_NORMAL);
+    }
 
     task_draw_label(tk);
 }
@@ -1474,12 +1483,17 @@ static void taskbar_net_active_window(GtkWidget * widget, TaskbarPlugin * tb)
     {
         ctk->focused = FALSE;
         tb->focused = NULL;
+        if(!tb->flat_button) /* relieve the button if flat buttons is not used. */
+            gtk_toggle_button_set_active((GtkToggleButton*)ctk->button, FALSE);
+
         task_button_redraw(ctk, tb);
     }
 
     /* If a task gained focus, update data structures. */
     if ((ntk != NULL) && (make_new))
     {
+        if(!tb->flat_button) /* depress the button if flat buttons is not used. */
+            gtk_toggle_button_set_active((GtkToggleButton*)ntk->button, TRUE);
         ntk->focused = TRUE;
         tb->focused = ntk;
         task_button_redraw(ntk, tb);
@@ -1906,10 +1920,10 @@ static void taskbar_destructor(Plugin * p)
     gdk_window_remove_filter(NULL, (GdkFilterFunc) taskbar_event_filter, tb);
 
     /* Remove root window signal handlers. */
-    g_signal_handlers_disconnect_by_func(G_OBJECT(fbev), taskbar_net_current_desktop, tb);
-    g_signal_handlers_disconnect_by_func(G_OBJECT(fbev), taskbar_net_active_window, tb);
-    g_signal_handlers_disconnect_by_func(G_OBJECT(fbev), taskbar_net_number_of_desktops, tb);
-    g_signal_handlers_disconnect_by_func(G_OBJECT(fbev), taskbar_net_client_list, tb);
+    g_signal_handlers_disconnect_by_func(fbev, taskbar_net_current_desktop, tb);
+    g_signal_handlers_disconnect_by_func(fbev, taskbar_net_active_window, tb);
+    g_signal_handlers_disconnect_by_func(fbev, taskbar_net_number_of_desktops, tb);
+    g_signal_handlers_disconnect_by_func(fbev, taskbar_net_client_list, tb);
 
     /* Deallocate task list. */
     while (tb->task_list != NULL)