summaryrefslogtreecommitdiffstats
path: root/gtk/src
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2009-03-27 15:58:11 +0000
committerjstebbins <[email protected]>2009-03-27 15:58:11 +0000
commit64dfe58a8f49c8de188fed1dddc76ebabdfeb4b4 (patch)
tree29eda34a85d74e98f26b46f3e14337543e6ca63c /gtk/src
parenta5eab51e9af0ba1cba513ecd323744958e701c65 (diff)
LinGui:
- add some error handling to resource parser - modify how icons are deserialized in ghb since the python resource parser can't easily serialize the old way git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2278 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk/src')
-rw-r--r--gtk/src/callbacks.c3
-rw-r--r--gtk/src/create_resources.py24
-rw-r--r--gtk/src/icons.c41
3 files changed, 61 insertions, 7 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c
index d76404993..9e8bc23bb 100644
--- a/gtk/src/callbacks.c
+++ b/gtk/src/callbacks.c
@@ -79,6 +79,7 @@ dep_check(signal_user_data_t *ud, const gchar *name, gboolean *out_hide)
g_debug("dep_check () %s", name);
+ if (rev_map == NULL) return TRUE;
array = ghb_dict_lookup(rev_map, name);
count = ghb_array_len(array);
*out_hide = FALSE;
@@ -172,6 +173,7 @@ ghb_check_dependency(signal_user_data_t *ud, GtkWidget *widget)
name = gtk_widget_get_name(widget);
g_debug("ghb_check_dependency () %s", name);
+ if (dep_map == NULL) return;
array = ghb_dict_lookup(dep_map, name);
count = ghb_array_len(array);
for (ii = 0; ii < count; ii++)
@@ -219,6 +221,7 @@ ghb_check_all_depencencies(signal_user_data_t *ud)
GObject *dep_object;
g_debug("ghb_check_all_depencencies ()");
+ if (rev_map == NULL) return;
ghb_dict_iter_init(&iter, rev_map);
// middle (void*) cast prevents gcc warning "defreferencing type-punned
// pointer will break strict-aliasing rules"
diff --git a/gtk/src/create_resources.py b/gtk/src/create_resources.py
index 1e346fb9b..4fdf20b1d 100644
--- a/gtk/src/create_resources.py
+++ b/gtk/src/create_resources.py
@@ -36,8 +36,8 @@ def start_element_handler(tag, attr):
val = dict()
stack.append(val)
elif tag == "icon":
- fname = attr["file"]
- fname = find_file(fname)
+ fbase = attr["file"]
+ fname = find_file(fbase)
key = attr["name"]
if fname != None and key != None:
val = dict()
@@ -49,15 +49,21 @@ def start_element_handler(tag, attr):
val["height"] = pb.get_height()
val["rowstride"] = pb.get_rowstride()
val["data"] = plistlib.Data(pb.get_pixels())
+ elif fname == None:
+ print >> sys.stderr, ( "Error: No such icon file %s" % fbase )
+ sys.exit(1)
elif tag == "plist":
- fname = attr["file"]
- fname = find_file(fname)
+ fbase = attr["file"]
+ fname = find_file(fbase)
key = attr["name"]
if fname != None and key != None:
val = plistlib.readPlist(fname)
+ elif fname == None:
+ print >> sys.stderr, ( "Error: No such plist file %s" % fbase )
+ sys.exit(1)
elif tag == "string":
- fname = attr["file"]
- fname = find_file(fname)
+ fbase = attr["file"]
+ fname = find_file(fbase)
key = attr["name"]
if fname != None and key != None:
try:
@@ -65,6 +71,10 @@ def start_element_handler(tag, attr):
val = ff.read()
except Exception, err:
print >> sys.stderr, ( "Error: %s" % str(err) )
+ sys.exit(1)
+ elif fname == None:
+ print >> sys.stderr, ( "Error: No such string file %s" % fbase )
+ sys.exit(1)
if val != None:
if type(current) == types.DictType:
@@ -101,7 +111,7 @@ def find_file(name):
global inc_list
for inc_dir in inc_list:
- inc = "%s/%s" % inc_dir, name
+ inc = "%s/%s" % (inc_dir, name)
if os.path.isfile(inc):
return inc
diff --git a/gtk/src/icons.c b/gtk/src/icons.c
index af7d84e05..948213de4 100644
--- a/gtk/src/icons.c
+++ b/gtk/src/icons.c
@@ -3,6 +3,46 @@
#include "values.h"
#include "resources.h"
+#if 0
+void
+ghb_load_icons()
+{
+ GHashTableIter iter;
+ gchar *name;
+ GValue *gval;
+
+ GValue *icons = ghb_resource_get("icons");
+ ghb_dict_iter_init(&iter, icons);
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &iter, (gpointer*)(void*)&name, (gpointer*)(void*)&gval))
+ {
+ gint colorspace, bps, width, height, rowstride;
+ gboolean alpha;
+ ghb_rawdata_t *rd;
+ gint size;
+ GdkPixbuf *pb;
+
+ colorspace = ghb_value_int(ghb_dict_lookup(gval, "colorspace"));
+ alpha = ghb_value_boolean(ghb_dict_lookup(gval, "alpha"));
+ bps = ghb_value_int(ghb_dict_lookup(gval, "bps"));
+ width = ghb_value_int(ghb_dict_lookup(gval, "width"));
+ height = ghb_value_int(ghb_dict_lookup(gval, "height"));
+ rowstride = ghb_value_int(ghb_dict_lookup(gval, "rowstride"));
+ rd = g_value_get_boxed(ghb_dict_lookup(gval, "data"));
+ pb = gdk_pixbuf_new_from_data(
+ rd->data, colorspace, alpha, bps,
+ width, height, rowstride,
+ NULL, NULL);
+ size = gdk_pixbuf_get_height(pb);
+ gtk_icon_theme_add_builtin_icon(name, size, pb);
+ gdk_pixbuf_unref(pb);
+ }
+}
+
+#else
+
void
ghb_load_icons()
{
@@ -27,3 +67,4 @@ ghb_load_icons()
gdk_pixbuf_unref(pb);
}
}
+#endif