Bug 578393 – convert from libglade to GtkBuilder

This commit is contained in:
Felix Riemann 2009-07-20 10:23:32 +02:00
parent f22e523404
commit 3f33966167
16 changed files with 2020 additions and 137 deletions

View File

@ -18,7 +18,7 @@ AC_PROG_CC
GTK_REQUIRED=2.15.1
PKG_CHECK_MODULES([ZENITY],[gtk+-2.0 >= $GTK_REQUIRED libglade-2.0 glib-2.0])
PKG_CHECK_MODULES([ZENITY],[gtk+-2.0 >= $GTK_REQUIRED glib-2.0])
AC_SUBST([ZENITY_CFLAGS])
AC_SUBST([ZENITY_LIBS])

View File

@ -4,5 +4,5 @@ src/notification.c
src/scale.c
src/tree.c
src/util.c
src/zenity.glade
[type: gettext/glade]src/zenity.ui
src/option.c

View File

@ -6,4 +6,5 @@ src/progress.c
src/text.c
src/util.h
src/util.c
src/zenity.glade
src/zenity.h

View File

@ -40,15 +40,15 @@ zenity_LDADD = \
$(LIBNOTIFY_LIBS) \
$(X_LIBS)
gladedir = $(datadir)/zenity
uidir = $(datadir)/zenity
glade_DATA = \
zenity.glade
ui_DATA = \
zenity.ui
DISTCLEANFILES= \
gdialog
EXTRA_DIST = \
$(glade_DATA) \
$(ui_DATA) \
gdialog \
gdialog.in

View File

@ -23,7 +23,6 @@
#include "config.h"
#include <glade/glade.h>
#include <time.h>
#include "zenity.h"
#include "util.h"
@ -38,22 +37,23 @@ static void zenity_calendar_double_click (GtkCalendar *calendar, gpointer data);
void
zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data)
{
GladeXML *glade_dialog = NULL;
GtkBuilder *builder;
GtkWidget *dialog;
GtkWidget *text;
GObject *text;
zen_cal_data = cal_data;
glade_dialog = zenity_util_load_glade_file ("zenity_calendar_dialog");
builder = zenity_util_load_ui_file ("zenity_calendar_dialog", NULL);
if (glade_dialog == NULL) {
if (builder == NULL) {
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
return;
}
glade_xml_signal_autoconnect (glade_dialog);
gtk_builder_connect_signals (builder, NULL);
dialog = glade_xml_get_widget (glade_dialog, "zenity_calendar_dialog");
dialog = GTK_WIDGET (gtk_builder_get_object (builder,
"zenity_calendar_dialog"));
g_signal_connect (G_OBJECT (dialog), "response",
G_CALLBACK (zenity_calendar_dialog_response), data);
@ -66,15 +66,12 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data)
if (data->width > -1 || data->height > -1)
gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
text = glade_xml_get_widget (glade_dialog, "zenity_calendar_text");
text = gtk_builder_get_object (builder, "zenity_calendar_text");
if (cal_data->dialog_text)
gtk_label_set_markup (GTK_LABEL (text), g_strcompress (cal_data->dialog_text));
calendar = glade_xml_get_widget (glade_dialog, "zenity_calendar");
if (glade_dialog)
g_object_unref (glade_dialog);
calendar = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar"));
if (cal_data->month > 0 || cal_data->year > 0)
gtk_calendar_select_month (GTK_CALENDAR (calendar), cal_data->month - 1, cal_data->year);
@ -91,6 +88,8 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data)
g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL);
}
g_object_unref (builder);
gtk_main ();
}

View File

@ -23,7 +23,6 @@
#include "config.h"
#include <glade/glade.h>
#include "zenity.h"
#include "util.h"
@ -46,23 +45,23 @@ zenity_entry_fill_entries (GSList **entries, const gchar **args)
void
zenity_entry (ZenityData *data, ZenityEntryData *entry_data)
{
GladeXML *glade_dialog = NULL;
GtkBuilder *builder = NULL;
GtkWidget *dialog;
GtkWidget *text;
GObject *text;
GSList *entries = NULL;
GSList *tmp;
GtkWidget *vbox;
GObject *vbox;
glade_dialog = zenity_util_load_glade_file ("zenity_entry_dialog");
builder = zenity_util_load_ui_file ("zenity_entry_dialog", NULL);
if (glade_dialog == NULL) {
if (builder == NULL) {
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
return;
}
glade_xml_signal_autoconnect (glade_dialog);
gtk_builder_connect_signals (builder, NULL);
dialog = glade_xml_get_widget (glade_dialog, "zenity_entry_dialog");
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_dialog"));
g_signal_connect (G_OBJECT (dialog), "response",
G_CALLBACK (zenity_entry_dialog_response), data);
@ -75,12 +74,12 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data)
if (data->width > -1 || data->height > -1)
gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
text = glade_xml_get_widget (glade_dialog, "zenity_entry_text");
text = gtk_builder_get_object (builder, "zenity_entry_text");
if (entry_data->dialog_text)
gtk_label_set_text_with_mnemonic (GTK_LABEL (text), entry_data->dialog_text);
vbox = glade_xml_get_widget (glade_dialog, "vbox4");
vbox = gtk_builder_get_object (builder, "vbox4");
zenity_entry_fill_entries(&entries, entry_data->data);
@ -113,11 +112,10 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data)
gtk_box_pack_end (GTK_BOX (vbox), entry, FALSE, FALSE, 0);
if (glade_dialog)
g_object_unref (glade_dialog);
gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry);
g_object_unref (builder);
zenity_util_show_dialog (dialog);
if(data->timeout_delay > 0) {

View File

@ -23,7 +23,6 @@
#include "config.h"
#include <glade/glade.h>
#include <string.h>
#include "zenity.h"
#include "util.h"

View File

@ -23,7 +23,6 @@
#include "config.h"
#include <glade/glade.h>
#include "zenity.h"
#include "util.h"
@ -55,55 +54,52 @@ zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data
void
zenity_msg (ZenityData *data, ZenityMsgData *msg_data)
{
GladeXML *glade_dialog;
GtkBuilder *builder;
GtkWidget *dialog;
GtkWidget *text;
GObject *text;
switch (msg_data->mode) {
case ZENITY_MSG_WARNING:
glade_dialog = zenity_util_load_glade_file ("zenity_warning_dialog");
dialog = glade_xml_get_widget (glade_dialog, "zenity_warning_dialog");
text = glade_xml_get_widget (glade_dialog, "zenity_warning_text");
builder = zenity_util_load_ui_file ("zenity_warning_dialog", NULL);
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_warning_dialog"));
text = gtk_builder_get_object (builder, "zenity_warning_text");
break;
case ZENITY_MSG_QUESTION:
glade_dialog = zenity_util_load_glade_file ("zenity_question_dialog");
dialog = glade_xml_get_widget (glade_dialog, "zenity_question_dialog");
text = glade_xml_get_widget (glade_dialog, "zenity_question_text");
builder = zenity_util_load_ui_file ("zenity_question_dialog", NULL);
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_question_dialog"));
text = gtk_builder_get_object (builder, "zenity_question_text");
break;
case ZENITY_MSG_ERROR:
glade_dialog = zenity_util_load_glade_file ("zenity_error_dialog");
dialog = glade_xml_get_widget (glade_dialog, "zenity_error_dialog");
text = glade_xml_get_widget (glade_dialog, "zenity_error_text");
builder = zenity_util_load_ui_file ("zenity_error_dialog", NULL);
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_error_dialog"));
text = gtk_builder_get_object (builder, "zenity_error_text");
break;
case ZENITY_MSG_INFO:
glade_dialog = zenity_util_load_glade_file ("zenity_info_dialog");
dialog= glade_xml_get_widget (glade_dialog, "zenity_info_dialog");
text = glade_xml_get_widget (glade_dialog, "zenity_info_text");
builder = zenity_util_load_ui_file ("zenity_info_dialog", NULL);
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_info_dialog"));
text = gtk_builder_get_object (builder, "zenity_info_text");
break;
default:
glade_dialog = NULL;
builder = NULL;
dialog = NULL;
text = NULL;
g_assert_not_reached ();
break;
}
g_signal_connect (G_OBJECT (dialog), "response",
G_CALLBACK (zenity_msg_dialog_response), data);
if (glade_dialog == NULL) {
if (builder == NULL) {
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
return;
}
glade_xml_signal_autoconnect (glade_dialog);
g_signal_connect (G_OBJECT (dialog), "response",
G_CALLBACK (zenity_msg_dialog_response), data);
if (glade_dialog)
g_object_unref (glade_dialog);
gtk_builder_connect_signals (builder, NULL);
if (data->dialog_title)
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
@ -145,6 +141,8 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data)
g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL);
}
g_object_unref (builder);
gtk_main ();
}

View File

@ -25,7 +25,6 @@
#include <config.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
#include <time.h>
#include <string.h>

View File

@ -29,11 +29,10 @@
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
#include <glade/glade.h>
#include "zenity.h"
#include "util.h"
static GladeXML *glade_dialog;
static GtkBuilder *builder;
static ZenityData *zen_data;
static GIOChannel *channel;
@ -57,14 +56,14 @@ zenity_progress_handle_stdin (GIOChannel *channel,
gpointer data)
{
static ZenityProgressData *progress_data;
static GtkWidget *progress_bar;
static GtkWidget *progress_label;
static GObject *progress_bar;
static GObject *progress_label;
static gint pulsate_timeout = -1;
float percentage = 0.0;
progress_data = (ZenityProgressData *) data;
progress_bar = glade_xml_get_widget (glade_dialog, "zenity_progress_bar");
progress_label = glade_xml_get_widget (glade_dialog, "zenity_progress_text");
progress_bar = gtk_builder_get_object (builder, "zenity_progress_bar");
progress_label = gtk_builder_get_object (builder, "zenity_progress_text");
if ((condition == G_IO_IN) || (condition == G_IO_IN + G_IO_HUP)) {
GString *string;
@ -114,8 +113,8 @@ zenity_progress_handle_stdin (GIOChannel *channel,
/* Now try to convert the thing to a number */
percentage = atoi (string->str);
if (percentage >= 100) {
GtkWidget *button;
button = glade_xml_get_widget( glade_dialog,"zenity_progress_ok_button");
GObject *button;
button = gtk_builder_get_object(builder, "zenity_progress_ok_button");
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 1.0);
gtk_widget_set_sensitive(GTK_WIDGET (button), TRUE);
gtk_widget_grab_focus(GTK_WIDGET (button));
@ -136,11 +135,13 @@ zenity_progress_handle_stdin (GIOChannel *channel,
/* We assume that we are done, so stop the pulsating and de-sensitize the buttons */
GtkWidget *button;
button = glade_xml_get_widget (glade_dialog, "zenity_progress_ok_button");
button = GTK_WIDGET (gtk_builder_get_object (builder,
"zenity_progress_ok_button"));
gtk_widget_set_sensitive (button, TRUE);
gtk_widget_grab_focus (button);
button = glade_xml_get_widget (glade_dialog, "zenity_progress_cancel_button");
button = GTK_WIDGET (gtk_builder_get_object (builder,
"zenity_progress_cancel_button"));
gtk_widget_set_sensitive (button, FALSE);
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 1.0);
@ -150,8 +151,7 @@ zenity_progress_handle_stdin (GIOChannel *channel,
pulsate_timeout = -1;
}
if (glade_dialog)
g_object_unref (glade_dialog);
g_object_unref (builder);
if (progress_data->autoclose) {
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK);
@ -177,20 +177,21 @@ void
zenity_progress (ZenityData *data, ZenityProgressData *progress_data)
{
GtkWidget *dialog;
GtkWidget *text;
GtkWidget *progress_bar;
GObject *text;
GObject *progress_bar;
zen_data = data;
glade_dialog = zenity_util_load_glade_file ("zenity_progress_dialog");
builder = zenity_util_load_ui_file ("zenity_progress_dialog", NULL);
if (glade_dialog == NULL) {
if (builder == NULL) {
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
return;
}
glade_xml_signal_autoconnect (glade_dialog);
gtk_builder_connect_signals (builder, NULL);
dialog = glade_xml_get_widget (glade_dialog, "zenity_progress_dialog");
dialog = GTK_WIDGET (gtk_builder_get_object (builder,
"zenity_progress_dialog"));
g_signal_connect (G_OBJECT (dialog), "response",
G_CALLBACK (zenity_progress_dialog_response), data);
@ -203,12 +204,12 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data)
if (data->width > -1 || data->height > -1)
gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
text = glade_xml_get_widget (glade_dialog, "zenity_progress_text");
text = gtk_builder_get_object (builder, "zenity_progress_text");
if (progress_data->dialog_text)
gtk_label_set_markup (GTK_LABEL (text), g_strcompress (progress_data->dialog_text));
progress_bar = glade_xml_get_widget (glade_dialog, "zenity_progress_bar");
progress_bar = gtk_builder_get_object (builder, "zenity_progress_bar");
if (progress_data->percentage > -1)
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar),

View File

@ -23,7 +23,6 @@
#include "config.h"
#include <glade/glade.h>
#include "zenity.h"
#include "util.h"
@ -35,23 +34,24 @@ static void zenity_scale_dialog_response (GtkWidget *widget, int response, gpoin
void
zenity_scale (ZenityData *data, ZenityScaleData *scale_data)
{
GladeXML *glade_dialog;
GtkBuilder *builder;
GtkWidget *dialog;
GtkWidget *text;
GObject *text;
glade_dialog = zenity_util_load_glade_file ("zenity_scale_dialog");
dialog = glade_xml_get_widget (glade_dialog, "zenity_scale_dialog");
scale = glade_xml_get_widget (glade_dialog, "zenity_scale_hscale");
text = glade_xml_get_widget (glade_dialog, "zenity_scale_text");
builder = zenity_util_load_ui_file ("zenity_scale_dialog", "adjustment1", NULL);
g_signal_connect (G_OBJECT (dialog), "response",
G_CALLBACK (zenity_scale_dialog_response), data);
if (glade_dialog == NULL) {
if (builder == NULL) {
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
return;
}
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_dialog"));
scale = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_hscale"));
text = gtk_builder_get_object (builder, "zenity_scale_text");
g_signal_connect (G_OBJECT (dialog), "response",
G_CALLBACK (zenity_scale_dialog_response), data);
if (scale_data->min_value >= scale_data->max_value) {
g_printerr (_("Maximum value must be greater than minimum value.\n"));
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
@ -65,10 +65,7 @@ zenity_scale (ZenityData *data, ZenityScaleData *scale_data)
return;
}
glade_xml_signal_autoconnect (glade_dialog);
if (glade_dialog)
g_object_unref (glade_dialog);
gtk_builder_connect_signals (builder, NULL);
if (data->dialog_title)
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
@ -98,6 +95,8 @@ zenity_scale (ZenityData *data, ZenityScaleData *scale_data)
g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL);
}
g_object_unref (builder);
gtk_main ();
}

View File

@ -23,7 +23,6 @@
#include "config.h"
#include <glade/glade.h>
#include "zenity.h"
#include "util.h"
@ -102,22 +101,23 @@ zenity_text_fill_entries_from_stdin (GtkTextBuffer *text_buffer)
void
zenity_text (ZenityData *data, ZenityTextData *text_data)
{
GladeXML *glade_dialog = NULL;
GtkBuilder *builder;
GtkWidget *dialog;
GtkWidget *text_view;
GObject *text_view;
GtkTextBuffer *text_buffer;
zen_text_data = text_data;
glade_dialog = zenity_util_load_glade_file ("zenity_text_dialog");
builder = zenity_util_load_ui_file ("zenity_text_dialog",
"textbuffer1", NULL);
if (glade_dialog == NULL) {
if (builder == NULL) {
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
return;
}
glade_xml_signal_autoconnect (glade_dialog);
gtk_builder_connect_signals (builder, NULL);
dialog = glade_xml_get_widget (glade_dialog, "zenity_text_dialog");
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_text_dialog"));
g_signal_connect (G_OBJECT (dialog), "response",
G_CALLBACK (zenity_text_dialog_response), data);
@ -130,7 +130,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data)
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
text_buffer = gtk_text_buffer_new (NULL);
text_view = glade_xml_get_widget (glade_dialog, "zenity_text_view");
text_view = gtk_builder_get_object (builder, "zenity_text_view");
gtk_text_view_set_buffer (GTK_TEXT_VIEW (text_view), text_buffer);
gtk_text_view_set_editable (GTK_TEXT_VIEW(text_view), text_data->editable);
@ -149,8 +149,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data)
zenity_util_show_dialog (dialog);
if (glade_dialog)
g_object_unref (glade_dialog);
g_object_unref (builder);
if(data->timeout_delay > 0) {
g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL);

View File

@ -25,7 +25,6 @@
#include "config.h"
#include <glade/glade.h>
#include <string.h>
#include <stdlib.h>
#include "zenity.h"
@ -34,7 +33,7 @@
#define MAX_ELEMENTS_BEFORE_SCROLLING 5
#define PRINT_HIDE_COLUMN_SEPARATOR ","
static GladeXML *glade_dialog;
static GtkBuilder *builder;
static GSList *selected;
static gchar *separator;
static gboolean print_all_columns = FALSE;
@ -168,7 +167,8 @@ zenity_tree_handle_stdin (GIOChannel *channel,
GtkRequisition rectangle;
gtk_widget_size_request (GTK_WIDGET (tree_view), &rectangle);
scrolled_window = glade_xml_get_widget (glade_dialog, "zenity_tree_window");
scrolled_window = GTK_WIDGET (gtk_builder_get_object (builder,
"zenity_tree_window"));
gtk_widget_set_size_request (scrolled_window, -1, rectangle.height);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
@ -245,7 +245,8 @@ zenity_tree_fill_entries (GtkTreeView *tree_view,
GtkRequisition rectangle;
gtk_widget_size_request (GTK_WIDGET (tree_view), &rectangle);
scrolled_window = glade_xml_get_widget (glade_dialog, "zenity_tree_window");
scrolled_window = GTK_WIDGET (gtk_builder_get_object (builder,
"zenity_tree_window"));
gtk_widget_set_size_request (scrolled_window, -1, rectangle.height);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
@ -281,8 +282,8 @@ void
zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
{
GtkWidget *dialog;
GtkWidget *tree_view;
GtkWidget *text;
GObject *tree_view;
GObject *text;
GtkTreeViewColumn *column;
GtkListStore *model;
GType *column_types;
@ -290,9 +291,9 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
gboolean first_column = FALSE;
gint i, column_index, n_columns;
glade_dialog = zenity_util_load_glade_file ("zenity_tree_dialog");
builder = zenity_util_load_ui_file ("zenity_tree_dialog", NULL);
if (glade_dialog == NULL) {
if (builder == NULL) {
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
return;
}
@ -328,9 +329,9 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
return;
}
glade_xml_signal_autoconnect (glade_dialog);
gtk_builder_connect_signals (builder, NULL);
dialog = glade_xml_get_widget (glade_dialog, "zenity_tree_dialog");
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_tree_dialog"));
g_signal_connect (G_OBJECT (dialog), "response",
G_CALLBACK (zenity_tree_dialog_response), data);
@ -338,7 +339,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
if (data->dialog_title)
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
text = glade_xml_get_widget (glade_dialog, "zenity_tree_text");
text = gtk_builder_get_object (builder, "zenity_tree_text");
if (tree_data->dialog_text)
gtk_label_set_markup (GTK_LABEL (text), g_strcompress (tree_data->dialog_text));
@ -348,10 +349,10 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
if (data->width > -1 || data->height > -1)
gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view");
tree_view = gtk_builder_get_object (builder, "zenity_tree_view");
if (!(tree_data->radiobox || tree_data->checkbox))
g_signal_connect (G_OBJECT (tree_view), "row-activated",
g_signal_connect (tree_view, "row-activated",
G_CALLBACK (zenity_tree_row_activated), data);
/* Create an empty list store */
@ -500,8 +501,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
gtk_main ();
if (glade_dialog)
g_object_unref (glade_dialog);
g_object_unref (builder);
}
static void
@ -591,13 +591,13 @@ static void
zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data)
{
ZenityData *zen_data = data;
GtkWidget *tree_view;
GObject *tree_view;
GtkTreeSelection *selection;
GtkTreeModel *model;
switch (response) {
case GTK_RESPONSE_OK:
tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view");
tree_view = gtk_builder_get_object (builder, "zenity_tree_view");
model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
if (gtk_tree_model_get_column_type (model, 0) == G_TYPE_BOOLEAN)

View File

@ -34,6 +34,7 @@
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include "config.h"
#include "util.h"
#include "zenity.h"
@ -48,27 +49,62 @@
#define ZENITY_ERROR_DEFAULT -1
#define ZENITY_EXTRA_DEFAULT 127
GladeXML*
zenity_util_load_glade_file (const gchar *widget_root)
GtkBuilder*
zenity_util_load_ui_file (const gchar *root_widget, ...)
{
GladeXML *xml = NULL;
va_list args;
gchar *arg = NULL;
GPtrArray *ptrarray;
GtkBuilder *builder = gtk_builder_new ();
GError *error = NULL;
gchar **objects;
guint result = 0;
if (g_file_test (ZENITY_GLADE_FILE_RELATIVEPATH, G_FILE_TEST_EXISTS)) {
gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
/* We have at least the root_widget and a NULL */
ptrarray = g_ptr_array_sized_new (2);
g_ptr_array_add (ptrarray, g_strdup (root_widget));
va_start (args, root_widget);
arg = va_arg (args, gchar*);
while (arg) {
g_ptr_array_add (ptrarray, g_strdup (arg));
arg = va_arg (args, gchar*);
}
va_end (args);
/* Enforce terminating NULL */
g_ptr_array_add (ptrarray, NULL);
objects = (gchar**) g_ptr_array_free (ptrarray, FALSE);
if (g_file_test (ZENITY_UI_FILE_RELATIVEPATH, G_FILE_TEST_EXISTS)) {
/* Try current dir, for debugging */
xml = glade_xml_new (ZENITY_GLADE_FILE_RELATIVEPATH, widget_root, GETTEXT_PACKAGE);
result = gtk_builder_add_objects_from_file (builder,
ZENITY_UI_FILE_RELATIVEPATH,
objects, NULL);
}
if (xml == NULL)
xml = glade_xml_new (ZENITY_GLADE_FILE_FULLPATH, widget_root, GETTEXT_PACKAGE);
if (result == 0)
result = gtk_builder_add_objects_from_file (builder,
ZENITY_UI_FILE_FULLPATH,
objects, &error);
if (xml == NULL) {
g_warning ("Could not load glade file : %s", ZENITY_GLADE_FILE_FULLPATH);
g_strfreev (objects);
if (result == 0) {
g_warning ("Could not load ui file %s: %s", ZENITY_UI_FILE_FULLPATH,
error->message);
g_error_free (error);
g_object_unref (builder);
return NULL;
}
return xml;
return builder;
}
gchar*
zenity_util_strip_newline (gchar *string)
{

View File

@ -2,16 +2,16 @@
#define UTIL_H
#include <gtk/gtk.h>
#include <glade/glade.h>
#include "zenity.h"
G_BEGIN_DECLS
#define ZENITY_GLADE_FILE_FULLPATH ZENITY_DATADIR "/zenity.glade"
#define ZENITY_GLADE_FILE_RELATIVEPATH "./zenity.glade"
#define ZENITY_UI_FILE_FULLPATH ZENITY_DATADIR "/zenity.ui"
#define ZENITY_UI_FILE_RELATIVEPATH "./zenity.ui"
#define ZENITY_IMAGE_FULLPATH(filename) (ZENITY_DATADIR "/" filename)
GladeXML* zenity_util_load_glade_file (const gchar *widget_root);
GtkBuilder* zenity_util_load_ui_file (const gchar *widget_root, ...) G_GNUC_NULL_TERMINATED;
gchar * zenity_util_strip_newline (gchar *string);
gboolean zenity_util_fill_file_buffer (GtkTextBuffer *buffer,
const gchar *filename);

1854
src/zenity.ui Normal file

File diff suppressed because it is too large Load Diff