[haiku-commits] r35524 - in haiku/trunk/src: add-ons/disk_systems/bfs apps/drivesetup

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 19 Feb 2010 18:22:55 +0100 (CET)

Author: axeld
Date: 2010-02-19 18:22:54 +0100 (Fri, 19 Feb 2010)
New Revision: 35524
Changeset: http://dev.haiku-os.org/changeset/35524/haiku
Ticket: http://dev.haiku-os.org/ticket/4123

Modified:
   haiku/trunk/src/add-ons/disk_systems/bfs/InitializeParameterEditor.cpp
   haiku/trunk/src/apps/drivesetup/InitParamsPanel.cpp
   haiku/trunk/src/apps/drivesetup/InitParamsPanel.h
Log:
* Applied patch by idefix that disables the "Initialize" button if the name
  field is empty. This is part of ticket #4123.
* The message constants should be moved into their own shared
  header, though; added a TODO for this.


Modified: haiku/trunk/src/add-ons/disk_systems/bfs/InitializeParameterEditor.cpp
===================================================================
--- haiku/trunk/src/add-ons/disk_systems/bfs/InitializeParameterEditor.cpp      
2010-02-19 16:52:55 UTC (rev 35523)
+++ haiku/trunk/src/add-ons/disk_systems/bfs/InitializeParameterEditor.cpp      
2010-02-19 17:22:54 UTC (rev 35524)
@@ -24,6 +24,7 @@
 
 
 static uint32 MSG_BLOCK_SIZE = 'blsz';
+static uint32 MSG_NAME_CHANGED = 'nmch';
 
 
 InitializeBFSEditor::InitializeBFSEditor()
@@ -95,6 +96,7 @@
 InitializeBFSEditor::_CreateViewControls()
 {
        fNameTC = new BTextControl("Name:", "Haiku", NULL);
+       fNameTC->SetModificationMessage(new BMessage(MSG_NAME_CHANGED));
        // TODO find out what is the max length for this specific FS partition 
name
        fNameTC->TextView()->SetMaxBytes(31);
 

Modified: haiku/trunk/src/apps/drivesetup/InitParamsPanel.cpp
===================================================================
--- haiku/trunk/src/apps/drivesetup/InitParamsPanel.cpp 2010-02-19 16:52:55 UTC 
(rev 35523)
+++ haiku/trunk/src/apps/drivesetup/InitParamsPanel.cpp 2010-02-19 17:22:54 UTC 
(rev 35524)
@@ -4,9 +4,10 @@
  *
  * Authors:
  *             Stephan Aßmus <superstippi@xxxxxx>
-*              Karsten Heimrich. <host.haiku@xxxxxx>
+ *             Karsten Heimrich. <host.haiku@xxxxxx>
  */
 
+
 #include "InitParamsPanel.h"
 
 #include <driver_settings.h>
@@ -20,6 +21,7 @@
 #include <Message.h>
 #include <MessageFilter.h>
 #include <String.h>
+#include <TextControl.h>
 
 
 #define TR_CONTEXT "InitParamsPanel"
@@ -67,10 +69,13 @@
 // #pragma mark -
 
 
+// TODO: MSG_NAME_CHANGED is shared with the disk system add-ons, so it should
+// be in some private shared header.
+// TODO: there is already B_CANCEL, why not use that one?
 enum {
        MSG_OK                                          = 'okok',
        MSG_CANCEL                                      = 'cncl',
-       MSG_BLOCK_SIZE                          = 'blsz'
+       MSG_NAME_CHANGED                        = 'nmch'
 };
 
 
@@ -87,7 +92,7 @@
 {
        AddCommonFilter(fEscapeFilter);
 
-       BButton* okButton = new BButton(TR("Initialize"), new BMessage(MSG_OK));
+       fOkButton = new BButton(TR("Initialize"), new BMessage(MSG_OK));
 
        partition->GetInitializationParameterEditor(diskSystem.String(),
                &fEditor);
@@ -99,12 +104,12 @@
                .AddGroup(B_HORIZONTAL, spacing)
                        .AddGlue()
                        .Add(new BButton(TR("Cancel"), new 
BMessage(MSG_CANCEL)))
-                       .Add(okButton)
+                       .Add(fOkButton)
                .End()
                .SetInsets(spacing, spacing, spacing, spacing)
        );
 
-       SetDefaultButton(okButton);
+       SetDefaultButton(fOkButton);
 
        // If the partition had a previous name, set to that name.
        BString name = partition->ContentName();
@@ -145,6 +150,19 @@
                        release_sem(fExitSemaphore);
                        break;
 
+               case MSG_NAME_CHANGED:
+                       // message comes from fEditor's BTextControl
+                       BTextControl* control;
+                       if (message->FindPointer("source", (void**)&control) != 
B_OK)
+                               break;
+                       if (control->TextView()->TextLength() == 0
+                               && fOkButton->IsEnabled())
+                               fOkButton->SetEnabled(false);
+                       else if (control->TextView()->TextLength() > 0
+                               && !fOkButton->IsEnabled())
+                               fOkButton->SetEnabled(true);
+                       break;
+
                default:
                        BWindow::MessageReceived(message);
        }

Modified: haiku/trunk/src/apps/drivesetup/InitParamsPanel.h
===================================================================
--- haiku/trunk/src/apps/drivesetup/InitParamsPanel.h   2010-02-19 16:52:55 UTC 
(rev 35523)
+++ haiku/trunk/src/apps/drivesetup/InitParamsPanel.h   2010-02-19 17:22:54 UTC 
(rev 35524)
@@ -36,6 +36,7 @@
                        EscapeFilter*           fEscapeFilter;
                        sem_id                          fExitSemaphore;
                        BWindow*                        fWindow;
+                       BButton*                        fOkButton;
                        int32                           fReturnValue;
 
                        BPartitionParameterEditor*      fEditor;


Other related posts:

  • » [haiku-commits] r35524 - in haiku/trunk/src: add-ons/disk_systems/bfs apps/drivesetup - axeld