Skip to content

Commit b1d01b1

Browse files
authored
Merge pull request #100 from MIERUNE/fix/icon-to-plugin-toolbar
Icon to plugin toolbar
2 parents 3db266c + 58bbd2f commit b1d01b1

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

gtfs_go.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ def __init__(self, iface):
3939
# Declare instance attributes
4040
self.actions = []
4141
self.menu = self.tr("&GTFS GO")
42-
# TODO: We are going to let the user set this up in a future iteration
43-
self.toolbar = self.iface.addToolBar("GTFSGo")
44-
self.toolbar.setObjectName("GTFSGo")
4542

4643
# print "** INITIALIZING GTFSGo"
4744

@@ -71,7 +68,7 @@ def add_action(
7168
callback,
7269
enabled_flag=True,
7370
add_to_menu=True,
74-
add_to_toolbar=True,
71+
add_to_plugin_toolbar=True,
7572
status_tip=None,
7673
whats_this=None,
7774
parent=None,
@@ -96,9 +93,9 @@ def add_action(
9693
be added to the menu. Defaults to True.
9794
:type add_to_menu: bool
9895
99-
:param add_to_toolbar: Flag indicating whether the action should also
100-
be added to the toolbar. Defaults to True.
101-
:type add_to_toolbar: bool
96+
:param add_to_plugin_toolbar: Flag indicating whether the action should also
97+
be added to the plugin toolbar. Defaults to True.
98+
:type add_to_plugin_toolbar: bool
10299
103100
:param status_tip: Optional text to show in a popup when mouse pointer
104101
hovers over the action.
@@ -126,12 +123,12 @@ def add_action(
126123
if whats_this is not None:
127124
action.setWhatsThis(whats_this)
128125

129-
if add_to_toolbar:
130-
self.toolbar.addAction(action)
131-
132126
if add_to_menu:
133127
self.iface.addPluginToWebMenu(self.menu, action)
134128

129+
if add_to_plugin_toolbar:
130+
self.iface.addToolBarIcon(action)
131+
135132
self.actions.append(action)
136133

137134
return action
@@ -146,6 +143,7 @@ def initGui(self):
146143
callback=self.run,
147144
parent=self.iface.mainWindow(),
148145
add_to_menu=True,
146+
add_to_plugin_toolbar=True,
149147
)
150148

151149
# --------------------------------------------------------------------------
@@ -174,8 +172,6 @@ def unload(self):
174172
for action in self.actions:
175173
self.iface.removePluginWebMenu(self.tr("&GTFS GO"), action)
176174
self.iface.removeToolBarIcon(action)
177-
# remove the toolbar
178-
del self.toolbar
179175

180176
# --------------------------------------------------------------------------
181177

0 commit comments

Comments
 (0)