]> granicus.if.org Git - handbrake/commitdiff
LinGui:
authorjstebbins <jstebbins.hb@gmail.com>
Fri, 27 Mar 2009 15:58:11 +0000 (15:58 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Fri, 27 Mar 2009 15:58:11 +0000 (15:58 +0000)
- 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

gtk/src/callbacks.c
gtk/src/create_resources.py
gtk/src/icons.c

index d764049935a531d861e50425e0c40c0b7df5e47f..9e8bc23bbc9935fe5460b2d5174d3e0d4b565b9a 100644 (file)
@@ -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"
index 1e346fb9b9cf8859a615afc0d6b5fa269cd5d810..4fdf20b1dfdbe73fa4b1e1560877426fa695cc6d 100644 (file)
@@ -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
 
index af7d84e05923ad30421874ee661f5beb64b24b78..948213de494df33df2748520f0ea627ff6efb02f 100644 (file)
@@ -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