[GnomeMeeting-devel-list] [PATCH] druid cleaning



Hi,

this is a new version of the previous patch.

There are still a few places where I'm not happy with the code (uses of
GnomeMeeting::Process ()->Get*, or g_object_get_data).

Snark
diff -ur gnomemeeting/src/common.h gnomemeeting.patched/src/common.h
--- gnomemeeting/src/common.h	2004-04-14 20:24:02.000000000 +0200
+++ gnomemeeting.patched/src/common.h	2004-04-30 10:34:20.000000000 +0200
@@ -116,7 +116,6 @@
 typedef struct _GmPrefWindow GmPrefWindow;
 typedef struct _GmLdapWindow GmLdapWindow;
 typedef struct _GmLdapWindowPage GmLdapWindowPage;
-typedef struct _GmDruidWindow GmDruidWindow;
 typedef struct _GmRtpData GmRtpData;
 
 
@@ -247,29 +246,6 @@
 };
 
 
-struct _GmDruidWindow
-{
-  GnomeDruid *druid;
-  GtkWidget *ils_register;
-  GtkWidget *audio_test_button;
-  GtkWidget *video_test_button;
-  GtkWidget *enable_microtelco;
-  GtkWidget *kind_of_net;
-  GtkWidget *progress;
-  GtkWidget *audio_manager;
-  GtkWidget *video_manager;
-  GtkWidget *audio_player;
-  GtkWidget *audio_recorder;
-  GtkWidget *video_device;
-  GtkWidget *gk_alias;
-  GtkWidget *gk_password;
-  GtkWidget *name;
-  GtkWidget *use_callto;
-  GtkWidget *mail;
-  GnomeDruidPageEdge *page_edge;
-};
-
-
 struct _GmPrefWindow
 {
   GtkListStore *codecs_list_store;
diff -ur gnomemeeting/src/druid.cpp gnomemeeting.patched/src/druid.cpp
--- gnomemeeting/src/druid.cpp	2004-04-22 11:23:11.000000000 +0200
+++ gnomemeeting.patched/src/druid.cpp	2004-04-30 11:24:59.000000000 +0200
@@ -50,8 +50,33 @@
 #include "stock-icons.h"
 #include "gm_conf.h"
 
+/* private data */
+
+struct _GmDruidWindow
+{
+  GnomeDruid *druid;
+  GtkWidget *ils_register;
+  GtkWidget *audio_test_button;
+  GtkWidget *video_test_button;
+  GtkWidget *enable_microtelco;
+  GtkWidget *kind_of_net;
+  GtkWidget *progress;
+  GtkWidget *audio_manager;
+  GtkWidget *video_manager;
+  GtkWidget *audio_player;
+  GtkWidget *audio_recorder;
+  GtkWidget *video_device;
+  GtkWidget *gk_alias;
+  GtkWidget *gk_password;
+  GtkWidget *name;
+  GtkWidget *use_callto;
+  GtkWidget *mail;
+  GnomeDruidPageEdge *page_edge;
+};
 
 /* Declarations */
+static void destroy_internal_struct (gpointer);
+
 static gint kind_of_net_hack (gpointer);
 
 static void audio_test_button_clicked (GtkWidget *,
@@ -78,19 +103,27 @@
 					     gpointer);
 
 
-static void gnomemeeting_init_druid_audio_manager_page (GnomeDruid *, 
+static void gnomemeeting_init_druid_audio_manager_page (GmDruidWindow *, 
 							int,
 							int);
 
-static void gnomemeeting_init_druid_audio_devices_page (GnomeDruid *, 
+static void gnomemeeting_init_druid_audio_devices_page (GmDruidWindow *, 
 							int,
 							int);
 
-static void gnomemeeting_init_druid_connection_type_page (GnomeDruid *, 
+static void gnomemeeting_init_druid_connection_type_page (GmDruidWindow *, 
 							  int, int);
 
 extern GtkWidget *gm;
 
+/* used to free the memory of the attached GmDruidWindow */
+static void 
+destroy_internal_struct (gpointer ptr)
+{
+  GmDruidWindow *dw = (GmDruidWindow *)ptr;
+ 
+  delete (dw);
+}
 
 /* GTK Callbacks */
 static gint
@@ -172,7 +205,7 @@
   GmDruidWindow *dw = NULL;
 
   gw = GnomeMeeting::Process ()->GetMainWindow ();
-  dw = GnomeMeeting::Process ()->GetDruidWindow ();
+  dw = (GmDruidWindow *)data;
   
   gnome_druid_set_page (dw->druid, GNOME_DRUID_PAGE (dw->page_edge));
   gnomemeeting_window_hide (gw->druid_window);
@@ -211,7 +244,7 @@
   gchar *video_recorder = NULL;
 
   gw = GnomeMeeting::Process ()->GetMainWindow ();
-  dw = GnomeMeeting::Process ()->GetDruidWindow ();
+  dw = (GmDruidWindow *)g_object_get_data (G_OBJECT (GnomeMeeting::Process ()->GetDruidWindow ()), "GMObject");
   ep = GnomeMeeting::Process ()->Endpoint ();
 
   
@@ -365,7 +398,7 @@
 
   BOOL error = TRUE;
 
-  dw = GnomeMeeting::Process ()->GetDruidWindow ();
+  dw = (GmDruidWindow *)g_object_get_data (G_OBJECT (GnomeMeeting::Process ()->GetDruidWindow ()), "GMObject");
 
   if (page == 2) {
       
@@ -408,7 +441,7 @@
 {
   GmDruidWindow *dw = NULL;
 
-  dw = GnomeMeeting::Process ()->GetDruidWindow ();
+  dw = (GmDruidWindow *)g_object_get_data (G_OBJECT (GnomeMeeting::Process ()->GetDruidWindow ()), "GMObject");
 
   gnomemeeting_druid_personal_data_check (dw->druid, GPOINTER_TO_INT (data));
 }
@@ -426,7 +459,7 @@
 {
   GmDruidWindow *dw = NULL;
 
-  dw = GnomeMeeting::Process ()->GetDruidWindow ();
+  dw = (GmDruidWindow *)g_object_get_data (G_OBJECT (GnomeMeeting::Process ()->GetDruidWindow ()), "GMObject");
 
   gnomemeeting_druid_personal_data_check (dw->druid, GPOINTER_TO_INT (data));
 }
@@ -483,7 +516,7 @@
 
   GtkWidget *child = NULL;
   
-  dw = GnomeMeeting::Process ()->GetDruidWindow ();
+  dw = (GmDruidWindow *)g_object_get_data (G_OBJECT (GnomeMeeting::Process ()->GetDruidWindow ()), "GMObject");
   
   name = (gchar *) gtk_entry_get_text (GTK_ENTRY (dw->name));
   mail = (gchar *) gtk_entry_get_text (GTK_ENTRY (dw->mail));
@@ -570,7 +603,7 @@
   
   PStringArray devices;
   
-  dw = GnomeMeeting::Process ()->GetDruidWindow ();
+  dw = (GmDruidWindow *)g_object_get_data (G_OBJECT (GnomeMeeting::Process ()->GetDruidWindow ()), "GMObject");
   gw = GnomeMeeting::Process ()->GetMainWindow ();
   ep = GnomeMeeting::Process ()->Endpoint ();
 
@@ -758,7 +791,7 @@
  * PRE          :  /
  */
 static void 
-gnomemeeting_init_druid_personal_data_page (GnomeDruid *druid, int p, int t)
+gnomemeeting_init_druid_personal_data_page (GmDruidWindow *dw, int p, int t)
 {
   GtkWidget *label = NULL;
   GtkWidget *vbox = NULL;
@@ -766,11 +799,10 @@
   gchar *title = NULL;
   gchar *text = NULL;
   
-  GmDruidWindow *dw = NULL;
+  GnomeDruid *druid = dw->druid;
   GtkWidget *page = NULL;
 
 
-  dw = GnomeMeeting::Process ()->GetDruidWindow ();
   page = gnome_druid_page_standard_new ();
 
   title = g_strdup_printf (_("Personal Information - page %d/%d"), p, t);
@@ -821,7 +853,7 @@
  * PRE          :  /
  */
 static void 
-gnomemeeting_init_druid_callto_page (GnomeDruid *druid, int p, int t)
+gnomemeeting_init_druid_callto_page (GmDruidWindow *dw, int p, int t)
 {
   GtkWidget *label = NULL;
   GtkWidget *vbox = NULL;
@@ -830,11 +862,10 @@
   gchar *title = NULL;
   gchar *text = NULL;
   
-  GmDruidWindow *dw = NULL;
+  GnomeDruid *druid = dw->druid;
   GtkWidget *page = NULL;
 
 
-  dw = GnomeMeeting::Process ()->GetDruidWindow ();
   page = gnome_druid_page_standard_new ();
 
   title = g_strdup_printf (_("Callto URL - page %d/%d"), p, t);
@@ -893,15 +924,14 @@
  * PRE          :  /
  */
 static void 
-gnomemeeting_init_druid_connection_type_page (GnomeDruid *druid,
+gnomemeeting_init_druid_connection_type_page (GmDruidWindow *dw,
 					      int p,
 					      int t)
 {
   GtkWidget *vbox = NULL;
   GtkWidget *label = NULL;
 
-  GmDruidWindow *dw = NULL;
-  GmWindow *gw = NULL;
+  GnomeDruid *druid = dw->druid;
 
   gchar *title = NULL;
   gchar *text = NULL;
@@ -909,9 +939,6 @@
   GnomeDruidPageStandard *page_standard = NULL;
 
   /* Get data */
-  dw = GnomeMeeting::Process ()->GetDruidWindow ();
-  gw = GnomeMeeting::Process ()->GetMainWindow ();
-  
   page_standard = 
     GNOME_DRUID_PAGE_STANDARD (gnome_druid_page_standard_new ());
   
@@ -952,25 +979,21 @@
  * PRE          :  /
  */
 static void 
-gnomemeeting_init_druid_audio_manager_page (GnomeDruid *druid,
+gnomemeeting_init_druid_audio_manager_page (GmDruidWindow *dw,
 					    int p,
 					    int t)
 {
   GtkWidget *label = NULL;
   GtkWidget *vbox = NULL;
 
-  GmDruidWindow *dw = NULL;
-  GmWindow *gw = NULL;
+  GnomeDruid *druid = dw->druid;
 
   gchar *title = NULL;
   gchar *text = NULL;
   
   GnomeDruidPageStandard *page_standard = NULL;
 
-  /* Get data */
-  dw = GnomeMeeting::Process ()->GetDruidWindow ();
-  gw = GnomeMeeting::Process ()->GetMainWindow ();
-  
+  /* Get data */  
   page_standard = 
     GNOME_DRUID_PAGE_STANDARD (gnome_druid_page_standard_new ());
   
@@ -1012,7 +1035,7 @@
  * PRE          :  /
  */
 static void 
-gnomemeeting_init_druid_audio_devices_page (GnomeDruid *druid,
+gnomemeeting_init_druid_audio_devices_page (GmDruidWindow *dw,
 					    int p,
 					    int t)
 {
@@ -1020,8 +1043,7 @@
   GtkWidget *vbox = NULL;
   GtkWidget *label = NULL;
 
-  GmDruidWindow *dw = NULL;
-  GmWindow *gw = NULL;
+  GnomeDruid *druid = dw->druid;
 
   gchar *title = NULL;
   gchar *text = NULL;
@@ -1029,9 +1051,6 @@
   GnomeDruidPageStandard *page_standard = NULL;
 
   /* Get data */
-  dw = GnomeMeeting::Process ()->GetDruidWindow ();
-  gw = GnomeMeeting::Process ()->GetMainWindow ();
-  
   page_standard = 
     GNOME_DRUID_PAGE_STANDARD (gnome_druid_page_standard_new ());
   
@@ -1110,15 +1129,14 @@
  * PRE          :  /
  */
 static void 
-gnomemeeting_init_druid_video_manager_page (GnomeDruid *druid,
+gnomemeeting_init_druid_video_manager_page (GmDruidWindow *dw,
 					    int p,
 					    int t)
 {
   GtkWidget *label = NULL;
   GtkWidget *vbox = NULL;
 
-  GmDruidWindow *dw = NULL;
-  GmWindow *gw = NULL;
+  GnomeDruid *druid = dw->druid;
 
   gchar *title = NULL;
   gchar *text = NULL;
@@ -1126,9 +1144,6 @@
   GnomeDruidPageStandard *page_standard = NULL;
 
   /* Get data */
-  dw = GnomeMeeting::Process ()->GetDruidWindow ();
-  gw = GnomeMeeting::Process ()->GetMainWindow ();
-  
   page_standard = 
     GNOME_DRUID_PAGE_STANDARD (gnome_druid_page_standard_new ());
   
@@ -1169,7 +1184,7 @@
  * PRE          :  /
  */
 static void 
-gnomemeeting_init_druid_video_devices_page (GnomeDruid *druid,
+gnomemeeting_init_druid_video_devices_page (GmDruidWindow *dw,
 					    int p,
 					    int t)
 {
@@ -1177,8 +1192,7 @@
   GtkWidget *vbox = NULL;
   GtkWidget *label = NULL;
 
-  GmDruidWindow *dw = NULL;
-  GmWindow *gw = NULL;
+  GnomeDruid *druid = dw->druid;
 
   gchar *title = NULL;
   gchar *text = NULL;
@@ -1186,9 +1200,6 @@
   GnomeDruidPageStandard *page_standard = NULL;
 
   /* Get data */
-  dw = GnomeMeeting::Process ()->GetDruidWindow ();
-  gw = GnomeMeeting::Process ()->GetMainWindow ();
-  
   page_standard = 
     GNOME_DRUID_PAGE_STANDARD (gnome_druid_page_standard_new ());
   
@@ -1242,13 +1253,13 @@
 }
 
 
-
 /* Functions */
 GtkWidget *
-gnomemeeting_druid_window_new (GmDruidWindow *dw)
+gnomemeeting_druid_window_new ()
 {
   GtkWidget *window = NULL;
-  
+  GmDruidWindow *dw = NULL;
+
   gchar *title = NULL;
 
   GnomeDruidPageEdge *page_final = NULL;
@@ -1260,6 +1271,11 @@
   gtk_window_set_title (GTK_WINDOW (window), 
 			_("First Time Configuration Druid"));
   gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
+
+  dw = new GmDruidWindow;
+  g_object_set_data_full (G_OBJECT (window), "GMObject",
+			  (gpointer)dw, destroy_internal_struct);
+
   dw->druid = GNOME_DRUID (gnome_druid_new ());
 
   gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (dw->druid));
@@ -1292,13 +1308,13 @@
 
 
   /* Create the different pages */
-  gnomemeeting_init_druid_personal_data_page (dw->druid, 2, 9);
-  gnomemeeting_init_druid_callto_page (dw->druid, 3, 9);
-  gnomemeeting_init_druid_connection_type_page (dw->druid, 4, 9);
-  gnomemeeting_init_druid_audio_manager_page (dw->druid, 5, 9);
-  gnomemeeting_init_druid_audio_devices_page (dw->druid, 6, 9);
-  gnomemeeting_init_druid_video_manager_page (dw->druid, 7, 9);
-  gnomemeeting_init_druid_video_devices_page (dw->druid, 8, 9);
+  gnomemeeting_init_druid_personal_data_page (dw, 2, 9);
+  gnomemeeting_init_druid_callto_page (dw, 3, 9);
+  gnomemeeting_init_druid_connection_type_page (dw, 4, 9);
+  gnomemeeting_init_druid_audio_manager_page (dw, 5, 9);
+  gnomemeeting_init_druid_audio_devices_page (dw, 6, 9);
+  gnomemeeting_init_druid_video_manager_page (dw, 7, 9);
+  gnomemeeting_init_druid_video_devices_page (dw, 8, 9);
 
   /*
   gnomemeeting_init_druid_ixj_device_page (dw->druid, 6, 7);
@@ -1322,13 +1338,27 @@
 		    G_CALLBACK (gnomemeeting_druid_quit), dw->druid);
 
   g_signal_connect (G_OBJECT (dw->druid), "cancel",
-		    G_CALLBACK (gnomemeeting_druid_cancel), NULL);
+		    G_CALLBACK (gnomemeeting_druid_cancel), dw);
 
   g_signal_connect (G_OBJECT (window), "delete_event",
-		    G_CALLBACK (gnomemeeting_druid_destroy), NULL);
+		    G_CALLBACK (gnomemeeting_druid_destroy), dw);
 
   gtk_widget_show_all (GTK_WIDGET (dw->druid));
 
   return window;
 }
 
+void 
+gnomemeeting_druid_set_test_buttons_sensitivity (GtkWidget *druid,
+						 gboolean value)
+{
+  GmDruidWindow *dw = NULL;
+
+  dw = (GmDruidWindow *)g_object_get_data (G_OBJECT (druid), "GMObject");
+
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dw->video_test_button),
+				value);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dw->audio_test_button),
+				value);
+
+}
diff -ur gnomemeeting/src/druid.h gnomemeeting.patched/src/druid.h
--- gnomemeeting/src/druid.h	2004-01-20 12:00:40.000000000 +0100
+++ gnomemeeting.patched/src/druid.h	2004-04-30 10:34:21.000000000 +0200
@@ -37,11 +37,16 @@
 
 #include "common.h"
 
+typedef struct _GmDruidWindow GmDruidWindow;
 
 /* DESCRIPTION  :  /
  * BEHAVIOR     :  Builds the "First time configuration druid" and returns it.
  * PRE          :  /
  */
-GtkWidget *
-gnomemeeting_druid_window_new (GmDruidWindow *);
+GtkWidget *gnomemeeting_druid_window_new ();
 
+/* DESCRIPTION  :  /
+ * BEHAVIOR     :  Makes the device test buttons active/inactive
+ * PRE          :  /
+ */
+void gnomemeeting_druid_set_test_buttons_sensitivity (GtkWidget *, gboolean);
diff -ur gnomemeeting/src/gnomemeeting.cpp gnomemeeting.patched/src/gnomemeeting.cpp
--- gnomemeeting/src/gnomemeeting.cpp	2004-04-26 23:02:49.000000000 +0200
+++ gnomemeeting.patched/src/gnomemeeting.cpp	2004-04-30 10:34:21.000000000 +0200
@@ -112,7 +112,6 @@
   gw = new GmWindow ();
   pw = new GmPrefWindow ();
   lw = new GmLdapWindow ();
-  dw = new GmDruidWindow ();
   rtp = new GmRtpData ();
 
   memset ((void *) rtp, 0, sizeof (struct _GmRtpData));
@@ -161,7 +160,6 @@
   delete (gw);
   delete (pw);
   delete (lw);
-  delete (dw);
   delete (rtp);
 }
 
@@ -374,10 +372,10 @@
 }
 
 
-GmDruidWindow *
+GtkWidget *
 GnomeMeeting::GetDruidWindow ()
 {
-  return dw;
+  return gw->druid_window;
 }
 
 
@@ -440,7 +438,7 @@
   gw->addressbook_window = gm_addressbook_window_new ();
 #endif
   gw->ldap_window = gnomemeeting_ldap_window_new (lw);
-  gw->druid_window = gnomemeeting_druid_window_new (dw);
+  gw->druid_window = gnomemeeting_druid_window_new ();
 #ifndef WIN32
   gw->docklet = gnomemeeting_tray_new ();
   gw->tray_popup_menu = gnomemeeting_tray_init_menu (gw->docklet);
diff -ur gnomemeeting/src/gnomemeeting.h gnomemeeting.patched/src/gnomemeeting.h
--- gnomemeeting/src/gnomemeeting.h	2004-04-18 09:04:56.000000000 +0200
+++ gnomemeeting.patched/src/gnomemeeting.h	2004-04-30 10:34:21.000000000 +0200
@@ -128,11 +128,11 @@
 
 
   /* DESCRIPTION  :  /
-   * BEHAVIOR     :  Returns a pointer to the GmDruidWindow
+   * BEHAVIOR     :  Returns a pointer to the druid window
    *                 structure of widgets.
    * PRE          :  /
    */
-  GmDruidWindow *GetDruidWindow ();
+  GtkWidget *GetDruidWindow ();
 
 
   /* DESCRIPTION  :  /
@@ -196,7 +196,6 @@
   
   GmWindow *gw;
   GmLdapWindow *lw;
-  GmDruidWindow *dw;
   GmPrefWindow *pw;
   GmRtpData *rtp;
 
diff -ur gnomemeeting/src/sound_handling.cpp gnomemeeting.patched/src/sound_handling.cpp
--- gnomemeeting/src/sound_handling.cpp	2004-04-18 20:21:49.000000000 +0200
+++ gnomemeeting.patched/src/sound_handling.cpp	2004-04-30 10:34:21.000000000 +0200
@@ -43,6 +43,7 @@
 #include "endpoint.h"
 #include "lid.h"
 #include "misc.h"
+#include "druid.h"
 
 #include "gtklevelmeter.h"
 #include "dialog.h"
@@ -77,12 +78,11 @@
 #ifndef DISABLE_GNOME
 static void dialog_response_cb (GtkWidget *w, gint, gpointer data)
 {
-  GmDruidWindow *dw = NULL;
+  GtkWidget *dw = NULL;
 
   dw = GnomeMeeting::Process ()->GetDruidWindow ();
 
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dw->audio_test_button),
-				false);
+  gnomemeeting_druid_set_test_buttons_sensitivity (dw, FALSE);
 
   gtk_widget_hide (w);
 }
diff -ur gnomemeeting/src/videograbber.cpp gnomemeeting.patched/src/videograbber.cpp
--- gnomemeeting/src/videograbber.cpp	2004-04-12 14:50:36.000000000 +0200
+++ gnomemeeting.patched/src/videograbber.cpp	2004-04-30 10:34:21.000000000 +0200
@@ -44,6 +44,7 @@
 #include "menu.h"
 #include "misc.h"
 #include "log_window.h"
+#include "druid.h"
 
 #include "dialog.h"
 #include "gm_conf.h"
@@ -563,8 +564,8 @@
   gchar *tmp = NULL;
 
   gw = GnomeMeeting::Process ()->GetMainWindow ();
-  dw = GnomeMeeting::Process ()->GetDruidWindow ();
-
+  dw = (GmDruidWindow *)g_object_get_data (G_OBJECT (GnomeMeeting::Process ()->GetDruidWindow ()), "GMObject");
+  
   PWaitAndSignal m(quit_mutex);
   thread_sync_point.Signal ();
 
@@ -700,8 +701,7 @@
   }
 
   gdk_threads_enter ();
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dw->video_test_button),
-				FALSE);
+  gnomemeeting_druid_set_test_buttons_sensitivity (gw->druid_window, FALSE);
   if (test_dialog)
     gtk_widget_destroy (test_dialog);
   gdk_threads_leave ();


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