On Friday 21 March 2008 17:23:13 Hannu Savolainen wrote:
> Hannu Savolainen wrote:
> I added a new ioctl call
> (http://manuals.opensound.com/developer/SNDCTL_MIX_DESCRIPTION.html) to
> the hg version. There is also a new MIXF_DESCR flag that tells if a
> mixer control has descriptive text available.
>

> I also modified ossxmix to show the texts but it looks like it doesn't
> work yet (at least not under GTK+ versions before 2.12). 

I tested with a fake description ("strcpy(ei.strings,"... ). GTK 2.12+ is 
usually fine. It works only on some widgets in GTK < 2.12, maybe because of 
this restriction (from GtkTooltips.html):
"Tooltips can only be set on widgets which have their own X window and
  receive enter and leave events." (They than prescribe a test which doesn't 
work at all, and a workaround which is too messy to apply).

I suggest the attached diff to simplify check_tooltips a bit. (I don't 
understand why char *p is needed in check_tooltips() - it doesn't look like 
there's a way to access the "private tooltips", so it's unneccesary).

> The vmixN-src control in most mixers has a description defined.
I can't see any description for vmixN-src in the diff.

Yours,
        Yair K.

--- cmd/ossxmix/ossxmix.c	2008-04-21 18:50:51.636021088 +0300
+++ cmd/ossxmix/ossxmix.c	2008-04-21 20:12:26.554023206 +0300
@@ -141,6 +141,7 @@
 static gint add_timeout (gpointer);
 static void change_enum (GtkToggleButton *, gpointer);
 static void change_on_off (GtkToggleButton *, gpointer);
+static void check_tooltip (oss_mixext *, GtkWidget *);
 static void cleanup (void);
 static gint close_request (GtkWidget *, gpointer);
 static void connect_enum (oss_mixext *, GtkObject *);
@@ -186,10 +187,9 @@
 #endif /* STATUSICON */
 
 static void
-check_tooltip(oss_mixext *rec, GtkWidget *wid)
+check_tooltip (oss_mixext *rec, GtkWidget *wid)
 {
   oss_mixer_enuminfo ei;
-  char *p;
 
   if (!(rec->flags & MIXF_DESCR)) /* No description available */
      return;
@@ -200,23 +200,14 @@
   if (ioctl (mixer_fd, SNDCTL_MIX_DESCRIPTION, &ei) == -1)
      return;
 
-  p=ei.strings;
-
-  while (*p && *p != '\n') p++; /* Find a line feed */
-
-  if (*p=='\n')
-     *p++=0;
-  if (*p==0)
-     p=NULL;
-
 #if GTK_CHECK_VERSION(2,12,0)
   gtk_widget_set_tooltip_text(wid, ei.strings);
 #else
   {
-	  GtkTooltips *tip;
+	  static GtkTooltips *tip = NULL;
 
-	  tip = gtk_tooltips_new();
-	  gtk_tooltips_set_tip(tip, wid, ei.strings, p);
+	  if (tip == NULL) tip = gtk_tooltips_new();
+	  gtk_tooltips_set_tip(tip, wid, ei.strings, NULL);
   }
 #endif
 }
_______________________________________________
oss-devel mailing list
oss-devel@mailman.opensound.com
http://mailman.opensound.com/mailman/listinfo/oss-devel

Reply via email to