Re: [PATCH to gtop] making gtop stable and gtk theme-friendly



On Fri, 2 Mar 2001, Vlad Harchev wrote:

 Oops, 
 I have an impression that you may want to look at the patch itself.. :)

> 
>  Hi, 
> 
>  After applying this patch gtop becomes stable again (otherwise it will crash
> if "details" and "memory map" dialogs are closed by pressing Esc, and probably
> if closed using "Close" button), and makes it gtk theme-friendly
> (gtk_widget_ensure_style(widget) needs to be called before
> gtk_widget_get_style() - otherwise you'll get a builtin gtk style - black text
> on gray - in the copy). Also after this patch global style (used by ALL
> widgets - including menu) won't be altered any more after "process details"
> dialog is opened first time - the following hunks fix this particular problem:
> -	style = gtk_widget_get_style (l); 
> +	style = gtk_style_copy(gtk_widget_get_style (l));
> 
>  This is a patch against gtop from gnome-1.4b1.
> 
>  Could it be committed?

 Best regards,
  -Vlad
diff -rub --exclude=gtop.pot gtop-1.0.12~/details.c gtop-1.0.12/details.c
--- gtop-1.0.12~/details.c	Mon Feb 14 02:30:41 2000
+++ gtop-1.0.12/details.c	Fri Mar  2 19:33:51 2001
@@ -28,7 +28,7 @@
 
 static void set_mem_map (GTopProcMapRow **rows, GtkWidget *mcl);
 
-static int  delete_event_handler (GtkWidget *, gpointer, GTopProcViewData *);
+static void  destroy_handler (GtkWidget *, GTopProcViewData *);
 static void auto_update_cb (GtkWidget *, GTopProcViewData *);
 static void close_cb (GtkWidget *, GTopProcViewData *);
 static void update_cb (GtkWidget *, GTopProcViewData *);
@@ -117,8 +117,8 @@
 			    FALSE, TRUE, GNOME_PAD_SMALL);
 
 	gtk_signal_connect
-	    (GTK_OBJECT (d->details.dwin), "delete_event",
-	     GTK_SIGNAL_FUNC (delete_event_handler), (gpointer) d);
+	    (GTK_OBJECT (d->details.dwin), "destroy",
+	     GTK_SIGNAL_FUNC (destroy_handler), (gpointer) d);
 
 	gnome_dialog_button_connect
 	    (GNOME_DIALOG (d->details.dwin), 1,
@@ -150,17 +150,11 @@
     display_details (d, pid);
 }
 
-static int
-delete_event_handler (GtkWidget *widget,
-		      gpointer func_data,
-		      GTopProcViewData *d)
+static void
+destroy_handler (GtkWidget *widget, GTopProcViewData *d)
 {
-    gtk_widget_destroy (d->details.dwin);
-
     d->details.dwin = d->details.icl = NULL;
     d->details.mcl = d->details.gswin = NULL;
-
-    return TRUE;
 }
 
 static void
@@ -202,7 +196,7 @@
     gnome_config_set_int ("gtop/details/h", h);
     gnome_config_sync ();
 
-    delete_event_handler (widget, NULL, d);
+    gtk_widget_destroy(d->details.dwin);
 }
 
 static void
@@ -333,6 +327,7 @@
 
 	dt->icl = gtk_clist_new (3);
 
+	gtk_widget_ensure_style(dt->icl);
 	style = gtk_style_copy (gtk_widget_get_style (dt->icl));
 	style->font = gtop_properties.procview.font;
 	gtk_widget_set_style (dt->icl, style);
@@ -343,6 +338,7 @@
 
 	    gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5);
 
+	    gtk_widget_ensure_style(l);
 	    style = gtk_style_copy (gtk_widget_get_style (l));
 	    style->font = gtop_properties.procview.font;
 	    gtk_widget_set_style (l, style);
@@ -598,6 +594,7 @@
 
     mcl = gtk_clist_new (MAP_COLS);
 		
+    gtk_widget_ensure_style(mcl);	
     style = gtk_style_copy (gtk_widget_get_style (mcl));
     style->font = gtop_properties.procview.font;
     gtk_widget_set_style (mcl, style);
@@ -611,6 +608,7 @@
 	else
 	    gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5);
 
+	gtk_widget_ensure_style(l);
 	style = gtk_style_copy (gtk_widget_get_style (l));
 	style->font = gtop_properties.procview.font;
 	gtk_widget_set_style (l, style);
@@ -704,6 +702,7 @@
 
 	dt->mcl = gtk_clist_new (MAP_COLS);
 		
+	gtk_widget_ensure_style(dt->mcl);
 	style = gtk_style_copy (gtk_widget_get_style (dt->mcl));
 	style->font = gtop_properties.procview.font;
 	gtk_widget_set_style (dt->mcl, style);
@@ -717,6 +716,7 @@
 	    else
 		gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5);
 
+	    gtk_widget_ensure_style (l);
 	    style = gtk_style_copy (gtk_widget_get_style (l));
 	    style->font = gtop_properties.procview.font;
 	    gtk_widget_set_style (l, style);
diff -rub --exclude=gtop.pot gtop-1.0.12~/process-details.c gtop-1.0.12/process-details.c
--- gtop-1.0.12~/process-details.c	Mon Feb 14 02:30:41 2000
+++ gtop-1.0.12/process-details.c	Fri Mar  2 19:34:18 2001
@@ -19,9 +19,8 @@
 #include <gtop-graph.h>
 #include <process-details.h>
 
-static int
-delete_event_handler		(GtkWidget *widget, gpointer func_data,
-				 GTopProcessDetails *d);
+static void
+destroy_handler		(GtkWidget *widget, GTopProcessDetails *d);
 static void
 update_cb			(GtkWidget *widget, GTopProcessDetails *d);
 
@@ -162,8 +161,8 @@
     update_cb (NULL, d);
 
     gtk_signal_connect
-	(GTK_OBJECT (d->dialog), "delete_event",
-	 GTK_SIGNAL_FUNC (delete_event_handler), (gpointer) d);
+	(GTK_OBJECT (d->dialog), "destroy",
+	 GTK_SIGNAL_FUNC (destroy_handler), (gpointer) d);
 
     gnome_dialog_button_connect
 	(GNOME_DIALOG (d->dialog), 0,
@@ -178,20 +177,16 @@
     g_free (title);
 }
 
-static int
-delete_event_handler (GtkWidget *widget, gpointer func_data,
-		      GTopProcessDetails *d)
+static void
+destroy_handler (GtkWidget *widget, GTopProcessDetails *d)
 {
     if (d->timeout_id) {
 	gtk_timeout_remove (d->timeout_id);
 	d->timeout_id = 0;
     }
 
-    gtk_widget_destroy (d->dialog);
     d->dialog = NULL;
     g_free (d);
-
-    return TRUE;
 }
 
 static void
@@ -219,7 +214,7 @@
     gnome_config_set_int ("gtop/process_details/h", h);
     gnome_config_sync ();
 
-    delete_event_handler (widget, NULL, d);
+    gtk_widget_destroy(d->dialog);
 }
 
 static gint
@@ -299,6 +294,7 @@
     gtk_clist_freeze (list);
     gtk_clist_clear (list);
 
+    gtk_widget_ensure_style(GTK_WIDGET(list));
     font = gtk_widget_get_style (GTK_WIDGET(list))->font;
     cw = gdk_char_width (font, 'M');
 
@@ -360,8 +356,9 @@
     l = gtk_label_new (_("Process State:"));
     gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5);
     gtk_misc_set_padding (GTK_MISC (l), GNOME_PAD_SMALL, 0);
+    gtk_widget_ensure_style(l);
 
-    style = gtk_widget_get_style (l);
+    style = gtk_style_copy(gtk_widget_get_style (l));
     style->font = gtop_properties.procview.font;
     gtk_widget_set_style (l, style);
 
@@ -424,8 +421,9 @@
     l = gtk_label_new (_("Command Line:"));
     gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5);
     gtk_misc_set_padding (GTK_MISC (l), GNOME_PAD_SMALL, 0);
+    gtk_widget_ensure_style(l);
 
-    style = gtk_widget_get_style (l);
+    style = gtk_style_copy(gtk_widget_get_style (l));
     style->font = gtop_properties.procview.font;
     gtk_widget_set_style (l, style);
 
@@ -528,8 +526,9 @@
     l = gtk_label_new (_("Process Credentials:"));
     gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5);
     gtk_misc_set_padding (GTK_MISC (l), GNOME_PAD_SMALL, 0);
+    gtk_widget_ensure_style(l);
 
-    style = gtk_widget_get_style (l);
+    style = gtk_style_copy(gtk_widget_get_style (l));
     style->font = gtop_properties.procview.font;
     gtk_widget_set_style (l, style);
 


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