Subject: FVWM: fvwmtabs - named tabbers (patch)

From: Micha Feigin <[email-masked]>
Date: Mon, 21 Jun 2004 19:45:32 +0300

Hi,

I was missing a feature to be able to create named tabbers instead of
numbered tabs. This is useful for auto swallow so you don't have to
depend on the ordering of opening the tabbers. Attached is a patch that
implements that. Unamed new tabbers still get number names as before
(the change was quite minimal thanks to using a hash in the original
code ;-)

The syntax is
SendToModule FvwmTabs createNewTabber <name>
*FvwmTabs: autoSwallow(Class|Name|Resource) <appname> <tabber name>

so for example to create a tabber named vim and auto swallow gvim into
it:

SendToModule FvwmTabs createNewTabber vim
*FvwmTabs: autoSwallowClass Gvim vim

If anyone else was missing that also, enjoy
--- FvwmTabs	2004-06-06 15:03:59.000000000 +0300
+++ /usr/lib/fvwm/2.5.10/FvwmTabs	2004-06-20 22:06:03.000000000 +0300
@@ -303,7 +303,7 @@
 	my ($type) = @_;
 	foreach (split(/,/, $pConfig->{'autoSwallow' . $type}))
 	{
-		if (!/^\s*(.+?)(\s+(\d+|any|lastFocus))?\s*$/i)
+		if (!/^\s*(.+?)(\s+(\S+|any|lastFocus))?\s*$/i)
 		{
 			print(STDERR $fvwm->name() . ": unparseable autoSwallow$type.\n");
 			next;
@@ -415,10 +415,29 @@
 
 sub createNewTabber ()
 {
-	my $tId;
-	for ($tId = 0; ; $tId++)
+	my $tId = shift;
+
+	if (defined($tId))
 	{
-		last if (!defined($tabWin{$tId}));
+		my $errmsg;
+
+		$errmsg = "Only tabber name allowed as parameter" if (defined($_[0]));
+		$errmsg = "any,lastFocus,-1 names are reserved" if ($tId =~ /any|lastfocus|-1/i);
+		$errmsg = "Tabber by that name already exists!" if (defined($tabWin{$tId}));
+		
+		if (defined($errmsg))
+		{
+			$fvwm->send("Beep");
+			$fvwm->showError($errmsg);
+			return;
+		}
+	}
+	else
+	{
+		for ($tId = 0; ; $tId++)
+		{
+			last if (!defined($tabWin{$tId}));
+		}
 	}
 
 	my $title = $fvwm->name() . " [$tId]";
@@ -892,7 +911,7 @@
 			$tId = $_, last if ($tabWin{$_}{parent} == $event{window});
 		}
 
-		return if ($tId < 0);
+		return if ($tId == -1);
 
 		my $h = $tabWin{$tId}{winFrame}->height();
 		# resize the $winFrame widget. Can't use $w->configure(-height ...)
@@ -927,7 +946,7 @@
 			$tId = $_, last if (getWrapperWinId($_) == $event{event});
 		}
 
-		print(STDERR "BUG: EnterNotify\n"), return if ($tId < 0);
+		print(STDERR "BUG: EnterNotify\n"), return if ($tId == -1);
 		$tabWin{$tId}{focusTimestamp} = $event{time};
 		$fvwm->debug("focusTimestamp set to $tabWin{$tId}{focusTimestamp}");
 		takeFocus($tId);

---

From: Scott Smedley <[email-masked]>
Date: Wed, 23 Jun 2004 23:06:44 +1000

Hi Micha,

> implements that.

Great, thanks! Applied (with a few mods) & available in FvwmTabs v3.2.

> Unamed new tabbers still get number names as before

Yup, what good design hey! :)

> If anyone else was missing that also, enjoy

Yep, a couple of other people have asked for this feature.

As a general rule, patches/bugfixes are best sent to the fvwm-workers
list. Many people on the fvwm list aren't interested in such posts.

SCoTT. :)
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].