Little fix for the config of dclock plugin.
authorHong Jen Yee (PCMan) <pcman.tw@gmail.com>
Sun, 29 Oct 2006 10:27:43 +0000 (10:27 +0000)
committerHong Jen Yee (PCMan) <pcman.tw@gmail.com>
Sun, 29 Oct 2006 10:27:43 +0000 (10:27 +0000)
src/configurator.c
src/plugins/dclock.c

index fe30ea9..eb5abc2 100644 (file)
@@ -459,10 +459,11 @@ on_sel_plugin_changed( GtkTreeSelection* tree_sel, GtkWidget* label )
 
     if( gtk_tree_selection_get_selected( tree_sel, &model, &it ) )
     {
-        GtkWidget *config = NULL;
+        GtkTreeView* view = gtk_tree_selection_get_tree_view( tree_sel );
+        GtkWidget *edit_btn = (GtkWidget*)g_object_get_data( (GtkWidget*)view, "edit_btn" );
         gtk_tree_model_get( model, &it, 1, &pl, -1 );
         gtk_label_set_text( label, _(pl->class->description) );
-        /* FIXME: Disable the modify button if config dlg is not available. */
+        gtk_widget_set_sensitive( edit_btn, pl->class->config != NULL );
     }
 }
 
@@ -689,6 +690,7 @@ mk_tab_plugins()
     button = gtk_button_new_from_stock( GTK_STOCK_EDIT );
     gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 2 );
     g_signal_connect( button, "clicked", G_CALLBACK(on_modify_plugin), plugin_list );
+    g_object_set_data( plugin_list, "edit_btn", button );
 
     button = gtk_button_new_from_stock( GTK_STOCK_REMOVE );
     gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 2 );
@@ -834,7 +836,9 @@ void
 configure(void)
 {
     ENTER;
-    dialog = mk_dialog();
+
+    if( ! dialog )
+        dialog = mk_dialog();
 
     update_opt_menu(edge_opt, p->edge - 1);
     update_opt_menu(allign_opt, p->allign - 1);
index 429d6bb..26fd383 100644 (file)
@@ -65,13 +65,13 @@ clock_update(gpointer data )
     gtk_label_set_markup (GTK_LABEL(dc->clockw), str) ;
 
     if (detail->tm_mday != dc->lastDay) {
-       dc->lastDay = detail->tm_mday ;
+        dc->lastDay = detail->tm_mday ;
 
-       strftime (output, sizeof(output), dc->tfmt, detail) ;
-        if ((utf8 = g_locale_to_utf8(output, -1, NULL, NULL, NULL))) {
-            gtk_tooltips_set_tip(dc->tip, dc->main, utf8, NULL) ;
-            g_free(utf8);
-        }
+        strftime (output, sizeof(output), dc->tfmt, detail) ;
+            if ((utf8 = g_locale_to_utf8(output, -1, NULL, NULL, NULL))) {
+                gtk_tooltips_set_tip(dc->tip, dc->main, utf8, NULL) ;
+                g_free(utf8);
+            }
     }
     RET(TRUE);
 }
@@ -169,13 +169,23 @@ dclock_destructor(plugin *p)
   RET();
 }
 
+static void apply_config( plugin* p )
+{
+    /* NOTE: This dirty hack is used to force the update of tooltip
+       because tooltip will be updated when dc->lastDay != today.
+    */
+    dclock* dc = (dclock*)p->priv;
+    --dc->lastDay;
+    clock_update( dc );
+}
+
 static void dclock_config( plugin *p, GtkWindow* parent )
 {
     GtkWidget* dlg;
     dclock *dc = (dclock *)p->priv;
     dlg = create_generic_config_dlg( _(p->class->name),
                                      parent,
-                                     NULL, NULL,
+                                     apply_config, p,
                                      _("Clock Format"), &dc->cfmt, G_TYPE_STRING,
                                      _("Tooltip Format"), &dc->tfmt, G_TYPE_STRING,
                                      _("Action"), &dc->action, G_TYPE_STRING,