changeset 586:26519231a4f4 trunk

[svn] - aosd: added experimental multiple monitor support, plus max_width setting
author giacomo
date Wed, 31 Jan 2007 08:42:04 -0800
parents 2d20bc58a290
children 289c08270c7b
files ChangeLog src/aosd/aosd_cfg.c src/aosd/aosd_cfg.h src/aosd/aosd_common.h src/aosd/aosd_osd.c src/aosd/aosd_ui.c
diffstat 6 files changed, 141 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Jan 30 23:14:02 2007 -0800
+++ b/ChangeLog	Wed Jan 31 08:42:04 2007 -0800
@@ -1,3 +1,15 @@
+2007-01-31 07:14:02 +0000  Yoshiki Yazawa <yaz@cc.rim.or.jp>
+  revision [1256]
+  tweak xspf plugin to conform xspf specification version 1.
+  - arrange the order of elements to pass several validators.
+  - specify character set and encoding as UTF-8.
+  - now urls beginning with file:// can be used.
+  - prepend file:// onto local file entry to save (tentative).
+  
+  trunk/src/xspf/xspf.c |   99 ++++++++++++++++++++++++++++----------------------
+  1 file changed, 56 insertions(+), 43 deletions(-)
+
+
 2007-01-30 21:41:14 +0000  Michael Farber <01mf02@gmail.com>
   revision [1254]
   - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
--- a/src/aosd/aosd_cfg.c	Tue Jan 30 23:14:02 2007 -0800
+++ b/src/aosd/aosd_cfg.c	Wed Jan 31 08:42:04 2007 -0800
@@ -132,6 +132,8 @@
   cfg_osd_copy->position.placement = cfg_osd->position.placement;
   cfg_osd_copy->position.offset_x = cfg_osd->position.offset_x;
   cfg_osd_copy->position.offset_y = cfg_osd->position.offset_y;
+  cfg_osd_copy->position.maxsize_width = cfg_osd->position.maxsize_width;
+  cfg_osd_copy->position.multimon_id = cfg_osd->position.multimon_id;
   cfg_osd_copy->animation.timing_display = cfg_osd->animation.timing_display;
   cfg_osd_copy->animation.timing_fadein = cfg_osd->animation.timing_fadein;
   cfg_osd_copy->animation.timing_fadeout = cfg_osd->animation.timing_fadeout;
@@ -163,6 +165,8 @@
   g_print("  placement: %i\n", cfg->osd->position.placement);
   g_print("  offset x: %i\n", cfg->osd->position.offset_x);
   g_print("  offset y: %i\n", cfg->osd->position.offset_y);
+  g_print("  max OSD width: %i\n", cfg->osd->position.maxsize_width);
+  g_print("  multi-monitor id: %i\n", cfg->osd->position.multimon_id);
   g_print("\nANIMATION\n");
   g_print("  timing display: %i\n", cfg->osd->animation.timing_display);
   g_print("  timing fade in: %i\n", cfg->osd->animation.timing_fadein);
@@ -215,6 +219,14 @@
        "position_offset_y" , &(cfg->osd->position.offset_y) ) )
     cfg->osd->position.offset_y = 0;
 
+  if ( !bmp_cfg_db_get_int( cfgfile , "aosd" ,
+       "position_maxsize_width" , &(cfg->osd->position.maxsize_width) ) )
+    cfg->osd->position.maxsize_width = 0;
+
+  if ( !bmp_cfg_db_get_int( cfgfile , "aosd" ,
+       "position_multimon_id" , &(cfg->osd->position.multimon_id) ) )
+    cfg->osd->position.multimon_id = -1;
+
   /* animation */
   if ( !bmp_cfg_db_get_int( cfgfile , "aosd" ,
        "animation_timing_display" , &(cfg->osd->animation.timing_display) ) )
@@ -326,6 +338,12 @@
   bmp_cfg_db_set_int( cfgfile , "aosd" ,
     "position_offset_y" , cfg->osd->position.offset_y );
 
+  bmp_cfg_db_set_int( cfgfile , "aosd" ,
+    "position_maxsize_width" , cfg->osd->position.maxsize_width );
+
+  bmp_cfg_db_set_int( cfgfile , "aosd" ,
+    "position_multimon_id" , cfg->osd->position.multimon_id );
+
   /* animation */
   bmp_cfg_db_set_int( cfgfile , "aosd" ,
     "animation_timing_display" , cfg->osd->animation.timing_display );
--- a/src/aosd/aosd_cfg.h	Tue Jan 30 23:14:02 2007 -0800
+++ b/src/aosd/aosd_cfg.h	Wed Jan 31 08:42:04 2007 -0800
@@ -88,6 +88,8 @@
   gint placement;
   gint offset_x;
   gint offset_y;
+  gint maxsize_width;
+  gint multimon_id;
 }
 aosd_cfg_osd_position_t;
 
--- a/src/aosd/aosd_common.h	Tue Jan 30 23:14:02 2007 -0800
+++ b/src/aosd/aosd_common.h	Wed Jan 31 08:42:04 2007 -0800
@@ -30,6 +30,6 @@
 
 #include "../../config.h"
 
-#define AOSD_VERSION_PLUGIN "0.1"
+#define AOSD_VERSION_PLUGIN "0.1beta"
 
 #endif /* !_I_AOSD_COMMON_H */
--- a/src/aosd/aosd_osd.c	Tue Jan 30 23:14:02 2007 -0800
+++ b/src/aosd/aosd_osd.c	Wed Jan 31 08:42:04 2007 -0800
@@ -96,22 +96,52 @@
   GhosdFadeData fade_data = { NULL , 0 , NULL , 0 , 0 , 0 };
   PangoContext *context;
   PangoLayout *osd_layout;
-  gint max_width, layout_width, layout_height, pos_x = 0, pos_y = 0;
+  gint max_width, layout_width, layout_height;
+  gint pos_x = 0, pos_y = 0;
   gint pad_left = 0 , pad_right = 0 , pad_top = 0 , pad_bottom = 0;
-  const gint screen_width = gdk_screen_get_width( gdk_screen_get_default() );
-  const gint screen_height = gdk_screen_get_height( gdk_screen_get_default() );
+  gint screen_width, screen_height;
   const gint STEP_MS = 50;
   const gfloat dalpha_in = 1.0 / ( cfg_osd->animation.timing_fadein / (gfloat)STEP_MS );
   const gfloat dalpha_out = 1.0 / ( cfg_osd->animation.timing_fadeout / (gfloat)STEP_MS );
   struct timeval tv_nextupdate;
   gboolean stop_now = FALSE;
   aosd_deco_style_data_t style_data;
+  GdkScreen *screen = gdk_screen_get_default();
+
+  /* calculate screen_width and screen_height */
+  if ( cfg_osd->position.multimon_id > -1 )
+  {
+    /* adjust coordinates and size according to selected monitor */
+    GdkRectangle rect;
+    gdk_screen_get_monitor_geometry( screen , cfg_osd->position.multimon_id , &rect );
+    pos_x = rect.x;
+    pos_y = rect.y;
+    screen_width = rect.width;
+    screen_height = rect.height;
+  }
+  else
+  {
+    /* use total space available, even when composed by multiple monitor */
+    screen_width = gdk_screen_get_width( screen );
+    screen_height = gdk_screen_get_height( screen );
+    pos_x = 0;
+    pos_y = 0;
+  }
 
   /* pick padding from selected decoration style */
   aosd_deco_style_get_padding( cfg_osd->decoration.code ,
     &pad_top , &pad_bottom , &pad_left , &pad_right );
 
-  max_width = screen_width - pad_left - pad_right - abs(cfg_osd->position.offset_x);
+  if ( cfg_osd->position.maxsize_width > 0 )
+  {
+    max_width = cfg_osd->position.maxsize_width - pad_left - pad_right;
+    if ( max_width < 1 ) /* ignore user-defined max_width if it is too small */
+      max_width = screen_width - pad_left - pad_right - abs(cfg_osd->position.offset_x);
+  }
+  else
+  {
+    max_width = screen_width - pad_left - pad_right - abs(cfg_osd->position.offset_x);
+  }
   context = pango_cairo_font_map_create_context(
               PANGO_CAIRO_FONT_MAP(pango_cairo_font_map_get_default()));
   osd_layout = pango_layout_new(context);
@@ -127,41 +157,41 @@
   switch ( cfg_osd->position.placement )
   {
     case AOSD_POSITION_PLACEMENT_TOP:
-      pos_x = (screen_width - (layout_width + pad_left + pad_right)) / 2;
-      pos_y = 0;
+      pos_x += (screen_width - (layout_width + pad_left + pad_right)) / 2;
+      pos_y += 0;
       break;
     case AOSD_POSITION_PLACEMENT_TOPRIGHT:
-      pos_x = screen_width - (layout_width + pad_left + pad_right);
-      pos_y = 0;
+      pos_x += screen_width - (layout_width + pad_left + pad_right);
+      pos_y += 0;
       break;
     case AOSD_POSITION_PLACEMENT_MIDDLELEFT:
-      pos_x = 0;
-      pos_y = (screen_height - (layout_height + pad_top + pad_bottom)) / 2;
+      pos_x += 0;
+      pos_y += (screen_height - (layout_height + pad_top + pad_bottom)) / 2;
       break;
     case AOSD_POSITION_PLACEMENT_MIDDLE:
-      pos_x = (screen_width - (layout_width + pad_left + pad_right)) / 2;
-      pos_y = (screen_height - (layout_height + pad_top + pad_bottom)) / 2;
+      pos_x += (screen_width - (layout_width + pad_left + pad_right)) / 2;
+      pos_y += (screen_height - (layout_height + pad_top + pad_bottom)) / 2;
       break;
     case AOSD_POSITION_PLACEMENT_MIDDLERIGHT:
-      pos_x = screen_width - (layout_width + pad_left + pad_right);
-      pos_y = (screen_height - (layout_height + pad_top + pad_bottom)) / 2;
+      pos_x += screen_width - (layout_width + pad_left + pad_right);
+      pos_y += (screen_height - (layout_height + pad_top + pad_bottom)) / 2;
       break;
     case AOSD_POSITION_PLACEMENT_BOTTOMLEFT:
-      pos_x = 0;
-      pos_y = screen_height - (layout_height + pad_top + pad_bottom);
+      pos_x += 0;
+      pos_y += screen_height - (layout_height + pad_top + pad_bottom);
       break;
     case AOSD_POSITION_PLACEMENT_BOTTOM:
-      pos_x = (screen_width - (layout_width + pad_left + pad_right)) / 2;
-      pos_y = screen_height - (layout_height + pad_top + pad_bottom);
+      pos_x += (screen_width - (layout_width + pad_left + pad_right)) / 2;
+      pos_y += screen_height - (layout_height + pad_top + pad_bottom);
       break;
     case AOSD_POSITION_PLACEMENT_BOTTOMRIGHT:
-      pos_x = screen_width - (layout_width + pad_left + pad_right);
-      pos_y = screen_height - (layout_height + pad_top + pad_bottom);
+      pos_x += screen_width - (layout_width + pad_left + pad_right);
+      pos_y += screen_height - (layout_height + pad_top + pad_bottom);
       break;
     case AOSD_POSITION_PLACEMENT_TOPLEFT:
     default:
-      pos_x = 0;
-      pos_y = 0;
+      pos_x += 0;
+      pos_y += 0;
       break;
   }
 
--- a/src/aosd/aosd_ui.c	Tue Jan 30 23:14:02 2007 -0800
+++ b/src/aosd/aosd_ui.c	Wed Jan 31 08:42:04 2007 -0800
@@ -126,6 +126,24 @@
 }
 
 
+static void
+aosd_cb_configure_position_maxsize_commit ( GtkWidget * table , aosd_cfg_t * cfg )
+{
+  cfg->osd->position.maxsize_width = gtk_spin_button_get_value_as_int(
+    GTK_SPIN_BUTTON(g_object_get_data(G_OBJECT(table),"maxsize_width")) );
+  return;
+}
+
+
+static void
+aosd_cb_configure_position_multimon_commit ( GtkWidget * combo , aosd_cfg_t * cfg )
+{
+  gint active = gtk_combo_box_get_active( GTK_COMBO_BOX(combo) );
+  cfg->osd->position.multimon_id = ( active > -1 ) ? (active - 1) : -1;
+  return;
+}
+
+
 static GtkWidget *
 aosd_ui_configure_position ( aosd_cfg_t * cfg , GList ** cb_list )
 {
@@ -134,9 +152,14 @@
   GtkWidget *pos_placement_bt[9], *pos_placement_bt_darea[9];
   GtkWidget *pos_offset_table, *pos_offset_x_label, *pos_offset_x_spinbt;
   GtkWidget *pos_offset_y_label, *pos_offset_y_spinbt;
+  GtkWidget *pos_maxsize_width_label, *pos_maxsize_width_spinbt;
+  GtkWidget *pos_multimon_frame, *pos_multimon_hbox;
+  GtkWidget *pos_multimon_label;
+  GtkWidget *pos_multimon_combobox;
+  gint monitors_num = gdk_screen_get_n_monitors( gdk_screen_get_default() );
   gint i = 0;
 
-  pos_vbox = gtk_vbox_new( FALSE , 0 );
+  pos_vbox = gtk_vbox_new( FALSE , 4 );
   gtk_container_set_border_width( GTK_CONTAINER(pos_vbox) , 6 );
 
   pos_placement_frame = gtk_frame_new( _("Placement") );
@@ -170,10 +193,11 @@
 
   gtk_box_pack_start( GTK_BOX(pos_placement_hbox) , gtk_vseparator_new() , FALSE , FALSE , 6 );
 
-  pos_offset_table = gtk_table_new( 2 , 2 , FALSE );
+  pos_offset_table = gtk_table_new( 3 , 2 , FALSE );
   gtk_table_set_row_spacings( GTK_TABLE(pos_offset_table) , 4 );
   gtk_table_set_col_spacings( GTK_TABLE(pos_offset_table) , 4 );
   pos_offset_x_label = gtk_label_new( _( "Relative X offset:" ) );
+  gtk_misc_set_alignment( GTK_MISC(pos_offset_x_label) , 0 , 0.5 );
   gtk_table_attach( GTK_TABLE(pos_offset_table) , pos_offset_x_label ,
                     0 , 1 , 0 , 1 , GTK_FILL , GTK_FILL , 0 , 0 );
   pos_offset_x_spinbt = gtk_spin_button_new_with_range( -9999 , 9999 , 1 );
@@ -182,6 +206,7 @@
                     1 , 2 , 0 , 1 , GTK_FILL , GTK_FILL , 0 , 0 );
   g_object_set_data( G_OBJECT(pos_offset_table) , "offx" , pos_offset_x_spinbt );
   pos_offset_y_label = gtk_label_new( _( "Relative Y offset:" ) );
+  gtk_misc_set_alignment( GTK_MISC(pos_offset_y_label) , 0 , 0.5 );
   gtk_table_attach( GTK_TABLE(pos_offset_table) , pos_offset_y_label ,
                     0 , 1 , 1 , 2 , GTK_FILL , GTK_FILL , 0 , 0 );
   pos_offset_y_spinbt = gtk_spin_button_new_with_range( -9999 , 9999 , 1 );
@@ -189,8 +214,37 @@
   gtk_table_attach( GTK_TABLE(pos_offset_table) , pos_offset_y_spinbt ,
                     1 , 2 , 1 , 2 , GTK_FILL , GTK_FILL , 0 , 0 );
   g_object_set_data( G_OBJECT(pos_offset_table) , "offy" , pos_offset_y_spinbt );
+  pos_maxsize_width_label = gtk_label_new( _("Max OSD width:") );
+  gtk_misc_set_alignment( GTK_MISC(pos_maxsize_width_label) , 0 , 0.5 );
+  gtk_table_attach( GTK_TABLE(pos_offset_table) , pos_maxsize_width_label ,
+                    0 , 1 , 2 , 3 , GTK_FILL , GTK_FILL , 0 , 0 );
+  pos_maxsize_width_spinbt = gtk_spin_button_new_with_range( 0 , 99999 , 1 );
+  g_object_set_data( G_OBJECT(pos_offset_table) , "maxsize_width" , pos_maxsize_width_spinbt );
+  gtk_spin_button_set_value( GTK_SPIN_BUTTON(pos_maxsize_width_spinbt) , cfg->osd->position.maxsize_width );
+  gtk_table_attach( GTK_TABLE(pos_offset_table) , pos_maxsize_width_spinbt ,
+                    1 , 2 , 2 , 3 , GTK_FILL , GTK_FILL , 0 , 0 );
   gtk_box_pack_start( GTK_BOX(pos_placement_hbox) , pos_offset_table , FALSE , FALSE , 0 );
   aosd_callback_list_add( cb_list , pos_offset_table , aosd_cb_configure_position_offset_commit );
+  aosd_callback_list_add( cb_list , pos_offset_table , aosd_cb_configure_position_maxsize_commit );
+
+  pos_multimon_frame = gtk_frame_new( "Multi-Monitor options" );
+  pos_multimon_hbox = gtk_hbox_new( FALSE , 4 );
+  gtk_container_set_border_width( GTK_CONTAINER(pos_multimon_hbox) , 6 );
+  gtk_container_add( GTK_CONTAINER(pos_multimon_frame), pos_multimon_hbox );
+  pos_multimon_label = gtk_label_new( _("Display OSD using:") );
+  pos_multimon_combobox = gtk_combo_box_new_text();
+  gtk_combo_box_append_text( GTK_COMBO_BOX(pos_multimon_combobox) , _("all monitors") );
+  for ( i = 0 ; i < monitors_num ; i++ )
+  {
+    gchar *mon_str = g_strdup_printf( _("monitor %i") , i + 1 );
+    gtk_combo_box_append_text( GTK_COMBO_BOX(pos_multimon_combobox) , mon_str );
+    g_free( mon_str );
+  }
+  gtk_combo_box_set_active( GTK_COMBO_BOX(pos_multimon_combobox) , (cfg->osd->position.multimon_id + 1) );
+  aosd_callback_list_add( cb_list , pos_multimon_combobox , aosd_cb_configure_position_multimon_commit );
+  gtk_box_pack_start( GTK_BOX(pos_multimon_hbox) , pos_multimon_label , FALSE , FALSE , 0 );
+  gtk_box_pack_start( GTK_BOX(pos_multimon_hbox) , pos_multimon_combobox , FALSE , FALSE , 0 );
+  gtk_box_pack_start( GTK_BOX(pos_vbox) , pos_multimon_frame , FALSE , FALSE , 0 );
 
   return pos_vbox;
 }