2
0

WmSetTitle.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $XConsortium: WmSetTitle.c /main/6 1996/05/20 16:08:13 drk $
  24. *
  25. * (c) Copyright 1996 Digital Equipment Corporation.
  26. * (c) Copyright 1993,1994,1996 Hewlett-Packard Company.
  27. * (c) Copyright 1993,1994,1996 International Business Machines Corp.
  28. * (c) Copyright 1993,1994,1996 Sun Microsystems, Inc.
  29. * (c) Copyright 1993,1994,1996 Novell, Inc.
  30. * (c) Copyright 1996 FUJITSU LIMITED.
  31. * (c) Copyright 1996 Hitachi.
  32. */
  33. /************************************<+>*************************************
  34. ****************************************************************************
  35. **
  36. ** File: WmSetTitle.c
  37. **
  38. ** Project: DT Workspace Manager
  39. **
  40. ** Description: Set the title for a workspace
  41. **
  42. ****************************************************************************
  43. ************************************<+>*************************************/
  44. #include <stdio.h>
  45. #include <X11/Intrinsic.h>
  46. #include <Dt/Wsm.h>
  47. #include <Dt/WsmP.h>
  48. #include <Dt/WsmM.h>
  49. #include <Dt/Service.h>
  50. #include <Xm/Xm.h>
  51. #include <Xm/AtomMgr.h>
  52. #include <Tt/tttk.h>
  53. /*************************************<->*************************************
  54. *
  55. * int DtWsmSetWorkspaceTitle (widget, aWs, pchNewName)
  56. *
  57. *
  58. * Description:
  59. * -----------
  60. * Rename a workspace
  61. *
  62. *
  63. * Inputs:
  64. * ------
  65. * widget - a widget
  66. * aWs - atom of workspace
  67. * pchNewName - new name for the workspace
  68. *
  69. * Outputs:
  70. * --------
  71. * Return - Success if communication to workspace manager
  72. * was successful. Note that this is *not* the same
  73. * value _DtWsmSetWorkspaceTitle returns.
  74. *
  75. * Comments:
  76. * ---------
  77. * public interface to _DtWsmSetWorkspaceTitle()
  78. *
  79. *************************************<->***********************************/
  80. int
  81. DtWsmSetWorkspaceTitle (
  82. Widget widget,
  83. Atom aWs,
  84. char * pchNewName)
  85. {
  86. int rcode = _DtWsmSetWorkspaceTitle(widget, aWs, pchNewName);
  87. if (rcode == DT_SVC_SUCCESS)
  88. return Success;
  89. else /* rcode == DT_SVC_FAIL || rcode == dtmsg_FAIL */
  90. return rcode;
  91. }
  92. /*************************************<->*************************************
  93. *
  94. * int _DtWsmSetWorkspaceTitle (widget, aWs, pchNewName)
  95. *
  96. *
  97. * Description:
  98. * -----------
  99. * Rename a workspace
  100. *
  101. *
  102. * Inputs:
  103. * ------
  104. * widget - a widget
  105. * aWs - atom of workspace
  106. * pchNewName - new name for the workspace
  107. *
  108. * Outputs:
  109. * --------
  110. * Return - 1 (*not* Success) if communication to workspace manager
  111. * was successful.
  112. *
  113. * Comments:
  114. * ---------
  115. * The odd-ball successful return value is a CDE 1.0 bug being
  116. * preserved for backward compatibility.
  117. *
  118. *************************************<->***********************************/
  119. int
  120. _DtWsmSetWorkspaceTitle (
  121. Widget widget,
  122. Atom aWs,
  123. char * pchNewName)
  124. {
  125. Tt_status status;
  126. Tt_message msg;
  127. char pch[40];
  128. sprintf (pch, "0x%lx", aWs);
  129. msg = tttk_message_create(0, TT_REQUEST, TT_SESSION, 0,
  130. "DtWorkspace_Title_Set", 0);
  131. status = tt_ptr_error(msg);
  132. if (status != TT_OK) {
  133. return DT_SVC_FAIL;
  134. }
  135. status = tt_message_arg_add(msg, TT_IN, "integer", NULL);
  136. if (status != TT_OK) {
  137. return DT_SVC_FAIL;
  138. }
  139. status = tt_message_arg_ival_set(msg, 0,
  140. XScreenNumberOfScreen(XtScreen(widget)) % 1000);
  141. if (status != TT_OK) {
  142. return DT_SVC_FAIL;
  143. }
  144. status = tt_message_arg_add(msg, TT_IN, Tttk_string, pch);
  145. if (status != TT_OK) {
  146. return DT_SVC_FAIL;
  147. }
  148. status = tt_message_arg_add(msg, TT_IN, Tttk_string, pchNewName);
  149. if (status != TT_OK) {
  150. return DT_SVC_FAIL;
  151. }
  152. status = tt_message_callback_add(msg, _DtWsmConsumeReply);
  153. if (status != TT_OK) {
  154. return dtmsg_FAIL;
  155. }
  156. status = tt_message_send(msg);
  157. if (status != TT_OK) {
  158. return DT_SVC_FAIL;
  159. }
  160. return DT_SVC_SUCCESS;
  161. } /* END OF FUNCTION DtWsmSetWorkspaceTitle */