Hello,

We have been using the Launcher for our Low Power Computer development projects. The Launcher has been working for us quite well. We did like the backgrounds in the previous version. I notice there has not been any updates on themes since the merge with gmenu and the conformity with freedesktop.org specification.

I have implemented some changes that will allow for configurable Button icon size and Background image from the command line. We wanted to be able to adjust the icon size very easily on each launch. The background image from the command line gives us one image for all tabs on the notebook.

Another change I implemented is the extended-format property name from the desktop-menu specification at freedesktop.org, X-Background. This will add to menu-cache-gen the background filename and will be found in the ".directory" file if it exists. These will override any background options from the command line. This gives total customization over all the backgrounds in the notebook.

Please take a look at the attached patch to see if it would be possible to integrate these changes into lxlauncher.

I am not sure what you are planning to do about themes. I have noticed that every platform puts its default background directory in a different place. They also do not agree on theme specification (eg Gnome vs. KDE). I agree this is a very complicated issue. Maybe this could be a temporary fix.

Brent
Index: lxlauncher/src/lxlauncher.c
===================================================================
--- lxlauncher/src/lxlauncher.c	(revision 1247)
+++ lxlauncher/src/lxlauncher.c	(working copy)
@@ -45,6 +45,15 @@
 #define BUTTON_SIZE    120
 #define IMG_SIZE    48
 
+static gint image_size = IMG_SIZE;
+static gchar* background_image = NULL;
+static GOptionEntry entries[] = 
+{
+	{"icon-size", 'i', 0, G_OPTION_ARG_INT, &image_size, "Button icon size NxN", "N"},
+	{"background-image", 'b', 0, G_OPTION_ARG_FILENAME, &background_image, "Background image", "FILENAME"},
+	{NULL}
+};
+
 #define DATA_DIR  PACKAGE_DATA_DIR"/lxlauncher"
 #define BACKGROUND_DIR  PACKAGE_DATA_DIR"/lxlauncher/background"
 #define ICON_DIR        PACKAGE_DATA_DIR"/lxlauncher/icons"
@@ -221,7 +230,7 @@
     if( !icon_name )
         icon_name = "folder";
 
-    icon = lxlauncher_load_icon( icon_name, IMG_SIZE, TRUE );
+    icon = lxlauncher_load_icon( icon_name, image_size, TRUE );
 
     btn = add_btn( data->table, menu_cache_item_get_name(dir), icon, menu_cache_item_get_comment(dir) );
     if( icon )
@@ -240,7 +249,7 @@
     if( !icon_name )
         icon_name = "application-x-executable";
 
-    icon = lxlauncher_load_icon( icon_name, IMG_SIZE, TRUE );
+    icon = lxlauncher_load_icon( icon_name, image_size, TRUE );
 
     btn = add_btn( table, menu_cache_item_get_name(app), icon, menu_cache_item_get_comment(app) );
 
@@ -272,9 +281,21 @@
 //        cairo_rectangle(cr, evt->area.x, evt->area.y, evt->area.width, evt->area.height );
         cairo_rectangle(cr, evt->area.x, evt->area.y, evt->area.width, evt->area.height );
         //cairo_set_source(cr, pat);
-        cairo_set_source_rgb(cr, 184.0/256, 215.0/256, 235.0/256);
+        //cairo_set_source_rgb(cr, 184.0/256, 215.0/256, 235.0/256);
+        //cairo_fill(cr);
+        //cairo_pattern_destroy(pat);
+
+		if( pixmap )
+        {
+			gdk_cairo_set_source_pixmap(cr, pixmap, 0, 0);
+			pat = cairo_get_source(cr);
+			cairo_pattern_set_extend(pat, CAIRO_EXTEND_REPEAT);
+        }
+		else
+		{
+	        cairo_set_source_rgb(cr, 184.0/256, 215.0/256, 235.0/256);
+		}
         cairo_fill(cr);
-        //cairo_pattern_destroy(pat);
         cairo_destroy(cr);
 
 /*
@@ -565,7 +586,7 @@
         GtkWidget* image;
         GtkWidget* go_up_bar = gtk_hbox_new( FALSE, 2 );
         GdkPixbuf* pixbuf=NULL;
-        GdkPixmap* pixmap;
+        GdkPixmap* pixmap=NULL;
         GdkGC *pixmap_gc=NULL;
         char* file;
         PageData* page_data;
@@ -614,16 +635,30 @@
 
         // set background
         gtk_widget_set_app_paintable( viewport, TRUE );
-/*
-        file = g_build_filename( BACKGROUND_DIR, groups[i].background, NULL );
-        pixbuf = gdk_pixbuf_new_from_file( file, NULL );
-        g_free( file );
-*/
+
+        // Background images from entries in application-directory files
+        char* str = menu_cache_item_get_background(dir);
+        if( str )
+        {
+       		file = g_build_filename( BACKGROUND_DIR, str, NULL );
+        	pixbuf = gdk_pixbuf_new_from_file( file, NULL );
+        	g_free( file );
+        }
+		g_free( str );
+
+        // GOption background-image to allow for only one background for the application        
+   		if( !pixbuf && background_image )
+   		{
+        	file = g_build_filename( BACKGROUND_DIR, background_image, NULL );
+       		pixbuf = gdk_pixbuf_new_from_file( file, NULL );
+        	g_free( file );
+       	}
+
         if( pixbuf )
         {
             pixmap = gdk_pixmap_new( gdk_get_default_root_window(), gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf), -1 );
             pixmap_gc = gdk_gc_new(pixmap);
-            gdk_pixbuf_render_to_drawable(pixbuf, pixmap, pixmap_gc,
+            gdk_draw_pixbuf(pixmap, pixmap_gc, pixbuf,
                                     0, 0, 0, 0,
                                     gdk_pixbuf_get_width(pixbuf),
                                     gdk_pixbuf_get_height(pixbuf),
@@ -650,6 +685,8 @@
     GList* l;
     gboolean enable_key=0;
     GtkSettings *settings;
+	GError *error = NULL;
+	GOptionContext *context;
 
 #ifdef ENABLE_NLS
     bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
@@ -657,7 +694,14 @@
     textdomain (GETTEXT_PACKAGE);
 #endif
 
-    gtk_init( &argc, &argv );
+	context = g_option_context_new("- icon-size background-image");
+	g_option_context_add_main_entries(context, entries, GETTEXT_PACKAGE);
+	g_option_context_add_group(context, gtk_get_option_group(TRUE));
+	if(!g_option_context_parse(context, &argc, &argv, &error))
+	{
+		g_print("option parsing failed: %s\n", error->message);
+		return 1;
+	}
 
     // Add application specific properties
     gtk_settings_install_property(g_param_spec_boolean("lxlauncher-enable-key",
@@ -667,7 +711,7 @@
     // set up themes for notebook
     gtk_rc_parse( PACKAGE_DATA_DIR "/lxlauncher/gtkrc" );
 
-    icon_size = gtk_icon_size_register( "ALIcon", IMG_SIZE, IMG_SIZE );
+    icon_size = gtk_icon_size_register( "ALIcon", image_size, image_size );
 
     main_window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
     gtk_window_move( main_window, 0, 0 );
Index: menu-cache/libmenu-cache/menu-cache.c
===================================================================
--- menu-cache/libmenu-cache/menu-cache.c	(revision 1247)
+++ menu-cache/libmenu-cache/menu-cache.c	(working copy)
@@ -48,6 +48,7 @@
     char* name;
     char* comment;
     char* icon;
+    char* background;
     const char* file_dir;
     char* file_name;
     MenuCacheDir* parent;
@@ -212,6 +213,13 @@
     if( G_LIKELY(len > 1) )
         item->icon = g_strndup( line, len - 1 );
 
+    /* background */
+    if( G_UNLIKELY( ! fgets( line, G_N_ELEMENTS(line) - 1, f ) ))
+        return item;
+    len = strlen( line );
+    if( G_LIKELY(len > 1) )
+        item->background = g_strndup( line, len - 1 );
+
     /* file dir/basename */
 
     /* file name */
@@ -485,6 +493,7 @@
         g_free( item->name );
         g_free( item->comment );
         g_free( item->icon );
+        g_free( item->background );
 
         if( item->file_name && item->file_name != item->id )
             g_free( item->file_name );
@@ -544,6 +553,11 @@
     return item->icon;
 }
 
+const char* menu_cache_item_get_background( MenuCacheItem* item )
+{
+    return item->background;
+}
+
 const char* menu_cache_item_get_file_basename( MenuCacheItem* item )
 {
     return item->file_name;
Index: menu-cache/libmenu-cache/menu-cache.h
===================================================================
--- menu-cache/libmenu-cache/menu-cache.h	(revision 1247)
+++ menu-cache/libmenu-cache/menu-cache.h	(working copy)
@@ -90,6 +90,7 @@
 const char* menu_cache_item_get_name( MenuCacheItem* item );
 const char* menu_cache_item_get_comment( MenuCacheItem* item );
 const char* menu_cache_item_get_icon( MenuCacheItem* item );
+const char* menu_cache_item_get_background( MenuCacheItem* item );
 
 const char* menu_cache_item_get_file_basename( MenuCacheItem* item );
 const char* menu_cache_item_get_file_dirname( MenuCacheItem* item );
Index: menu-cache/menu-cache-gen/gmenu-tree.c
===================================================================
--- menu-cache/menu-cache-gen/gmenu-tree.c	(revision 1247)
+++ menu-cache/menu-cache-gen/gmenu-tree.c	(working copy)
@@ -1052,6 +1052,17 @@
 }
 
 const char *
+gmenu_tree_directory_get_background (GMenuTreeDirectory *directory)
+{
+  g_return_val_if_fail (directory != NULL, NULL);
+
+  if (!directory->directory_entry)
+    return NULL;
+
+  return desktop_entry_get_background (directory->directory_entry);
+}
+
+const char *
 gmenu_tree_directory_get_desktop_file_path (GMenuTreeDirectory *directory)
 {
   g_return_val_if_fail (directory != NULL, NULL);
@@ -1182,6 +1193,14 @@
 }
 
 const char *
+gmenu_tree_entry_get_background (GMenuTreeEntry *entry)
+{
+  g_return_val_if_fail (entry != NULL, NULL);
+
+  return desktop_entry_get_background (entry->desktop_entry);
+}
+
+const char *
 gmenu_tree_entry_get_exec (GMenuTreeEntry *entry)
 {
   g_return_val_if_fail (entry != NULL, NULL);
Index: menu-cache/menu-cache-gen/menu-cache-gen.c
===================================================================
--- menu-cache/menu-cache-gen/menu-cache-gen.c	(revision 1247)
+++ menu-cache/menu-cache-gen/menu-cache-gen.c	(working copy)
@@ -151,6 +151,10 @@
     str = gmenu_tree_entry_get_icon( item );
     fprintf( of, "%s\n", str ? str : "" );
 
+    /* Background */
+    str = gmenu_tree_entry_get_background( item );
+    fprintf( of, "%s\n", str ? str : "" );
+
     /* file dir/basename */
     if( gmenu_tree_entry_get_desktop_file_path( item ) )
     {
@@ -214,6 +218,8 @@
     fprintf( of, "%s\n", str ? str : "" );
     str = gmenu_tree_directory_get_icon( dir );
     fprintf( of, "%s\n", str ? str : "" );
+    str = gmenu_tree_directory_get_background( dir );
+    fprintf( of, "%s\n", str ? str : "" );
 
     if( gmenu_tree_directory_get_desktop_file_path( dir ) )
     {
Index: menu-cache/menu-cache-gen/gmenu-tree.h
===================================================================
--- menu-cache/menu-cache-gen/gmenu-tree.h	(revision 1247)
+++ menu-cache/menu-cache-gen/gmenu-tree.h	(working copy)
@@ -102,6 +102,7 @@
 const char *gmenu_tree_directory_get_name              (GMenuTreeDirectory *directory);
 const char *gmenu_tree_directory_get_comment           (GMenuTreeDirectory *directory);
 const char *gmenu_tree_directory_get_icon              (GMenuTreeDirectory *directory);
+const char *gmenu_tree_directory_get_background		   (GMenuTreeDirectory *directory);
 const char *gmenu_tree_directory_get_desktop_file_path (GMenuTreeDirectory *directory);
 const char *gmenu_tree_directory_get_menu_id           (GMenuTreeDirectory *directory);
 GMenuTree  *gmenu_tree_directory_get_tree              (GMenuTreeDirectory *directory);
@@ -116,6 +117,7 @@
 const char *gmenu_tree_entry_get_generic_name       (GMenuTreeEntry *entry);
 const char *gmenu_tree_entry_get_comment            (GMenuTreeEntry *entry);
 const char *gmenu_tree_entry_get_icon               (GMenuTreeEntry *entry);
+const char *gmenu_tree_entry_get_background			(GMenuTreeEntry *entry);
 const char *gmenu_tree_entry_get_exec               (GMenuTreeEntry *entry);
 gboolean    gmenu_tree_entry_get_launch_in_terminal (GMenuTreeEntry *entry);
 gboolean    gmenu_tree_entry_get_use_startup_notify (GMenuTreeEntry *entry);
Index: menu-cache/menu-cache-gen/desktop-entries.c
===================================================================
--- menu-cache/menu-cache-gen/desktop-entries.c	(revision 1247)
+++ menu-cache/menu-cache-gen/desktop-entries.c	(working copy)
@@ -47,6 +47,7 @@
   char     *generic_name;
   char     *comment;
   char     *icon;
+  char	   *background;
   char     *exec;
   gboolean terminal : 1;
   gboolean startup_notify : 1;
@@ -304,6 +305,7 @@
   retval->generic_name = GET_LOCALE_STRING ("GenericName");
   retval->comment      = GET_LOCALE_STRING ("Comment");
   retval->icon         = GET_LOCALE_STRING ("Icon");
+  retval->background   = GET_LOCALE_STRING ("X-Background");
   retval->flags        = get_flags_from_key_file (retval, key_file, desktop_entry_group);
   retval->categories   = get_categories_from_key_file (retval, key_file, desktop_entry_group);
 
@@ -321,6 +323,7 @@
                 retval->name,
                 retval->comment ? retval->comment : "(null)",
                 retval->icon ? retval->icon : "(null)",
+                retval->background ? retval->background : "(null)",
                 retval->flags & DESKTOP_ENTRY_NO_DISPLAY     ? "(true)" : "(false)",
                 retval->flags & DESKTOP_ENTRY_HIDDEN         ? "(true)" : "(false)",
                 retval->flags & DESKTOP_ENTRY_SHOW_IN_GNOME  ? "(true)" : "(false)",
@@ -390,6 +393,9 @@
   g_free (entry->icon);
   entry->icon = NULL;
 
+  g_free (entry->background);
+  entry->background = NULL;
+
   g_free (entry->exec);
   entry->exec = NULL;
 
@@ -430,6 +436,7 @@
   retval->generic_name = g_strdup (entry->generic_name);
   retval->comment  = g_strdup (entry->comment);
   retval->icon     = g_strdup (entry->icon);
+  retval->background = g_strdup (entry->background);
   retval->exec     = g_strdup (entry->exec);
   retval->terminal = entry->terminal;
   retval->startup_notify = entry->startup_notify;
@@ -477,6 +484,9 @@
       g_free (entry->icon);
       entry->icon = NULL;
 
+      g_free (entry->background);
+      entry->background = NULL;
+
       g_free (entry->exec);
       entry->exec = NULL;
 
@@ -533,6 +543,12 @@
 }
 
 const char *
+desktop_entry_get_background (DesktopEntry *entry)
+{
+  return entry->background;
+}
+
+const char *
 desktop_entry_get_exec (DesktopEntry *entry)
 {
   return entry->exec;
Index: menu-cache/menu-cache-gen/desktop-entries.h
===================================================================
--- menu-cache/menu-cache-gen/desktop-entries.h	(revision 1247)
+++ menu-cache/menu-cache-gen/desktop-entries.h	(working copy)
@@ -48,6 +48,7 @@
 const char *desktop_entry_get_generic_name       (DesktopEntry *entry);
 const char *desktop_entry_get_comment            (DesktopEntry *entry);
 const char *desktop_entry_get_icon               (DesktopEntry *entry);
+const char *desktop_entry_get_background		 (DesktopEntry *entry);
 const char *desktop_entry_get_exec               (DesktopEntry *entry);
 const GQuark *desktop_entry_get_categories       (DesktopEntry *entry);
 gboolean    desktop_entry_get_launch_in_terminal (DesktopEntry *entry);
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Lxde-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lxde-list

Reply via email to