[gnome-media] profiles: Bug 524364 - libglade -> gtkbuilder



commit 8be08d426e2f3ddb86cff4015bcae02d1c7ac7b0
Author: Marc-Andre Lureau <marcandre lureau gmail com>
Date:   Sun Jul 12 18:04:50 2009 +0300

    profiles: Bug 524364 - libglade -> gtkbuilder
    
    Finally remove glade from GNOME Media.
    
    I figure out that the profiles/glade directory contain a glade plugin,
    not for others to use in their own UI, but to be able to modify the
    GNOME Media UI gnome-audio-profile-edit.ui itself.
    
    This is quite important to have for now. However, A saner solution
    would be to fill a regular dialog, thus avoiding a custom dialog and
    its glade registration.

 configure.ac                                  |   19 +-
 profiles/Makefile.am                          |   16 +-
 profiles/audio-profile-choose.c               |    1 -
 profiles/audio-profile-edit.c                 |   42 ++-
 profiles/audio-profile-private.h              |    7 -
 profiles/audio-profiles-edit.c                |   37 +-
 profiles/glade/Makefile.am                    |   16 +-
 profiles/glade/gnome-media-profiles-catalog.c |    8 +
 profiles/glade/gnome-media-profiles-glade.c   |   28 --
 profiles/glade/gnome-media-profiles.xml       |   10 +
 profiles/gmp-util.c                           |   61 ++--
 profiles/gmp-util.h                           |    9 +-
 profiles/gnome-audio-profile-edit.ui          |  204 ++++++++++
 profiles/gnome-audio-profile-new.ui           |  195 +++++++++
 profiles/gnome-audio-profiles-properties.c    |    5 +-
 profiles/gnome-audio-profiles-test.c          |    6 +-
 profiles/gnome-audio-profiles.glade2          |  533 -------------------------
 profiles/gnome-media-profiles.c               |   59 +---
 profiles/gnome-media-profiles.pc.in           |    4 +-
 19 files changed, 537 insertions(+), 723 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 330a9ee..b84235b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -59,7 +59,6 @@ AC_MSG_NOTICE([Using $GM_ERROR_CFLAGS as error checking CFLAGS])
 
 GLIB_REQUIRED_VERSION=2.18.2
 GTK_REQUIRED_VERSION=2.14.0
-LIBGLADE_REQUIRED_VERSION=1.99.2
 GCONF_REQUIRED_VERSION=2.6.1
 PA_REQUIRED_VERSION=0.9.15
 CANBERRA_REQUIRED_VERSION=0.4
@@ -143,9 +142,9 @@ AC_ARG_ENABLE([profiles],
 
 if test "x$enable_profiles" = "xyes"; then
   PKG_CHECK_MODULES(GMP, [
+    gtk+-2.0 >= $GTK_REQUIRED_VERSION
     gstreamer-0.10
     gconf-2.0
-    libglade-2.0
     gio-2.0],
     have_profiles=yes)
 fi
@@ -153,6 +152,20 @@ AC_SUBST(GMP_CFLAGS)
 AC_SUBST(GMP_LIBS)
 AM_CONDITIONAL(HAVE_GMP, [test x$have_profiles = xyes])
 
+dnl Profiles glade ui: needed to edit .ui files with glade3
+have_gladeui=no
+
+PKG_CHECK_MODULES(GLADEUI, [gladeui-1.0], have_gladeui=yes)
+AC_SUBST(GLADEUI_CFLAGS)
+AC_SUBST(GLADEUI_LIBS)
+AM_CONDITIONAL(HAVE_GLADEUI, [test x$have_gladeui = xyes])
+
+GLADEUI_CATALOG_DIR="`$PKG_CONFIG --variable=catalogdir gladeui-1.0`"
+AC_SUBST(GLADEUI_CATALOG_DIR)
+
+GLADEUI_MODULE_DIR="`$PKG_CONFIG --variable=moduledir gladeui-1.0`"
+AC_SUBST(GLADEUI_MODULE_DIR)
+
 dnl=======================================================================
 dnl Check for GStreamer and GSR deps
 dnl=======================================================================
@@ -433,7 +446,7 @@ echo "
 
         Volume Control          $have_pulseaudio
         GStreamer properties:   $have_gstprops
-        GStreamer profiles:     $have_profiles
+        GStreamer profiles:     $have_profiles (GladeUI: $have_gladeui)
         Sound recorder:         $have_grecord$grecord_reason
 
   *Deprecated*:
diff --git a/profiles/Makefile.am b/profiles/Makefile.am
index 55468c5..f413161 100644
--- a/profiles/Makefile.am
+++ b/profiles/Makefile.am
@@ -4,8 +4,7 @@ noinst_PROGRAMS =
 defines = \
 	-DG_LOG_DOMAIN=\"gnome-media-profiles\" \
 	-DDATADIR="\"$(pkgdatadir)\"" \
-	-DGMP_GLADE_DIR=\"$(gladedir)\" \
-	-DGM_AUDIO_GLADE_FILE=\"gnome-audio-profiles.glade2\" \
+	-DGMP_UIDIR=\"$(uidir)\" \
 	-DGNOMELOCALEDIR=\""$(datadir)/locale"\"
 
 if HAVE_GSTREAMER
@@ -20,8 +19,8 @@ lib_LTLIBRARIES = libgnome-media-profiles.la
 @INTLTOOL_DESKTOP_RULE@
 @INTLTOOL_SCHEMAS_RULE@
 
-gladedir = $(pkgdatadir)/glade
-glade_DATA = gnome-audio-profiles.glade2
+uidir = $(pkgdatadir)
+ui_DATA = gnome-audio-profile-new.ui gnome-audio-profile-edit.ui
 
 gnome_audio_profiles_properties_SOURCES = gnome-audio-profiles-properties.c
 gnome_audio_profiles_properties_CFLAGS = $(GMP_CFLAGS) $(defines) -I$(top_srcdir)
@@ -67,12 +66,15 @@ endif
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = gnome-media-profiles.pc
-
-EXTRA_DIST = $(glade_DATA) $(schema_DATA) $(pkgconfig_DATA)
+EXTRA_DIST = $(ui_DATA) $(schema_DATA) $(pkgconfig_DATA)
 
 CLEANFILES = $(schema_DATA)
 
 # "." is dirty hack to first build our .la in this dir before moving to glade
-SUBDIRS =  . help glade
+SUBDIRS =  . help
+
+if HAVE_GLADEUI
+SUBDIRS += glade
+endif
 
 -include $(top_srcdir)/git.mk
diff --git a/profiles/audio-profile-choose.c b/profiles/audio-profile-choose.c
index 8158a80..0990c75 100644
--- a/profiles/audio-profile-choose.c
+++ b/profiles/audio-profile-choose.c
@@ -26,7 +26,6 @@
 #include <string.h>
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
-#include <glade/glade-xml.h>
 #include <gio/gio.h>
 #include <gst/gst.h>
 
diff --git a/profiles/audio-profile-edit.c b/profiles/audio-profile-edit.c
index bbdddf5..745ee71 100644
--- a/profiles/audio-profile-edit.c
+++ b/profiles/audio-profile-edit.c
@@ -26,7 +26,6 @@
 #include <string.h>
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
-#include <glade/glade-xml.h>
 #include <gst/gst.h>
 
 #include "gmp-util.h"
@@ -37,7 +36,7 @@
 struct _GMAudioProfileEditPrivate
 {
   GConfClient *conf;
-  GladeXML *xml;
+  GtkBuilder *builder;
   GMAudioProfile *profile;
   GtkWidget *content;
 };
@@ -70,7 +69,7 @@ G_DEFINE_TYPE (GMAudioProfileEdit, gm_audio_profile_edit, GTK_TYPE_DIALOG)
 
 /* ui callbacks */
 
-/* initialize a dialog widget from the glade xml file */
+/* initialize a dialog widget from the ui builder file */
 static void
 gm_audio_profile_edit_init (GMAudioProfileEdit *dialog)
 {
@@ -125,7 +124,7 @@ gm_audio_profile_edit_response (GtkDialog *dialog,
 
       return;
     }
-      
+
   /* FIXME: hide or destroy ? */
   gtk_widget_hide (GTK_WIDGET (dialog));
 }
@@ -223,14 +222,21 @@ GtkWidget*
 gm_audio_profile_edit_new (GConfClient *conf, const char *id)
 {
   GMAudioProfileEdit *dialog;
-  GladeXML *xml;
+  GtkBuilder *builder;
   GtkWidget *w;
   GtkTextBuffer *tb;
+  GError *error = NULL;
 
   /* get the dialog */
-  xml = gmp_util_load_glade_file (GM_AUDIO_GLADE_FILE,
-                                  "profile-edit-dialog", NULL);
-  dialog = (GMAudioProfileEdit *) glade_xml_get_widget (xml, "profile-edit-dialog");
+  builder = gmp_util_load_builder_file ("gnome-audio-profile-edit.ui", NULL, &error);
+  if (error != NULL) {
+    g_warning (error->message);
+    g_error_free (error);
+    return NULL;
+  }
+
+  dialog = GM_AUDIO_PROFILE_EDIT (gtk_builder_get_object (builder, "profile-edit-dialog"));
+  g_return_val_if_fail (dialog != NULL, NULL);
 
   /* make sure we have priv */
   if (dialog->priv == NULL)
@@ -243,7 +249,7 @@ gm_audio_profile_edit_new (GConfClient *conf, const char *id)
      * smell to good to me */
     dialog->priv = g_new0 (GMAudioProfileEditPrivate, 1);
   }
-  dialog->priv->xml = xml;
+  dialog->priv->builder = builder;
 
   /* save the GConf stuff and get the profile belonging to this id */
   dialog->priv->conf = g_object_ref (conf);
@@ -252,24 +258,24 @@ gm_audio_profile_edit_new (GConfClient *conf, const char *id)
   g_assert (dialog->priv->profile);
 
   /* autoconnect doesn't handle data pointers, sadly, so do by hand */
-  w = glade_xml_get_widget (xml, "profile-name-entry");
+  w = GTK_WIDGET (gtk_builder_get_object (builder, "profile-name-entry"));
   gm_audio_profile_edit_update_name (dialog, dialog->priv->profile);
   g_signal_connect (G_OBJECT (w), "changed",
                     G_CALLBACK (on_profile_name_changed), dialog->priv->profile);
-  w = glade_xml_get_widget (xml, "profile-description-textview");
+  w = GTK_WIDGET (gtk_builder_get_object (builder, "profile-description-textview"));
   gm_audio_profile_edit_update_description (dialog, dialog->priv->profile);
   tb = gtk_text_view_get_buffer (GTK_TEXT_VIEW (w));
   g_signal_connect (G_OBJECT (tb), "changed",
                     G_CALLBACK (on_profile_description_changed), dialog->priv->profile);
-   w = glade_xml_get_widget (xml, "profile-pipeline-entry");
+  w = GTK_WIDGET (gtk_builder_get_object (builder, "profile-pipeline-entry"));
   gm_audio_profile_edit_update_pipeline (dialog, dialog->priv->profile);
   g_signal_connect (G_OBJECT (w), "changed",
                     G_CALLBACK (on_profile_pipeline_changed), dialog->priv->profile);
-  w = glade_xml_get_widget (xml, "profile-extension-entry");
+  w = GTK_WIDGET (gtk_builder_get_object (builder, "profile-extension-entry"));
   gm_audio_profile_edit_update_extension (dialog, dialog->priv->profile);
   g_signal_connect (G_OBJECT (w), "changed",
                     G_CALLBACK (on_profile_extension_changed), dialog->priv->profile);
-  w = glade_xml_get_widget (xml, "profile-active-button");
+  w = GTK_WIDGET (gtk_builder_get_object (builder, "profile-active-button"));
   gm_audio_profile_edit_update_active (dialog, dialog->priv->profile);
   g_signal_connect (G_OBJECT (w), "toggled",
                     G_CALLBACK (on_profile_active_toggled), dialog->priv->profile);
@@ -403,14 +409,14 @@ static GtkWidget*
 gm_audio_profile_edit_get_widget (GMAudioProfileEdit *dialog,
                              const char *widget_name)
 {
-  GladeXML *xml;
+  GtkBuilder *builder;
   GtkWidget *w;
 
-  xml = dialog->priv->xml;
+  builder = dialog->priv->builder;
 
-  g_return_val_if_fail (xml, NULL);
+  g_return_val_if_fail (builder, NULL);
 
-  w = glade_xml_get_widget (xml, widget_name);
+  w = GTK_WIDGET (gtk_builder_get_object (builder, widget_name));
 
   if (w == NULL)
     g_error ("No such widget %s", widget_name);
diff --git a/profiles/audio-profile-private.h b/profiles/audio-profile-private.h
index 2bc7cea..fa9b4ea 100644
--- a/profiles/audio-profile-private.h
+++ b/profiles/audio-profile-private.h
@@ -23,8 +23,6 @@
 #define AUDIO_PROFILE_PRIVATE_H
 
 #include <gconf/gconf-client.h>
-#include <glade/glade.h>
-#include <glade/glade-build.h>
 
 #include "gmp-conf.h"
 #include "audio-profile.h"
@@ -50,11 +48,6 @@ gboolean	gm_audio_setting_mask_is_empty	(const GMAudioSettingMask *mask);
 void		gm_audio_profile_delete_list	(GConfClient *conf,
 						 GList *deleted_profiles,
 						 GError **error);
-void        gtk_dialog_build_children (GladeXML *self, GtkWidget *w,
-						GladeWidgetInfo *info);
-GtkWidget*  dialog_find_internal_child (GladeXML *xml,
-						GtkWidget *parent,
-						const gchar *childname);
 
 G_END_DECLS
 
diff --git a/profiles/audio-profiles-edit.c b/profiles/audio-profiles-edit.c
index 5c05565..23c1681 100644
--- a/profiles/audio-profiles-edit.c
+++ b/profiles/audio-profiles-edit.c
@@ -26,7 +26,6 @@
 #include <string.h>
 #include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
-#include <glade/glade-xml.h>
 #include <gst/gst.h>
 
 #include "audio-profile.h"
@@ -54,14 +53,6 @@ static void gm_audio_profiles_edit_class_init	(GMAudioProfilesEditClass *klass);
 static void gm_audio_profiles_edit_finalize	(GObject *object);
 
 
-/* responses */
-enum
-{
-  RESPONSE_CREATE = GTK_RESPONSE_ACCEPT, /* Arghhh: Glade wants a GTK_RESPONSE_* for dialog buttons */
-  RESPONSE_CANCEL,
-  RESPONSE_DELETE
-};
-
 /* profile list column names */
 enum
 {
@@ -802,7 +793,7 @@ new_profile_response_callback (GtkWidget *new_profile_dialog,
                                int        response_id,
                                GMAudioProfilesEdit *dialog)
 {
-  if (response_id == RESPONSE_CREATE)
+  if (response_id == GTK_RESPONSE_ACCEPT)
   {
     GtkWidget *name_entry;
     char *name;
@@ -910,25 +901,29 @@ gm_audio_profiles_edit_new_profile (GMAudioProfilesEdit *dialog,
   GtkWindow *old_transient_parent;
   GtkWidget *create_button;
   gint response;
+  GError *error = NULL;
 
   if (dialog->priv->new_profile_dialog == NULL)
   {
-    GladeXML *xml;
+    GtkBuilder *builder;
     GtkWidget *w, *wl;
     GtkWidget *create_button;
     GtkSizeGroup *size_group, *size_group_labels;
 
-    xml = gmp_util_load_glade_file (GM_AUDIO_GLADE_FILE, "new-profile-dialog", transient_parent);
+    builder = gmp_util_load_builder_file ("gnome-audio-profile-new.ui", transient_parent, &error);
 
-    if (xml == NULL)
+    if (error != NULL) {
+      g_warning (error->message);
+      g_error_free (error);
       return;
+    }
 
-    dialog->priv->new_profile_dialog = glade_xml_get_widget (xml, "new-profile-dialog");
+    dialog->priv->new_profile_dialog = GTK_WIDGET (gtk_builder_get_object (builder, "new-profile-dialog"));
     g_signal_connect (G_OBJECT (dialog->priv->new_profile_dialog), "response", G_CALLBACK (new_profile_response_callback), dialog);
 
     g_object_add_weak_pointer (G_OBJECT (dialog->priv->new_profile_dialog), (void**) &dialog->priv->new_profile_dialog);
 
-    create_button = glade_xml_get_widget (xml, "new-profile-create-button");
+    create_button = GTK_WIDGET (gtk_builder_get_object (builder, "new-profile-create-button"));
     g_object_set_data (G_OBJECT (dialog->priv->new_profile_dialog), "create_button", create_button);
     gtk_widget_set_sensitive (create_button, FALSE);
 
@@ -936,7 +931,7 @@ gm_audio_profiles_edit_new_profile (GMAudioProfilesEdit *dialog,
     size_group_labels = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
 
     /* the name entry */
-    w = glade_xml_get_widget (xml, "new-profile-name-entry");
+    w = GTK_WIDGET (gtk_builder_get_object (builder, "new-profile-name-entry"));
     g_object_set_data (G_OBJECT (dialog->priv->new_profile_dialog), "name_entry", w);
     g_signal_connect (G_OBJECT (w), "changed", G_CALLBACK (new_profile_name_entry_changed_callback), create_button);
     gtk_entry_set_activates_default (GTK_ENTRY (w), TRUE);
@@ -944,32 +939,32 @@ gm_audio_profiles_edit_new_profile (GMAudioProfilesEdit *dialog,
     // FIXME terminal_util_set_atk_name_description (w, _("Enter profile name"), NULL);
     gtk_size_group_add_widget (size_group, w);
 
-    wl = glade_xml_get_widget (xml, "new-profile-name-label");
+    wl = GTK_WIDGET (gtk_builder_get_object (builder, "new-profile-name-label"));
     gtk_label_set_mnemonic_widget (GTK_LABEL (wl), w);
     // FIXME terminal_util_set_labelled_by (w, GTK_LABEL (wl));
     gtk_size_group_add_widget (size_group_labels, wl);
 
 #ifdef BASE
     /* the base profile option menu */
-    w = glade_xml_get_widget (xml, "new-profile-base-option-menu");
+    w = GTK_WIDGET (gtk_builder_get_object (builder, "new-profile-base-option-menu"));
     g_object_set_data (G_OBJECT (dialog->priv->new_profile_dialog), "base_option_menu", w);
     // FIXME terminal_util_set_atk_name_description (w, _("Choose base profile"), NULL);
     //FIXME profile_optionmenu_refill (w);
     gtk_size_group_add_widget (size_group, w);
 
-    wl = glade_xml_get_widget (xml, "new-profile-base-label");
+    wl = GTK_WIDGET (gtk_builder_get_object (builder, "new-profile-base-label"));
     gtk_label_set_mnemonic_widget (GTK_LABEL (wl), w);
     // FIXME terminal_util_set_labelled_by (w, GTK_LABEL (wl));
     gtk_size_group_add_widget (size_group_labels, wl);
 #endif
 
 
-    gtk_dialog_set_default_response (GTK_DIALOG (dialog->priv->new_profile_dialog), RESPONSE_CREATE);
+    /* gtk_dialog_set_default_response (GTK_DIALOG (dialog->priv->new_profile_dialog), GTK_RESPONSE_CREATE); */
 
     g_object_unref (G_OBJECT (size_group));
     g_object_unref (G_OBJECT (size_group_labels));
 
-    g_object_unref (G_OBJECT (xml));
+    g_object_unref (G_OBJECT (builder));
   }
 
   old_transient_parent = gtk_window_get_transient_for (GTK_WINDOW (dialog->priv->new_profile_dialog));
diff --git a/profiles/glade/Makefile.am b/profiles/glade/Makefile.am
index 96afd38..9e45b71 100644
--- a/profiles/glade/Makefile.am
+++ b/profiles/glade/Makefile.am
@@ -1,14 +1,22 @@
-glademoduledir = $(libdir)/libglade/2.0
+# this is provided for editing gnome-media UI files, not for any other
+# purposes
+
+glademoduledir = @GLADEUI_MODULE_DIR@
 glademodule_LTLIBRARIES = libgnome-media-profiles.la
 
 defines = \
 	-DG_LOG_DOMAIN=\"gnome-media-profiles\" \
 	-DGNOMELOCALEDIR=\""$(prefix)/${DATADIRNAME}/locale"\"
 
-libgnome_media_profiles_la_SOURCES = gnome-media-profiles-glade.c
-libgnome_media_profiles_la_CFLAGS = $(GMP_CFLAGS) $(defines) -I$(top_srcdir)
-libgnome_media_profiles_la_LIBADD = $(GMP_LIBS) $(top_builddir)/profiles/libgnome-media-profiles.la
+libgnome_media_profiles_la_SOURCES = gnome-media-profiles-catalog.c
+libgnome_media_profiles_la_CFLAGS = $(GMP_CFLAGS) $(GLADEUI_CFLAGS) $(defines) -I$(top_srcdir)
+libgnome_media_profiles_la_LIBADD = $(GMP_LIBS) $(GLADEUI_LIBS) $(top_builddir)/profiles/libgnome-media-profiles.la
 libgnome_media_profiles_la_LDFLAGS = -export-dynamic -module -avoid-version -no-undefined
 
+gladecatalogdir = @GLADEUI_CATALOG_DIR@
+gladecatalog_DATA = gnome-media-profiles.xml
+
+check-catalog:
+	xmllint --dtdvalid glade-catalog.dtd --noout $(gladecatalog_DATA)
 
 -include $(top_srcdir)/git.mk
diff --git a/profiles/glade/gnome-media-profiles-catalog.c b/profiles/glade/gnome-media-profiles-catalog.c
new file mode 100644
index 0000000..65e7671
--- /dev/null
+++ b/profiles/glade/gnome-media-profiles-catalog.c
@@ -0,0 +1,8 @@
+#include <profiles/audio-profile-edit.h>
+
+void gnome_media_profiles_catalog_init (void);
+
+void
+gnome_media_profiles_catalog_init (void) {
+  /* empty init function,to make sure the catalg is initialized */
+}
diff --git a/profiles/glade/gnome-media-profiles.xml b/profiles/glade/gnome-media-profiles.xml
new file mode 100644
index 0000000..c2bd46d
--- /dev/null
+++ b/profiles/glade/gnome-media-profiles.xml
@@ -0,0 +1,10 @@
+<glade-catalog supports="gtkbuilder" name="gnome-media-profiles" library="gnome-media-profiles" depends="gtk+">
+
+  <init-function>gnome_media_profiles_catalog_init</init-function>
+
+  <glade-widget-classes>
+    <glade-widget-class name="GMAudioProfileEdit" get-type-function="gm_audio_profile_edit_get_type"
+                        generic-name="audio-profile-edit" title="AudioProfileEdit"/>
+  </glade-widget-classes>
+
+</glade-catalog>
diff --git a/profiles/gmp-util.c b/profiles/gmp-util.c
index 60ae8d3..6d9d29f 100644
--- a/profiles/gmp-util.c
+++ b/profiles/gmp-util.c
@@ -25,52 +25,51 @@
 
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
-#include <glade/glade-xml.h>
 
 #include "gmp-util.h"
 
-GladeXML*
-gmp_util_load_glade_file (const char *filename,
-                          const char *widget_root,
-                          GtkWindow  *error_dialog_parent)
+GtkBuilder *
+gmp_util_load_builder_file (const char *filename,
+			    GtkWindow  *error_dialog_parent,
+			    GError **err)
 {
-  char *path;
-  GladeXML *xml;
+  static GtkWidget *no_glade_dialog = NULL;
+  gchar *path;
+  GtkBuilder *builder;
+  GError *error = NULL;
 
-  xml = NULL;
   path = g_strconcat ("./", filename, NULL);
 
-  if (g_file_test (path,
-                   G_FILE_TEST_EXISTS))
-    {
-      /* Try current dir, for debugging */
-      xml = glade_xml_new (path,
-                           widget_root,
-                           GETTEXT_PACKAGE);
-    }
+  builder = gtk_builder_new ();
 
-  if (xml == NULL)
-    {
-      g_free (path);
+  /* Try current dir, for debugging */
+  if (g_file_test (path, G_FILE_TEST_EXISTS) && gtk_builder_add_from_file (builder, path, &error))
+    goto end;
 
-      path = g_build_filename (GMP_GLADE_DIR, filename, NULL);
+  if (error != NULL) {
+    g_warning (error->message);
+    g_error_free (error);
+    error = NULL;
+  }
 
-      xml = glade_xml_new (path,
-                           widget_root,
-                           GETTEXT_PACKAGE);
-    }
+  g_free (path);
+  path = g_build_filename (GMP_UIDIR, filename, NULL);
+  if (g_file_test (path, G_FILE_TEST_EXISTS) && gtk_builder_add_from_file (builder, path, &error))
+    goto end;
 
-  if (xml == NULL)
-    {
-      static GtkWidget *no_glade_dialog = NULL;
+  gmp_util_show_error_dialog (error_dialog_parent, &no_glade_dialog,
+			      _("The file \"%s\" is missing. This indicates that the application is installed incorrectly, so the dialog can't be displayed."), path);
+  g_free (path);
+  if (error != NULL) {
+    g_propagate_error (err, error);
+  }
 
-      gmp_util_show_error_dialog (error_dialog_parent, &no_glade_dialog,
-                                       _("The file \"%s\" is missing. This indicates that the application is installed incorrectly, so the dialog can't be displayed."), path);
-    }
+  return builder;
 
+ end:
   g_free (path);
 
-  return xml;
+  return builder;
 }
 
 void
diff --git a/profiles/gmp-util.h b/profiles/gmp-util.h
index 10eed7b..012f1dd 100644
--- a/profiles/gmp-util.h
+++ b/profiles/gmp-util.h
@@ -24,12 +24,11 @@
 #endif
 
 #include <gtk/gtk.h>
-#include <glade/glade.h>
 
-GladeXML*
-gmp_util_load_glade_file (const char *filename,
-                          const char *widget_root,
-                          GtkWindow  *error_dialog_parent);
+GtkBuilder *
+gmp_util_load_builder_file (const char *filename,
+			    GtkWindow  *error_dialog_parent,
+			    GError **error);
 
 void
 gmp_util_show_error_dialog (GtkWindow *transient_parent,
diff --git a/profiles/gnome-audio-profile-edit.ui b/profiles/gnome-audio-profile-edit.ui
new file mode 100644
index 0000000..95f51ec
--- /dev/null
+++ b/profiles/gnome-audio-profile-edit.ui
@@ -0,0 +1,204 @@
+<?xml version="1.0"?>
+<interface>
+  <object class="GMAudioProfileEdit" id="profile-edit-dialog">
+    <property name="visible">True</property>
+    <property name="border_width">5</property>
+    <property name="title" translatable="yes">Edit Audio Profile</property>
+    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <property name="has_separator">False</property>
+    <child internal-child="vbox">
+      <object class="GtkVBox" id="profile-edit-content">
+        <property name="visible">True</property>
+        <property name="spacing">2</property>
+        <child>
+          <object class="GtkTable" id="table18">
+            <property name="visible">True</property>
+            <property name="border_width">5</property>
+            <property name="n_rows">5</property>
+            <property name="n_columns">2</property>
+            <property name="column_spacing">12</property>
+            <property name="row_spacing">6</property>
+            <child>
+              <object class="GtkEntry" id="profile-name-entry">
+                <property name="width_request">300</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <signal name="changed" handler="on_profile_name_entry_changed"/>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="y_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkScrolledWindow" id="scrolledwindow1">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
+                <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+                <property name="shadow_type">GTK_SHADOW_IN</property>
+                <child>
+                  <object class="GtkTextView" id="profile-description-textview">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="wrap_mode">GTK_WRAP_WORD</property>
+                    <property name="accepts_tab">False</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
+                <property name="x_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="profile-description-label">
+                <property name="visible">True</property>
+                <property name="xalign">0</property>
+                <property name="yalign">0</property>
+                <property name="label" translatable="yes">Profile _description:</property>
+                <property name="use_underline">True</property>
+                <property name="justify">GTK_JUSTIFY_CENTER</property>
+                <property name="width_chars">2</property>
+              </object>
+              <packing>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
+                <property name="x_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkCheckButton" id="profile-active-button">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="label" translatable="yes">_Active?</property>
+                <property name="use_underline">True</property>
+                <property name="draw_indicator">True</property>
+              </object>
+              <packing>
+                <property name="right_attach">2</property>
+                <property name="top_attach">4</property>
+                <property name="bottom_attach">5</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="profile-pipeline-entry">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <signal name="changed" handler="on_profile_pipeline_entry_changed" object="profile"/>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="profile-extension-entry">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <signal name="changed" handler="on_profile_pipeline_entry_changed" object="profile"/>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="top_attach">3</property>
+                <property name="bottom_attach">4</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="profile-extension-label">
+                <property name="visible">True</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">_File extension:</property>
+                <property name="use_underline">True</property>
+                <property name="justify">GTK_JUSTIFY_CENTER</property>
+                <property name="mnemonic_widget">profile-extension-entry</property>
+              </object>
+              <packing>
+                <property name="top_attach">3</property>
+                <property name="bottom_attach">4</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="profile-pipeline-label">
+                <property name="visible">True</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">_GStreamer pipeline:</property>
+                <property name="use_underline">True</property>
+                <property name="justify">GTK_JUSTIFY_CENTER</property>
+                <property name="mnemonic_widget">profile-pipeline-entry</property>
+              </object>
+              <packing>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="profile-name-label">
+                <property name="visible">True</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">_Profile name:</property>
+                <property name="use_underline">True</property>
+                <property name="justify">GTK_JUSTIFY_CENTER</property>
+                <property name="mnemonic_widget">profile-name-entry</property>
+              </object>
+              <packing>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <object class="GtkHButtonBox" id="dialog-action_area6">
+            <property name="visible">True</property>
+            <property name="layout_style">GTK_BUTTONBOX_EDGE</property>
+            <child>
+              <object class="GtkButton" id="button1">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="label">gtk-help</property>
+                <property name="use_stock">True</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkButton" id="profile-edit-close">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="label">gtk-close</property>
+                <property name="use_stock">True</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">GTK_PACK_END</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-5">profile-edit-close</action-widget>
+      <action-widget response="-11">button1</action-widget>
+    </action-widgets>
+  </object>
+</interface>
diff --git a/profiles/gnome-audio-profile-new.ui b/profiles/gnome-audio-profile-new.ui
new file mode 100644
index 0000000..39035a5
--- /dev/null
+++ b/profiles/gnome-audio-profile-new.ui
@@ -0,0 +1,195 @@
+<?xml version="1.0"?>
+<!--*- mode: xml -*-->
+<interface>
+  <object class="GtkDialog" id="new-profile-dialog">
+    <property name="border_width">5</property>
+    <property name="visible">True</property>
+    <property name="title" translatable="yes">New Profile</property>
+    <property name="type">GTK_WINDOW_TOPLEVEL</property>
+    <property name="window_position">GTK_WIN_POS_NONE</property>
+    <property name="modal">False</property>
+    <property name="resizable">False</property>
+    <property name="destroy_with_parent">False</property>
+    <property name="decorated">True</property>
+    <property name="skip_taskbar_hint">False</property>
+    <property name="skip_pager_hint">False</property>
+    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+    <property name="focus_on_map">True</property>
+    <property name="urgency_hint">False</property>
+    <property name="has_separator">False</property>
+    <child internal-child="vbox">
+      <object class="GtkVBox" id="dialog-vbox5">
+        <property name="visible">True</property>
+        <property name="homogeneous">False</property>
+        <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkHButtonBox" id="dialog-action_area5">
+            <property name="visible">True</property>
+            <property name="layout_style">GTK_BUTTONBOX_END</property>
+            <child>
+              <object class="GtkButton" id="new-profile-cancel-button">
+                <property name="visible">True</property>
+                <property name="can_default">True</property>
+                <property name="can_focus">True</property>
+                <property name="label">gtk-cancel</property>
+                <property name="use_stock">True</property>
+                <property name="relief">GTK_RELIEF_NORMAL</property>
+                <property name="focus_on_click">True</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkButton" id="new-profile-create-button">
+                <property name="visible">True</property>
+                <property name="sensitive">False</property>
+                <property name="can_default">True</property>
+                <property name="can_focus">True</property>
+                <property name="relief">GTK_RELIEF_NORMAL</property>
+                <property name="focus_on_click">True</property>
+                <child>
+                  <object class="GtkAlignment" id="alignment34">
+                    <property name="visible">True</property>
+                    <property name="xalign">0.5</property>
+                    <property name="yalign">0.5</property>
+                    <property name="xscale">0</property>
+                    <property name="yscale">0</property>
+                    <property name="top_padding">0</property>
+                    <property name="bottom_padding">0</property>
+                    <property name="left_padding">0</property>
+                    <property name="right_padding">0</property>
+                    <child>
+                      <object class="GtkHBox" id="hbox10">
+                        <property name="visible">True</property>
+                        <property name="homogeneous">False</property>
+                        <property name="spacing">2</property>
+                        <child>
+                          <object class="GtkImage" id="icon-1212">
+                            <property name="visible">True</property>
+                            <property name="stock">gtk-apply</property>
+                            <property name="icon_size">4</property>
+                            <property name="xalign">0.5</property>
+                            <property name="yalign">0.5</property>
+                            <property name="xpad">0</property>
+                            <property name="ypad">0</property>
+                          </object>
+                          <packing>
+                            <property name="padding">0</property>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkLabel" id="create-button">
+                            <property name="visible">True</property>
+                            <property name="label" translatable="yes">_Create</property>
+                            <property name="use_underline">True</property>
+                            <property name="use_markup">False</property>
+                            <property name="justify">GTK_JUSTIFY_LEFT</property>
+                            <property name="wrap">False</property>
+                            <property name="selectable">False</property>
+                            <property name="xalign">0.5</property>
+                            <property name="yalign">0.5</property>
+                            <property name="xpad">0</property>
+                            <property name="ypad">0</property>
+                            <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+                            <property name="width_chars">-1</property>
+                            <property name="single_line_mode">False</property>
+                            <property name="angle">0</property>
+                          </object>
+                          <packing>
+                            <property name="padding">0</property>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                          </packing>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="padding">0</property>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">GTK_PACK_END</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkVBox" id="vbox7">
+            <property name="border_width">5</property>
+            <property name="visible">True</property>
+            <property name="homogeneous">False</property>
+            <property name="spacing">6</property>
+            <child>
+              <object class="GtkHBox" id="hbox8">
+                <property name="visible">True</property>
+                <property name="homogeneous">False</property>
+                <property name="spacing">12</property>
+                <child>
+                  <object class="GtkLabel" id="new-profile-name-label">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">_Profile name:</property>
+                    <property name="use_underline">True</property>
+                    <property name="use_markup">False</property>
+                    <property name="justify">GTK_JUSTIFY_LEFT</property>
+                    <property name="wrap">False</property>
+                    <property name="selectable">False</property>
+                    <property name="xalign">0</property>
+                    <property name="yalign">0.5</property>
+                    <property name="xpad">0</property>
+                    <property name="ypad">0</property>
+                    <property name="mnemonic_widget">new-profile-name-entry</property>
+                    <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+                    <property name="width_chars">-1</property>
+                    <property name="single_line_mode">False</property>
+                    <property name="angle">0</property>
+                  </object>
+                  <packing>
+                    <property name="padding">0</property>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkEntry" id="new-profile-name-entry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="editable">True</property>
+                    <property name="visibility">True</property>
+                    <property name="max_length">0</property>
+                    <property name="text" translatable="yes"/>
+                    <property name="has_frame">True</property>
+                    <property name="invisible_char">*</property>
+                    <property name="activates_default">False</property>
+                    <property name="width_chars">14</property>
+                  </object>
+                  <packing>
+                    <property name="padding">0</property>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="padding">0</property>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="padding">0</property>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-6">new-profile-cancel-button</action-widget>
+      <action-widget response="-3">new-profile-create-button</action-widget>
+    </action-widgets>
+  </object>
+</interface>
diff --git a/profiles/gnome-audio-profiles-properties.c b/profiles/gnome-audio-profiles-properties.c
index c8f2f69..586c7e8 100644
--- a/profiles/gnome-audio-profiles-properties.c
+++ b/profiles/gnome-audio-profiles-properties.c
@@ -59,12 +59,9 @@ main (int argc, char *argv[])
   }
   g_option_context_free (context);
 
-  glade_register_widget (gm_audio_profile_edit_get_type (),
-			 NULL,
-			 gtk_dialog_build_children,
-			 dialog_find_internal_child);
   conf = gconf_client_get_default ();
   textdomain (GETTEXT_PACKAGE);
+
   gnome_media_profiles_init (conf);
 
   gtk_window_set_default_icon_name ("gnome-mime-audio");
diff --git a/profiles/gnome-audio-profiles-test.c b/profiles/gnome-audio-profiles-test.c
index 00db5fc..a53f32f 100644
--- a/profiles/gnome-audio-profiles-test.c
+++ b/profiles/gnome-audio-profiles-test.c
@@ -1,4 +1,4 @@
-/* gnome-audio-profiles-test.c: */ 
+/* gnome-audio-profiles-test.c: */
 
 /*
  * Copyright (C) 2003 Thomas Vander Stichele
@@ -89,12 +89,12 @@ test_clicked_cb (GtkButton *button, GtkWidget *combo)
     if ((msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0))) {
       gst_message_parse_error (msg, &error, NULL);
     }
-	                  
+
     g_warning ("Error starting pipeline: %s",
         (error) ? error->message : "UNKNOWN ERROR");
 
     goto done;
-  }  
+  }
 
   g_print ("Writing test sound to test.%s ...\n", extension);
 
diff --git a/profiles/gnome-media-profiles.c b/profiles/gnome-media-profiles.c
index 6a7bc63..b1b682e 100644
--- a/profiles/gnome-media-profiles.c
+++ b/profiles/gnome-media-profiles.c
@@ -25,8 +25,6 @@
 
 #include "gnome-media-profiles.h"
 
-#include <glade/glade.h>
-#include <glade/glade-build.h>
 #include <string.h>
 #include <glib/gi18n.h>
 #include <gconf/gconf-client.h>
@@ -36,51 +34,6 @@
 #include "gmp-conf.h"
 #include "gmp-util.h"
 
-void
-gtk_dialog_build_children (GladeXML *self, GtkWidget *w,
-			  GladeWidgetInfo *info)
-
-{
-  GtkDialog *dialog = GTK_DIALOG (w);
-  GList *children, *list;
-
-  glade_standard_build_children (self, w, info);
-
-  if (dialog->action_area == NULL)
-    return;
-
-  /* repack children of action_area */
-  children = gtk_container_get_children (GTK_CONTAINER (dialog->action_area));
-  for (list = children; list; list = list->next) {
-    GtkWidget *child = GTK_WIDGET (list->data);
-
-    g_object_ref (child);
-    gtk_container_remove (GTK_CONTAINER (dialog->action_area), child);
-  }
-  for (list = children; list; list = list->next) {
-    GtkWidget *child = GTK_WIDGET (list->data);
-    gint response_id;
-
-    response_id = GPOINTER_TO_INT (g_object_steal_data (G_OBJECT(child),
-						      "response_id"));
-   gtk_dialog_add_action_widget (dialog, child, response_id);
-   g_object_unref (child);
-  }
-  g_list_free (children);
-}
-
-GtkWidget *
-dialog_find_internal_child (GladeXML *xml, GtkWidget *parent,
-				   const gchar *childname)
-{
-  if (!strcmp (childname, "vbox"))
-    return GTK_DIALOG(parent)->vbox;
-  if (!strcmp (childname, "action_area"))
-    return GTK_DIALOG (parent)->action_area;
-  
-  return NULL;
-}
-
 /* do all necessary initialization to use this simple helper library */
 void
 gnome_media_profiles_init (GConfClient *conf)
@@ -93,7 +46,7 @@ gnome_media_profiles_init (GConfClient *conf)
   bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 #endif
 
-  if (conf == NULL) 
+  if (conf == NULL)
     conf = gconf_client_get_default ();
   else
     g_object_ref (G_OBJECT (conf));
@@ -109,16 +62,10 @@ gnome_media_profiles_init (GConfClient *conf)
     g_error_free (err);
   }
 
+ /* Register GMAudioProfieEdit widget for GtkBuilder */
+  (void)GM_AUDIO_PROFILE_EDIT(NULL);
   /* initialize the audio profiles part */
   gm_audio_profile_initialize (conf);
 
-  /* register widgets */
-  /* FIXME: add a comment why we need this at all, until then
-     we comment it out
-     gm_audio_profile_edit_get_type (); */
-  glade_register_widget (gm_audio_profile_edit_get_type (),
-			 NULL,
-			 gtk_dialog_build_children,
-			 dialog_find_internal_child);
   g_object_unref (G_OBJECT (conf));
 }
diff --git a/profiles/gnome-media-profiles.pc.in b/profiles/gnome-media-profiles.pc.in
index 5c2e140..24b2b41 100644
--- a/profiles/gnome-media-profiles.pc.in
+++ b/profiles/gnome-media-profiles.pc.in
@@ -3,10 +3,10 @@ exec_prefix= exec_prefix@
 libdir= libdir@
 includedir= includedir@/gnome-media
 toolsdir=${exec_prefix}/bin
-                                                                                
+
 Name: GNOME Media Profiles
 Description: Media Profiles describing audio codec settings for output
-Requires: gconf-2.0, gtk+-2.0, libglade-2.0
+Requires: gconf-2.0, gtk+-2.0
 Version: @VERSION@
 Libs: -L${libdir} -lgnome-media-profiles
 Cflags: -I${includedir}



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