[xiph-commits] r12123 - trunk/sushivision

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Fri Nov 17 03:34:14 PST 2006


Author: xiphmont
Date: 2006-11-17 03:34:11 -0800 (Fri, 17 Nov 2006)
New Revision: 12123

Modified:
   trunk/sushivision/gtksucks.c
   trunk/sushivision/gtksucks.h
   trunk/sushivision/panel-2d.c
   trunk/sushivision/plot.c
   trunk/sushivision/slice.c
   trunk/sushivision/slider.c
Log:
Add a little more common right-menu infrastructure



Modified: trunk/sushivision/gtksucks.c
===================================================================
--- trunk/sushivision/gtksucks.c	2006-11-17 11:32:44 UTC (rev 12122)
+++ trunk/sushivision/gtksucks.c	2006-11-17 11:34:11 UTC (rev 12123)
@@ -226,6 +226,51 @@
   gdk_threads_set_lock_functions(recursive_gdk_lock,recursive_gdk_unlock);
 }
 
+/**********************************************************************/
+/* Not really a fixup; generate menus that declare what the keyboard
+   shortcuts are */
 
+GtkWidget *gtk_menu_new_twocol(char **menu_list, char **shortcuts){
 
+  char **ptr = menu_list;
+  char **sptr = shortcuts;
+  GtkWidget *ret = gtk_menu_new();
+   
+  /* create packable boxes for labels, put left labels in */
+  while(*ptr){
+    GtkWidget *item;
+    if(!strcmp(*ptr,"")){
+      // seperator, not item
+      item = gtk_separator_menu_item_new();
+      gtk_menu_shell_append(GTK_MENU_SHELL(ret),item);
+    }else{
+      if(sptr && *sptr){
+	GtkWidget *box = gtk_hbox_new(0,10);
+	GtkWidget *left = gtk_label_new(*ptr);
+	GtkWidget *right = gtk_label_new(NULL);
 
+	char *markup = g_markup_printf_escaped ("<i>%s</i>", *sptr);
+	gtk_label_set_markup (GTK_LABEL (right), markup);
+	g_free (markup);
+	
+	item = gtk_menu_item_new();
+	gtk_container_add(GTK_CONTAINER(item),box);
+	gtk_box_pack_start(GTK_BOX(box),left,0,0,5);
+	gtk_box_pack_end(GTK_BOX(box),right,0,0,5);
+
+      }else{
+	item = gtk_menu_item_new_with_label(*ptr);
+      }
+      gtk_menu_shell_append(GTK_MENU_SHELL(ret),item);
+    }
+    gtk_widget_show_all(item);
+
+    ptr++;
+    if(sptr)
+      sptr++;
+  }
+
+  return ret;
+}
+
+

Modified: trunk/sushivision/gtksucks.h
===================================================================
--- trunk/sushivision/gtksucks.h	2006-11-17 11:32:44 UTC (rev 12122)
+++ trunk/sushivision/gtksucks.h	2006-11-17 11:34:11 UTC (rev 12123)
@@ -26,5 +26,6 @@
 extern void gtk_widget_remove_events (GtkWidget *widget, gint events);
 extern void gtk_button3_fixup();
 extern void gtk_mutex_fixup();
+extern GtkWidget *gtk_menu_new_twocol(char **menu_list, char **shortcuts);
 
 #endif

Modified: trunk/sushivision/panel-2d.c
===================================================================
--- trunk/sushivision/panel-2d.c	2006-11-17 11:32:44 UTC (rev 12122)
+++ trunk/sushivision/panel-2d.c	2006-11-17 11:34:11 UTC (rev 12123)
@@ -46,13 +46,23 @@
 static void panel2d_undo_resume(sushiv_panel_t *p);
 
 static char *menulist[]={
-  "Undo [Backspace]",
-  "Redo [Space]",
-  "Find Peaks [p]",
-  "Quit [q]",
+  "Undo",
+  "Redo",
+  "Find peaks",
+  "",
+  "Quit",
   NULL
 };
 
+static char *shortlist[]={
+  "Backspace",
+  "Space",
+  "p",
+  NULL,
+  "q",
+  NULL
+};
+
 static void render_checks(int w, int y, u_int32_t *render){
   int x,j;
   /* default checked background */
@@ -1388,24 +1398,11 @@
   }
   update_xy_availability(p);
 
-  // right mouse menu 
-  {
-    char **ptr = menulist;
-    p2->popmenu = gtk_menu_new();
-    
-    while(*ptr){
-      GtkWidget *mi = gtk_menu_item_new_with_label(*ptr);
-      gtk_menu_shell_append(GTK_MENU_SHELL(p2->popmenu),mi);
-      gtk_widget_show(mi);
-      ptr++;
-    }
+  p2->popmenu = gtk_menu_new_twocol(menulist,shortlist);
+  gtk_widget_add_events(p2->toplevel, GDK_BUTTON_PRESS_MASK);
+  g_signal_connect_swapped (G_OBJECT(p2->toplevel), "button-press-event",
+			    G_CALLBACK (popup_callback), p2->popmenu);
 
-    gtk_widget_add_events(p2->toplevel, GDK_BUTTON_PRESS_MASK);
-    g_signal_connect_swapped (G_OBJECT(p2->toplevel), "button-press-event",
-			      G_CALLBACK (popup_callback), p2->popmenu);
-
-  }
-
   g_signal_connect (G_OBJECT (p2->toplevel), "key-press-event",
                     G_CALLBACK (panel2d_keypress), p);
   gtk_window_set_title (GTK_WINDOW (p2->toplevel), p->name);

Modified: trunk/sushivision/plot.c
===================================================================
--- trunk/sushivision/plot.c	2006-11-17 11:32:44 UTC (rev 12122)
+++ trunk/sushivision/plot.c	2006-11-17 11:34:11 UTC (rev 12123)
@@ -552,25 +552,30 @@
 
 static gboolean mouse_press (GtkWidget        *widget,
 			     GdkEventButton   *event){
-  Plot *p = PLOT (widget);
- 
-  if(p->box_active && inside_box(p,event->x,event->y) && !p->button_down){
 
-    p->selx = scalespace_value(&p->x,event->x);
-    p->sely = scalespace_value(&p->y,widget->allocation.height-event->y);
-    p->cross_active=1;
-
-    if(p->box_callback)
-      p->box_callback(p->cross_data,1);
-
-    p->button_down=0;
-    p->box_active=0;
-
-  }else{
-    p->box_x2=p->box_x1 = scalespace_value(&p->x,event->x);
-    p->box_y2=p->box_y1 = scalespace_value(&p->y,widget->allocation.height-event->y);
-    p->box_active = 0;
-    p->button_down=1; 
+  if (event->button == 3) return FALSE;
+  if (event->button == 1){
+  
+    Plot *p = PLOT (widget);
+    
+    if(p->box_active && inside_box(p,event->x,event->y) && !p->button_down){
+      
+      p->selx = scalespace_value(&p->x,event->x);
+      p->sely = scalespace_value(&p->y,widget->allocation.height-event->y);
+      p->cross_active=1;
+      
+      if(p->box_callback)
+	p->box_callback(p->cross_data,1);
+      
+      p->button_down=0;
+      p->box_active=0;
+      
+    }else{
+      p->box_x2=p->box_x1 = scalespace_value(&p->x,event->x);
+      p->box_y2=p->box_y1 = scalespace_value(&p->y,widget->allocation.height-event->y);
+      p->box_active = 0;
+      p->button_down=1; 
+    }
   }
   gtk_widget_grab_focus(widget);
   return TRUE;
@@ -578,6 +583,8 @@
  
 static gboolean mouse_release (GtkWidget        *widget,
 			       GdkEventButton   *event){
+  if (event->button == 3) return FALSE;
+
   Plot *p = PLOT (widget);
   plot_expose_request(p);
 

Modified: trunk/sushivision/slice.c
===================================================================
--- trunk/sushivision/slice.c	2006-11-17 11:32:44 UTC (rev 12122)
+++ trunk/sushivision/slice.c	2006-11-17 11:34:11 UTC (rev 12123)
@@ -90,15 +90,23 @@
 static gboolean slice_button_press(GtkWidget        *widget,
 				   GdkEventButton   *event){
   Slice *s=SLICE(widget);
+  if(event->button == 3)return FALSE;
+  
+  if(event->button == 1)
+    slider_button_press(s->slider,s->slicenum,event->x,event->y);
 
-  slider_button_press(s->slider,s->slicenum,event->x,event->y);
+  gtk_widget_grab_focus(GTK_WIDGET(s));
   return TRUE;
 }
 
 static gboolean slice_button_release(GtkWidget        *widget,
 				     GdkEventButton   *event){
   Slice *s=SLICE(widget);
-  slider_button_release(s->slider,s->slicenum,event->x,event->y);
+  if(event->button == 3)return FALSE;
+
+  if(event->button == 1)
+    slider_button_release(s->slider,s->slicenum,event->x,event->y);
+
   return TRUE;
 }
 

Modified: trunk/sushivision/slider.c
===================================================================
--- trunk/sushivision/slider.c	2006-11-17 11:32:44 UTC (rev 12122)
+++ trunk/sushivision/slider.c	2006-11-17 11:34:11 UTC (rev 12123)
@@ -636,7 +636,6 @@
     if(sl->thumb_state){
       sl->thumb_grab=1;
       sl->thumb_focus=1;
-      gtk_widget_grab_focus(GTK_WIDGET(sl));
 
       if(sl->callback)sl->callback(sl->callback_data,0);
       slider_motion(s,slicenum,x,y);



More information about the commits mailing list