diff --git a/pw3270.cbp b/pw3270.cbp
index 59a6274..a76a1a7 100644
--- a/pw3270.cbp
+++ b/pw3270.cbp
@@ -73,6 +73,9 @@
+
+
+
diff --git a/src/include/pw3270/actions.h b/src/include/pw3270/actions.h
index 1392af1..492c299 100644
--- a/src/include/pw3270/actions.h
+++ b/src/include/pw3270/actions.h
@@ -56,6 +56,15 @@
const gchar * pw3270_action_get_name(GAction *action);
void pw3270_action_set_name(GAction *action, const gchar *name);
+ /// @brief Get the action icon name.
+ const gchar * pw3270_action_get_icon_name(GAction *action);
+
+ /// @brief Get the action label.
+ const gchar * pw3270_action_get_label(GAction *action);
+
+ /// @brief Get the action tooltip.
+ const gchar * pw3270_action_get_tooltip(GAction *action);
+
/// @brief Associate action with the terminal widget.
void pw3270_action_set_terminal_widget(GAction *action, GtkWidget *terminal);
diff --git a/src/include/pw3270/toolbar.h b/src/include/pw3270/toolbar.h
index bfb5d9c..0d8e546 100644
--- a/src/include/pw3270/toolbar.h
+++ b/src/include/pw3270/toolbar.h
@@ -52,8 +52,12 @@
typedef struct _pw3270ToolBar pw3270ToolBar;
typedef struct _pw3270ToolBarClass pw3270ToolBarClass;
+ GType pw3270ToolBar_get_type(void) G_GNUC_CONST;
+
GtkWidget * pw3270_toolbar_new(void);
+
GtkWidget * pw3270_toolbar_insert_lib3270_action(GtkWidget *toolbar, const LIB3270_ACTION *action, gint pos);
+ GtkWidget * pw3270_toolbar_insert_action(GtkWidget *toolbar, GAction *action, gint pos);
G_END_DECLS
diff --git a/src/objects/actions/abstract.c b/src/objects/actions/abstract.c
index f833f5d..c6858bd 100644
--- a/src/objects/actions/abstract.c
+++ b/src/objects/actions/abstract.c
@@ -42,6 +42,7 @@
static gboolean get_enabled(GAction *action, GtkWidget *terminal);
static void activate(GAction *action, GVariant *parameter, GtkWidget *terminal);
static void change_widget(GAction *action, GtkWidget *from, GtkWidget *to);
+ static const gchar *get_null(GAction *action);
static void finalize(GObject *object);
@@ -95,6 +96,9 @@
klass->get_enabled = get_enabled;
klass->activate = activate;
klass->get_parameter_type = get_parameter_type;
+ klass->get_icon_name = get_null;
+ klass->get_label = get_null;
+ klass->get_tooltip = get_null;
object_class->finalize = finalize;
object_class->set_property = pw3270_action_set_property;
@@ -409,3 +413,30 @@
void activate(GAction *action, GVariant G_GNUC_UNUSED(*parameter), GtkWidget G_GNUC_UNUSED(*terminal)) {
g_message("Action %s can't be activated",pw3270_action_get_name(action));
}
+
+ const gchar * get_null(GAction G_GNUC_UNUSED(*action)) {
+ return NULL;
+ }
+
+ const gchar * pw3270_action_get_icon_name(GAction *action) {
+ return PW3270_ACTION_GET_CLASS(action)->get_icon_name(action);
+ }
+
+ const gchar * pw3270_action_get_label(GAction *action) {
+ const gchar * label = PW3270_ACTION_GET_CLASS(action)->get_label(action);
+
+ if(label)
+ return gettext(label);
+
+ return NULL;
+ }
+
+ const gchar * pw3270_action_get_tooltip(GAction *action) {
+ const gchar * tooltip = PW3270_ACTION_GET_CLASS(action)->get_tooltip(action);
+
+ if(tooltip)
+ return gettext(tooltip);
+
+ return NULL;
+ }
+
diff --git a/src/objects/actions/lib3270/action.c b/src/objects/actions/lib3270/action.c
index c307e20..b8b3c96 100644
--- a/src/objects/actions/lib3270/action.c
+++ b/src/objects/actions/lib3270/action.c
@@ -66,10 +66,22 @@
}
- static void activate(GAction *action, GVariant *parameter, GtkWidget *terminal) {
+ static void activate(GAction *action, GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) {
PW3270_LIB3270_ACTION(action)->definition->activate(v3270_get_session(terminal));
}
+ static const gchar * get_icon_name(GAction *action) {
+ return PW3270_LIB3270_ACTION(action)->definition->icon;
+ }
+
+ const gchar * get_label(GAction *action) {
+ return PW3270_LIB3270_ACTION(action)->definition->label;
+ }
+
+ const gchar * get_tooltip(GAction *action) {
+ return PW3270_LIB3270_ACTION(action)->definition->summary;
+ }
+
void Lib3270Action_class_init(Lib3270ActionClass *klass) {
pw3270ActionClass * action = PW3270_ACTION_CLASS(klass);
@@ -77,10 +89,13 @@
action->activate = activate;
action->get_enabled = get_enabled;
action->change_widget = change_widget;
+ action->get_icon_name = get_icon_name;
+ action->get_label = get_label;
+ action->get_tooltip = get_tooltip;
}
- void Lib3270Action_init(Lib3270Action *action) {
+ void Lib3270Action_init(Lib3270Action G_GNUC_UNUSED(*action)) {
}
GAction * pw3270_action_new_from_lib3270(const LIB3270_ACTION * definition) {
diff --git a/src/objects/actions/private.h b/src/objects/actions/private.h
index c49e3a8..0a524b2 100644
--- a/src/objects/actions/private.h
+++ b/src/objects/actions/private.h
@@ -73,6 +73,9 @@
gboolean (*get_enabled)(GAction *action, GtkWidget *terminal);
void (*activate)(GAction *action, GVariant *parameter, GtkWidget *terminal);
const GVariantType * (*get_parameter_type)(GAction *action);
+ const gchar * (*get_icon_name)(GAction *action);
+ const gchar * (*get_label)(GAction *action);
+ const gchar * (*get_tooltip)(GAction *action);
};
diff --git a/src/objects/toolbar/actions.c b/src/objects/toolbar/actions.c
new file mode 100644
index 0000000..0d7bb2c
--- /dev/null
+++ b/src/objects/toolbar/actions.c
@@ -0,0 +1,62 @@
+/*
+ * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
+ * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
+ * aplicativos mainframe. Registro no INPI sob o nome G3270.
+ *
+ * Copyright (C) <2008>
+ *
+ * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
+ * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
+ * Free Software Foundation.
+ *
+ * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
+ * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
+ * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
+ * obter mais detalhes.
+ *
+ * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
+ * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
+ * St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Este programa está nomeado como - e possui - linhas de código.
+ *
+ * Contatos:
+ *
+ * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
+ * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
+ *
+ */
+
+ #include "private.h"
+ #include
+
+ GtkWidget * pw3270_toolbar_insert_action(GtkWidget *toolbar, GAction *action, gint pos) {
+
+ debug("toolbar=%p action=%p",toolbar,action);
+
+ g_return_val_if_fail(PW3270_IS_ACTION(action) && PW3270_IS_TOOLBAR(toolbar),NULL);
+
+ const gchar * icon_name = pw3270_action_get_icon_name(action);
+ if(!icon_name) {
+ g_message("Action doesn't have an icon");
+ return NULL;
+ }
+
+ debug("%s - %s",icon_name,pw3270_action_get_label(action));
+
+ GtkToolItem * item = gtk_tool_button_new(
+ gtk_image_new_from_icon_name(icon_name,GTK_ICON_SIZE_LARGE_TOOLBAR),
+ pw3270_action_get_label(action)
+ );
+
+ gtk_tool_button_set_use_underline(GTK_TOOL_BUTTON(item),TRUE);
+
+ gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, pos);
+ gtk_widget_show_all(GTK_WIDGET(item));
+
+ const gchar * tooltip = pw3270_action_get_tooltip(action);
+ if(tooltip)
+ gtk_widget_set_tooltip_markup(GTK_WIDGET(item),tooltip);
+
+ return GTK_WIDGET(item);
+ }
diff --git a/src/objects/toolbar/toolbar.c b/src/objects/toolbar/toolbar.c
index 4906df1..8c23b6f 100644
--- a/src/objects/toolbar/toolbar.c
+++ b/src/objects/toolbar/toolbar.c
@@ -256,3 +256,4 @@
return TRUE;
}
+
diff --git a/src/objects/window/window.c b/src/objects/window/window.c
index 07e0d3e..02832df 100644
--- a/src/objects/window/window.c
+++ b/src/objects/window/window.c
@@ -57,7 +57,6 @@
widget->toolbar = GTK_TOOLBAR(pw3270_toolbar_new());
-
gtk_box_pack_start(vBox,GTK_WIDGET(widget->toolbar),FALSE,TRUE,0);
gtk_box_pack_start(vBox,GTK_WIDGET(widget->notebook),TRUE,TRUE,0);
@@ -69,6 +68,10 @@
//
pw3270_window_add_actions(GTK_WIDGET(widget));
+ pw3270_toolbar_insert_action(GTK_WIDGET(widget->toolbar), g_action_map_lookup_action(G_ACTION_MAP(widget), "win.reconnect"), -1);
+
+ //gtk_widget_show_all(GTK_WIDGET(widget->toolbar));
+
//
// Setup Window actions.
//
--
libgit2 0.21.2