1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
|
These are some general notes about hacking the gnotepad code.
Last updated: July 14th, 1999
Coding Style
------------------------------------------------------------------------------
gnp does not use the braindead GNU coding style, which is what most of
the GTK code is written in. Instead, gnp more or less sticks with the
standard K&R style. Try "indent -kr -i8" to get 98% of the desired
effect.
GTK, GNOME, etc.
------------------------------------------------------------------------------
As long as (older) gtk+-1.0.x versions are still around and supported
by the GTK folks, gnp will also support it.
Though currently, it's recommended that you use the 1.2.x versions of
GTK.
GNOME is optional.
Variables that are truly global
------------------------------------------------------------------------------
- In debug.c, long dbg_flags
- In prefs.c, app_prefs_t prefs
- Everything in appinfo.c (about a dozen char strings)
- toolbar_data_t dwl_tbdata[] (declared in doc.c, but not exported in
a .h file)
- toolbar_data_t html_tbdata[] (declared in htmltags.c, but not
exported in a .h file)
- toolbar_data_t main_tbdata[] (declared in win.c, but not exported in
a .h file)
(These last three aren't exported because I wasn't happy about making
them truly global, and when I found some time, I wanted to rethink if
there is a way to prevent them from being truly global.)
Global only within a file (that is, they are declared "static" near
the top of the file)
------------------------------------------------------------------------------
- doc.c:
- unsigned nextdocid (DEBUG only)
- htmltags.c: (most of these are just tables containing information on
what to insert and how to insert specific HTML tags)
- htmltags_t htmltags[]
- char *shape_items[]
- char *dir_items[]
- char *align_items[]
- char *ismap_items[]
- html_wgt_info_t link_page_main[]
- html_wgt_info_t link_page_core[]
- html_wgt_info_t link_page_events[]
- html_wgt_info_t link_page_extra[]
- html_wgt_info_t img_page_main[]
- html_wgt_info_t img_page_core[]
- html_wgt_info_t img_page_events[]
- html_wgt_info_t img_page_align[]
- html_wgt_info_t img_page_extra[]
- html_wgt_info_t tbl_page_main[]
- html_wgt_info_t tbl_page_core[]
- html_wgt_info_t tbl_page_events[]
- html_wgt_info_t input_page_main[]
- html_wgt_info_t input_page_core[]
- html_wgt_info_t input_page_events[]
- html_wgt_info_t input_page_misc[]
- html_wgt_info_t form_page_main[]
- html_wgt_info_t form_page_core[]
- html_wgt_info_t form_page_events[]
- html_wgt_info_t textarea_page_main[]
- html_wgt_info_t textarea_page_core[]
- html_wgt_info_t textarea_page_events[]
- html_wgt_info_t select_page_main[]
- html_wgt_info_t select_page_core[]
- html_wgt_info_t select_page_events[]
- html_wgt_info_t option_page_main[]
- html_wgt_info_t option_page_core[]
- html_wgt_info_t option_page_events[]
- html_page_t link_tag_dlg[]
- html_page_t img_tag_dlg[]
- html_page_t tbl_tag_dlg[]
- html_page_t input_tag_dlg[]
- html_page_t form_tag_dlg[]
- html_page_t textarea_tag_dlg[]
- html_page_t select_tag_dlg[]
- html_page_t option_tag_dlg[]
- toolbar_data_t html_font_tbdata[]
- toolbar_data_t html_list_tbdata[]
- toolbar_data_t html_tbl_tbdata[]
- toolbar_data_t html_form_tbdata[]
- toolbar_data_t html_frame_tbdata[]
- tblist_data_t html_tblist_data[]
- html_nfo_t hnp_data[]
- menu.c: (again, most of these are just tables for the menus)
- GnomeUIInfo html_links_menu[]
- GnomeUIInfo html_heading_menu[]
- GnomeUIInfo html_layout_menu[]
- GnomeUIInfo html_font_menu[]
- GnomeUIInfo html_list_menu[]
- GnomeUIInfo html_menu[]
- GnomeUIInfo view_html_menu[]
- GnomeUIInfo scc_menu[]
- GnomeUIInfo recent_menu[]
- GnomeUIInfo file_menu[]
- GnomeUIInfo edit_menu[]
- GnomeUIInfo project_menu[]
- GnomeUIInfo window_menu[]
- GnomeUIInfo toolbar_style_menu[]
- GnomeUIInfo toolbar_menu[]
- GnomeUIInfo doctab_pos_menu[]
- GnomeUIInfo doctab_menu[]
- GnomeUIInfo options_menu[]
- GnomeUIInfo help_menu[]
- GnomeUIInfo main_menu[]
- GtkItemFactoryEntry mainmenu[]
- GtkMenuEntry mainmenu[]
- qmenu_t qmenu[]
- micb_data_t micb_data[]
- msgbox.c
- msgbox_t msgbox
- prefs.c
- bool_t pre102
- GtkPositionType prefs_tabpos
- char *appgtkrc
- scc_info_t scc_tbl[SCC_NUM_TYPES]
- char *scc_cmd_desc[SCC_NUM_CMDS]
- prefs_t app_prefs[]
- GSList *wgtopt_list
- char *apprc
- char *gtkrc
- GtkWidget *prefs_win
- GtkWidget *prefs_nb
- GtkWidget *prefs_txt
- GList *tabpos_list
- randomtips.c
- char *tips[]
- recent.c
- char *recentrc
- win.c
- GSList *winlist
- unsigned nextid
- GtkWidget *wlw
- GtkWidget *wlw_data
- unsigned curwinrow
- guint autosave_id
Rationale
------------------------------------------------------------------------------
I tried to limit the number of truly global variables due to obvious
reasons. The most important data structures would be "win_t",
"doc_t", "app_prefs_t", and to a lesser extent, the data structures
used for the menus, the tables for the HTML tags, and the toolbar
tables.
Most, if not all, variables and major data structures should have code
comments by the variable declaration stating what they are, and how
they are used. If they are not, taking a *very* quick glance at the
source code to see where they are used should make it obvious what/how
the variable is. If it is *NOT* obvious, then I've made and mistake
and should have commented it.
C++
------------------------------------------------------------------------------
Although gnp isn't written in C++, it easily can be, and might be done
so in the future someday. Here's how to look at the data structures
from a C++ point of view:
- There would be a top level Application class, say "App".
- There should only be once instance of the App class anyway.
- "App" would have truly global identifiers as "public"
members.
- Identifiers that are global only within a file (e.g.,
declared "static" within a file) would be "private" members
to App.
- It might be possible to even make smaller objects within the
"App" class. e.g., a "Prefs" object.
- There is no need for fancy things, like inheritance,
polymorphism, and "friend" functions. Everything is pretty
much a straight forward, simple object: public and private
members.
|