Discussion:
[Bitpim-devel] BitPim Mac Menus
Adit Panchal
2004-05-02 20:20:51 UTC
Permalink
I was tinkering around with the code and realized that on the Mac, that
some of the standard menus aren't in the right places (i.e, About and
Preferences).

I wrote some additional code that fixes the About menu position and
removes the separator bar if it is run on a Mac. I also tried doing the
Preferences, but for the life of me, I couldn't get it to work on this
code. I hacked up another Python script that just sets up menus and
added the Mac specific code there and it worked perfectly. For some
reason the Preferences setting does not work with the BitPim code.

Anyways, I think if this code is added, it would make the Mac build
feel more conforming with the OS.

Attached is my diff. If anyone wants my test code, please let me know
and I can send it.

I am currently trying to work on exporting the phonebook to a CSV. If
it is not necessary, please let me know.

Thanks for the good work :)

Index: gui.py
===================================================================
RCS file: /cvsroot/bitpim/bitpim/gui.py,v
retrieving revision 1.124
diff -u -r1.124 gui.py
--- gui.py 1 May 2004 07:57:49 -0000 1.124
+++ gui.py 2 May 2004 19:41:21 -0000
@@ -407,7 +407,11 @@
menu.AppendSeparator()
menu.Append(guihelper.ID_FV_ICONS, "View as Images", "Show
items as images")
menu.Append(guihelper.ID_FV_LIST, "View As List", "Show
items as a report")
- menu.AppendSeparator()
+ if guihelper.IsMac():
+
wx.App_SetMacPreferencesMenuItemId(guihelper.ID_EDITSETTINGS)
+ print wx.App_GetMacPreferencesMenuItemId()
+ else:
+ menu.AppendSeparator()
menu.Append(guihelper.ID_EDITSETTINGS, "&Settings", "Edit
settings")
menuBar.Append(menu, "&Edit");

@@ -427,10 +431,20 @@


menu=wx.Menu()
- menu.Append(guihelper.ID_HELPHELP, "&Help", "Help for the
panel you are looking at")
+ if guihelper.IsMac():
+ menu.Append(guihelper.ID_HELPHELP, "&BitPim Help", "Help
for the panel you are looking at")
+ menu.AppendSeparator()
+ else:
+ menu.Append(guihelper.ID_HELPHELP, "&Help", "Help for the
panel you are looking at")
menu.Append(guihelper.ID_HELPTOUR, "&Tour", "Tour of BitPim")
menu.Append(guihelper.ID_HELPCONTENTS, "&Contents", "Table of
contents for the online help")
- menu.AppendSeparator()
+ if guihelper.IsMac():
+ wx.App_SetMacAboutMenuItemId(guihelper.ID_HELPABOUT)
+ wx.App_SetMacHelpMenuTitleName("&Help")
+ wx.App_SetMacExitMenuItemId(guihelper.ID_FILEEXIT)
+ #print wx.App_GetMacAboutMenuItemId()
+ else:
+ menu.AppendSeparator()
menu.Append(guihelper.ID_HELPABOUT, "&About", "Display program
information")
menuBar.Append(menu, "&Help");
Roger Binns
2004-05-03 05:52:32 UTC
Permalink
Post by Adit Panchal
Anyways, I think if this code is added, it would make the Mac build
feel more conforming with the OS.
Steven deals with the Mac side so we will get feedback from him soon.
Post by Adit Panchal
I am currently trying to work on exporting the phonebook to a CSV. If
it is not necessary, please let me know.
A lot of people have asked for it :-) I would love for someone to deal
with all the import and export code. I would also prefer if you give
us patches early and frequently. That way others can help and provide
feedback. (My main rule is that the software should not be stupid. I
also have an idea in my head as to how this stuff should work, but code
rules over talk :-)

Roger
Steven Palm
2004-05-03 14:08:26 UTC
Permalink
Post by Roger Binns
Post by Adit Panchal
Anyways, I think if this code is added, it would make the Mac build
feel more conforming with the OS.
Steven deals with the Mac side so we will get feedback from him soon.
I was aware of that and at this point I was straddling the line
between having things be in the same place on each version and being
"Mac-like". I guess you've pushed me over to be more "Mac-like", so
I'll put the changes in. ;-)
Roger Binns
2004-05-03 20:23:34 UTC
Permalink
Post by Steven Palm
I was aware of that and at this point I was straddling the line
between having things be in the same place on each version and being
"Mac-like". I guess you've pushed me over to be more "Mac-like", so
I'll put the changes in. ;-)
My preference is for the program to behave as the users on each
platform expect and consider normal. For most, the fact that
it is available for other platforms is irrelevant and I don't
see much value in making it behave in a lowest common denominator
fashion.

That said, as a developer I prefer as little platform specific
code as possible as it is more difficult to maintain. However
the usability experience ultimately trumps the developer
experience in my book.

Roger
Adit Panchal
2004-05-03 20:37:06 UTC
Permalink
Good to hear. I did re-inspect my changes and found that the Quit
command was showing up on the File menu. I made the necessary fix and
it should now only show up on the Application menu (with the File menu
command and separator removed).

I was also wondering what would be the status for accelerator keys? Is
that something to be implemented down the road?

As to my CVS export code, it is coming along - I am currently trying to
figure out how to write the phonebook dict to a list or lists. The
exportDSV function expects a list and I was stepping through the
existing code trying to figure out the best way to get the data out
into a usable form.

Adit
Roger Binns
2004-05-04 01:43:17 UTC
Permalink
Post by Adit Panchal
I was also wondering what would be the status for accelerator keys? Is
that something to be implemented down the road?
As far as I know, you just put the key sequence in the string for the menu
item:

menu.Append(ID_SAVE, "Save\tCtrl+S")

That will automatically bind Ctrl+S to the menu item. Is there anything
you do often enough with the menus to justify an accelerator key?
Post by Adit Panchal
As to my CVS export code, it is coming along - I am currently trying to
figure out how to write the phonebook dict to a list or lists.
Given a list of column headers, you can call phonebook.getdata
to get the relevant field.

For example:

phonebook.getdata("Cell2", entry, "")
phonebook.getdata("Name", entry, "")

The full list of column names is phonebook.AvailableColumns.

I would expect the exporting UI to look similar to the importing
UI. You should be able to select one of the predefined column
types (Palm Desktop, Mozilla etc) or define your own and the
order they go in.

The columns offered should be importexport.ImportCSVDialog.possiblecolumns.
You will need a mapping table between those names and the ones used
by BitPim in the phonebook module.

Roger
Adit Panchal
2004-05-04 02:46:53 UTC
Permalink
Post by Roger Binns
As far as I know, you just put the key sequence in the string for the menu
menu.Append(ID_SAVE, "Save\tCtrl+S")
That will automatically bind Ctrl+S to the menu item. Is there anything
you do often enough with the menus to justify an accelerator key?
Not really, so I suppose it isn't necessary. Just figured we should
have an alternate way to do things, if necessary. :) But thanks for the
tip - I will keep that in mind for future projects.
Post by Roger Binns
Given a list of column headers, you can call phonebook.getdata
to get the relevant field.
phonebook.getdata("Cell2", entry, "")
phonebook.getdata("Name", entry, "")
The full list of column names is phonebook.AvailableColumns.
I would expect the exporting UI to look similar to the importing
UI. You should be able to select one of the predefined column
types (Palm Desktop, Mozilla etc) or define your own and the
order they go in.
The columns offered should be
importexport.ImportCSVDialog.possiblecolumns.
You will need a mapping table between those names and the ones used
by BitPim in the phonebook module.
Roger
Actually I already finished the parsing of the phonebook. I did use the
phonebook.getdata() function, but I ended up finding a way to just go
through the whole dict and get what I needed out of it. It works, but
if it is unacceptable, I can change it.

Right now, I am using hard-coded Mozilla address-book columns to
export, and it works (currently it just prints to the console, but that
output imports perfectly into Mozilla Thunderbird). I just have to
write the code to output the CSV to a file. Other than that, the only
remaining thing to do is write the gui and put in user-defined options
as you listed above. If you want, I can attach the stuff I have done,
so if anyone wants to test the parsing routines. I guess I'll do that
when I have it able to save to a file.

Adit
Roger Binns
2004-05-04 03:15:36 UTC
Permalink
Post by Adit Panchal
Right now, I am using hard-coded Mozilla address-book columns to
export,
There are field definitions in the pdc files in the resources
directory. They use the names from the importexport module to
define the fields, which is why a mapping table is needed.
Post by Adit Panchal
I just have to
write the code to output the CSV to a file.
As you surmised, that is fairly easy.
Post by Adit Panchal
Other than that, the only
remaining thing to do is write the gui and put in user-defined options
as you listed above.
The gui is definitely the hard part. Please put your code in the
importexport module and structure it in the same way as the import
dialog. You can probably steal some code from the import dialog
as well (such as getting the list of pre-defined column sets).

Don't worry about trying to share code between them yet. Get
it working first, and then worry about a common parent class
and stuff like that.
Post by Adit Panchal
If you want, I can attach the stuff I have done,
so if anyone wants to test the parsing routines. I guess I'll do that
when I have it able to save to a file.
That would be good.

Roger

Loading...