Commit eca3756d authored by Jonh Wendell's avatar Jonh Wendell
Browse files

Refactored last Leandro's GtkBuilder patch.

parent 588d039a
......@@ -68,7 +68,7 @@ vinagre/vinagre
vinagre/vinagre-applet
vinagre/vinagre-enums.*
vinagre/vinagre-ui.xml
vinagre/vinagre.glade
vinagre/vinagre.ui
vinagre/dbus-interface-glue.h
stamp-h1
xmldocs.make
......
......@@ -415,7 +415,6 @@ ask_credential (VinagreVncTab *vnc_tab,
gchar **password)
{
GtkBuilder *xml;
const char *ui_file;
GtkWidget *password_dialog, *host_label, *save_credential_check;
GtkWidget *password_label, *username_label, *image;
gchar *name, *label;
......@@ -424,15 +423,7 @@ ask_credential (VinagreVncTab *vnc_tab,
VinagreTab *tab = VINAGRE_TAB (vnc_tab);
VinagreConnection *conn = vinagre_tab_get_conn (tab);
ui_file = vinagre_utils_get_ui_filename ();
GError* error = NULL;
xml = gtk_builder_new ();
if (!gtk_builder_add_from_file (xml, ui_file, &error))
{
g_warning (_("Couldn't load builder file: &s"), error->message);
g_error_free (error);
}
xml = vinagre_utils_get_builder ();
password_dialog = GTK_WIDGET (gtk_builder_get_object (xml, "auth_required_dialog"));
gtk_window_set_transient_for (GTK_WINDOW(password_dialog),
......
......@@ -44,14 +44,7 @@ show_dialog_folder (VinagreBookmarks *book,
GtkWidget *dialog, *box, *tree, *name_entry, *save_button;
const gchar *name;
GError* error = NULL;
xml = gtk_builder_new ();
if (!gtk_builder_add_from_file (xml, vinagre_utils_get_ui_filename (), &error))
{
g_warning (_("Couldn't load builder file: &s"), error->message);
g_error_free (error);
}
xml = vinagre_utils_get_builder ();
dialog = GTK_WIDGET (gtk_builder_get_object (xml, "bookmarks_add_edit_folder_dialog"));
name_entry = GTK_WIDGET (gtk_builder_get_object (xml, "edit_bookmark_folder_name_entry"));
box = GTK_WIDGET (gtk_builder_get_object (xml, "folder_box1"));
......@@ -136,14 +129,7 @@ show_dialog_conn (VinagreBookmarks *book,
VinagrePlugin *plugin;
gchar **props;
GError* error = NULL;
xml = gtk_builder_new ();
if (!gtk_builder_add_from_file (xml, vinagre_utils_get_ui_filename (), &error))
{
g_warning (_("Couldn't load builder file: &s"), error->message);
g_error_free (error);
}
xml = vinagre_utils_get_builder ();
dialog = GTK_WIDGET (gtk_builder_get_object (xml, "bookmarks_add_edit_conn_dialog"));
name_entry = GTK_WIDGET (gtk_builder_get_object (xml, "edit_bookmark_name_entry"));
host_entry = GTK_WIDGET (gtk_builder_get_object (xml, "edit_bookmark_host_entry"));
......
......@@ -365,13 +365,7 @@ VinagreConnection *vinagre_connect (VinagreWindow *window)
gint result;
VinagreConnectDialog dialog;
GError* error = NULL;
dialog.xml = gtk_builder_new ();
if (!gtk_builder_add_from_file (dialog.xml, vinagre_utils_get_ui_filename (), &error))
{
g_warning (_("Couldn't load builder file: &s"), error->message);
g_error_free (error);
}
dialog.xml = vinagre_utils_get_builder ();
dialog.dialog = GTK_WIDGET (gtk_builder_get_object (dialog.xml, "connect_dialog"));
gtk_window_set_transient_for (GTK_WINDOW (dialog.dialog), GTK_WINDOW (window));
......
......@@ -529,14 +529,7 @@ vinagre_prefs_dialog_show (VinagreWindow *window)
dialog = g_new (VinagrePrefsDialog, 1);
GError* error = NULL;
dialog->xml = gtk_builder_new ();
if (!gtk_builder_add_from_file (dialog->xml, vinagre_utils_get_ui_filename (), &error))
{
g_warning (_("Couldn't load builder file: &s"), error->message);
g_error_free (error);
}
dialog->xml = vinagre_utils_get_builder ();
dialog->dialog = GTK_WIDGET (gtk_builder_get_object (dialog->xml, "preferences_dialog"));
gtk_window_set_transient_for (GTK_WINDOW (dialog->dialog), GTK_WINDOW (window));
......
......@@ -136,6 +136,26 @@ vinagre_utils_get_ui_xml_filename (void)
return VINAGRE_DATADIR "/" VINAGRE_UI_XML_FILE;
}
GtkBuilder *
vinagre_utils_get_builder (void)
{
GtkBuilder *xml;
GError *error = NULL;
xml = gtk_builder_new ();
if (!gtk_builder_add_from_file (xml,
vinagre_utils_get_ui_filename (),
&error))
{
g_error (_("Could not load builder file: %s"), error->message);
g_error_free (error);
g_object_unref (xml);
return NULL;
}
return xml;
}
/*
* Doubles underscore to avoid spurious menu accels.
*/
......
......@@ -45,6 +45,7 @@ void vinagre_utils_toggle_widget_visible (GtkWidget *widget);
const gchar *vinagre_utils_get_ui_filename (void);
const gchar *vinagre_utils_get_ui_xml_filename (void);
GtkBuilder *vinagre_utils_get_builder (void);
gchar *vinagre_utils_escape_underscores (const gchar *text,
gssize length);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment