summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--doc/ttk_style.n8
-rw-r--r--generic/ttk/ttkTheme.c43
3 files changed, 50 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index d8aefff..6d4c09d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-05-27 Pat Thoyts <patthoyts@users.sourceforge.net>
+
+ * generic/ttk/ttkTheme.c: [ttk::style theme use] without
+ * doc/ttk_style.n: an argument now returns the current theme
+
2008-05-23 Joe English <jenglish@users.sourceforge.net>
* doc/ttk_treeview.n, generic/ttk/ttkTreeview.c,
diff --git a/doc/ttk_style.n b/doc/ttk_style.n
index 0fc1e92..77d1385 100644
--- a/doc/ttk_style.n
+++ b/doc/ttk_style.n
@@ -4,7 +4,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: ttk_style.n,v 1.14 2008/04/09 09:28:05 patthoyts Exp $
+'\" RCS: @(#) $Id: ttk_style.n,v 1.15 2008/05/27 20:47:16 patthoyts Exp $
'\"
.so man.macros
.TH ttk::style n 8.5 Tk "Tk Themed Widget"
@@ -86,8 +86,10 @@ though arbitrary Tcl code may appear.
\fBttk::style theme names\fR
Returns a list of all known themes.
.TP
-\fBttk::style theme use\fR \fIthemeName\fR
-Sets the current theme to \fIthemeName\fR, and refreshes all widgets.
+\fBttk::style theme use\fR ?\fIthemeName\fR?
+Without an argument the result is the name of the current theme.
+Otherwise this command sets the current theme to \fIthemeName\fR,
+and refreshes all widgets.
.SH LAYOUTS
A \fIlayout\fR specifies a list of elements, each followed
by one or more options specifying how to arrange the element.
diff --git a/generic/ttk/ttkTheme.c b/generic/ttk/ttkTheme.c
index 45049b6..252c082 100644
--- a/generic/ttk/ttkTheme.c
+++ b/generic/ttk/ttkTheme.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * $Id: ttkTheme.c,v 1.13 2008/05/23 20:20:05 jenglish Exp $
+ * $Id: ttkTheme.c,v 1.14 2008/05/27 20:47:20 patthoyts Exp $
*/
#include <stdlib.h>
@@ -1334,6 +1334,39 @@ static int StyleLookupCmd(
return TCL_OK;
}
+static int StyleThemeCurrentCmd(
+ ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[])
+{
+ StylePackageData *pkgPtr = (StylePackageData *)clientData;
+ Tcl_HashSearch search;
+ Tcl_HashEntry *entryPtr = NULL;
+ const char *name = NULL;
+
+ if (objc != 3) {
+ Tcl_WrongNumArgs(interp, 3, objv, "");
+ return TCL_ERROR;
+ }
+
+ entryPtr = Tcl_FirstHashEntry(&pkgPtr->themeTable, &search);
+ while (entryPtr != NULL) {
+ Theme *ptr = (Theme *)Tcl_GetHashValue(entryPtr);
+ if (ptr == pkgPtr->currentTheme) {
+ name = Tcl_GetHashKey(&pkgPtr->themeTable, entryPtr);
+ break;
+ }
+ entryPtr = Tcl_NextHashEntry(&search);
+ }
+
+ if (name == NULL) {
+ Tcl_SetObjResult(interp,
+ Tcl_NewStringObj("error: failed to get theme name", -1));
+ return TCL_ERROR;
+ }
+
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(name, -1));
+ return TCL_OK;
+}
+
/* + style theme create name ?-parent $theme? ?-settings { script }?
*/
static int StyleThemeCreateCmd(
@@ -1572,11 +1605,15 @@ StyleThemeUseCmd(
StylePackageData *pkgPtr = clientData;
Ttk_Theme theme;
- if (objc != 4) {
- Tcl_WrongNumArgs(interp, 3, objv, "theme");
+ if (objc < 3 || objc > 4) {
+ Tcl_WrongNumArgs(interp, 3, objv, "?theme?");
return TCL_ERROR;
}
+ if (objc == 3) {
+ return StyleThemeCurrentCmd(clientData, interp, objc, objv);
+ }
+
theme = LookupTheme(interp, pkgPtr, Tcl_GetString(objv[3]));
if (!theme) {
return TCL_ERROR;