diff options
Diffstat (limited to 'src/libr-gtk.c')
-rw-r--r-- | src/libr-gtk.c | 155 |
1 files changed, 0 insertions, 155 deletions
diff --git a/src/libr-gtk.c b/src/libr-gtk.c index f746aa8..85e154c 100644 --- a/src/libr-gtk.c +++ b/src/libr-gtk.c @@ -35,9 +35,6 @@ #include <gdk-pixbuf/gdk-pixbuf.h> #include <glib.h> -/* For loading GLADE files */ -#include <glade/glade.h> - /* For loading GTK+ Builder files */ #include <gtk/gtk.h> @@ -47,19 +44,12 @@ /* For string handling */ #include <string.h> -typedef gchar * (*GladeFileCallback)(GladeXML *, const gchar *, guint *); -GladeFileCallback glade_set_file_callback(GladeFileCallback callback, gpointer user_data); - -/* Use weak binding for all glade and GTK+ requirements */ -#pragma weak glade_set_file_callback - #pragma weak gtk_window_set_default_icon_list #pragma weak gdk_pixbuf_loader_get_pixbuf #pragma weak gtk_builder_add_from_string #pragma weak gdk_pixbuf_loader_set_size #pragma weak g_type_check_instance_cast #pragma weak gtk_builder_add_from_file -#pragma weak glade_xml_new_from_buffer #pragma weak gdk_pixbuf_loader_write #pragma weak gdk_pixbuf_loader_close #pragma weak gdk_pixbuf_loader_new @@ -67,24 +57,13 @@ GladeFileCallback glade_set_file_callback(GladeFileCallback callback, gpointer u #pragma weak g_signal_connect #pragma weak gtk_builder_new #pragma weak g_object_unref -#pragma weak glade_xml_new #pragma weak g_list_append -#pragma weak glade_init #pragma weak gtk_init #pragma weak g_free -#define GLADE_SECTION ".glade" #define BUILDER_SECTION ".ui" /* - * Handle the resource request from libglade - */ -gchar *libr_glade_read_resource(GladeXML *gladefile, const gchar *filename, guint *size, gpointer user_data) -{ - return libr_malloc((libr_file *) user_data, (char *) filename, (size_t *) size); -} - -/* * Handle the resource request from GtkBuilder */ gboolean libr_gtk_read_resource(GtkBuilder *builder, const gchar *filename, gchar **data, gsize *size, GError **error, gpointer user_data) @@ -98,41 +77,6 @@ gboolean libr_gtk_read_resource(GtkBuilder *builder, const gchar *filename, gcha } /* - * Load the libglade resource appropriately for the currently installed version - * (AKA, hurray hacks!) - */ -GladeXML *libr_new_glade(libr_file *handle, char *gladefile, size_t gladefile_size) -{ - if(glade_set_file_callback) /* The not-yet (ever?) existing way */ - { - /* Register a callback for libglade to load our resources */ - if(glade_set_file_callback((GladeFileCallback) libr_glade_read_resource, handle) != NULL) - printf("warning: over-wrote an application callback!\n"); - /* Initialize libglade almost as usual, just use a buffer instead of a file */ - return glade_xml_new_from_buffer(gladefile, gladefile_size, NULL, NULL); - } - else /* The hacky way */ - { - char *glade_file[PATH_MAX]; - GladeXML *ret = NULL; - char *temp_folder; - - temp_folder = libr_extract_resources(handle); - if(temp_folder == NULL) - return NULL; - strcpy((char*)glade_file, temp_folder); - strcat((char*)glade_file, "/"); - strcat((char*)glade_file, GLADE_SECTION); - ret = glade_xml_new((char*)glade_file, NULL, NULL); - if(ret == NULL) - cleanup_folder(temp_folder); - else - register_folder_cleanup(temp_folder); - return ret; - } -} - -/* * Load the GtkBuilder resource appropriately for the currently installed version * (AKA, hurray hacks!) */ @@ -342,102 +286,3 @@ failed: libr_close(handle); return ret; } - -/* - * Shared libglade resource loading - */ -GladeXML *libr_glade_load_internal(libr_file *handle, char *resource_name) -{ - GladeXML *glade = NULL; - size_t glade_length; - char *glade_data; - - /* Obtain the GLADE XML definition */ - glade_data = libr_malloc(handle, resource_name, &glade_length); - if(glade_data == NULL) - { - /* Failed to obtain embedded glade file */ - goto failed; - } - /* Initialize libglade appropriate for the available version */ - glade = libr_new_glade(handle, glade_data, glade_length); - if(glade == NULL) - { - /* Failed to initialize embedded glade file */ - goto failed; - } -failed: - free(glade_data); - return glade; -} - -/* - * Load the requested libglade resource and any applicable icons - */ -EXPORT_FN int libr_glade_load(GladeHandle **glade_ret, char *resource_name) -{ - libr_file *handle; - int ret = false; - - if(glade_ret == NULL) - { - /* Why on earth would you call this without obtaining the handle to the resource? */ - return false; - } - if(glade_init == NULL) - { - /* libglade was not linked with the application */ - return false; - } - /* Obtain the handle to the executable */ - if((handle = libr_open(NULL, LIBR_READ)) == NULL) - { - /* "Failed to open this executable (%s) for resources", progname() */ - return false; - } - register_internal_handle(handle); - *glade_ret = libr_glade_load_internal(handle, resource_name); - if(*glade_ret == NULL) - goto failed; - ret = true; -failed: - if(!ret) - libr_close(handle); - return ret; -} - -/* - * Automatically load the ".glade" resource and any applicable icons - */ -EXPORT_FN int libr_glade_autoload(GladeHandle **glade_ret, IconList **icons_ret, int set_default_icon) -{ - libr_file *handle = NULL; - GList *icons = NULL; - - if(glade_ret == NULL) - { - /* Why on earth would you call this without obtaining the handle to the resource? */ - return false; - } - if(glade_init == NULL) - { - /* libglade was not linked with the application */ - return false; - } - /* Obtain the handle to the executable */ - if((handle = libr_open(NULL, LIBR_READ)) == NULL) - { - /* "Failed to open this executable (%s) for resources", progname() */ - return false; - } - register_internal_handle(handle); - icons = libr_gtk_iconlist(handle); - /* Set the embedded icons as the default icon list (if requested) */ - if(icons != NULL && set_default_icon) - gtk_window_set_default_icon_list(icons); - /* Return the libglade and icon handles for the application */ - *glade_ret = libr_glade_load_internal(handle, GLADE_SECTION); - if(icons_ret) - *icons_ret = icons; - return true; -} |