Commit f78955658a9f4d635dd4dee16811dda1dc50601a
1 parent
aa2e5b86
Exists in
master
and in
2 other branches
Implementing method to get active session.
Showing
3 changed files
with
22 additions
and
40 deletions
Show diff stats
src/include/pw3270/application.h
| @@ -37,6 +37,7 @@ | @@ -37,6 +37,7 @@ | ||
| 37 | #define PW3270_APPLICATION_H_INCLUDED | 37 | #define PW3270_APPLICATION_H_INCLUDED |
| 38 | 38 | ||
| 39 | #include <gtk/gtk.h> | 39 | #include <gtk/gtk.h> |
| 40 | +#include <lib3270.h> | ||
| 40 | 41 | ||
| 41 | G_BEGIN_DECLS | 42 | G_BEGIN_DECLS |
| 42 | 43 | ||
| @@ -98,6 +99,9 @@ void pw3270_application_save_copy_activated(GAction *action, GVariant *parameter | @@ -98,6 +99,9 @@ void pw3270_application_save_copy_activated(GAction *action, GVariant *parameter | ||
| 98 | // Settings | 99 | // Settings |
| 99 | GtkWidget * pw3270_header_settings_new(); | 100 | GtkWidget * pw3270_header_settings_new(); |
| 100 | 101 | ||
| 102 | +// Tools | ||
| 103 | +H3270 * pw3270_get_active_session(); | ||
| 104 | + | ||
| 101 | 105 | ||
| 102 | G_END_DECLS | 106 | G_END_DECLS |
| 103 | 107 |
src/main/tools.c
| @@ -64,27 +64,6 @@ void gtk_container_remove_all(GtkContainer *container) { | @@ -64,27 +64,6 @@ void gtk_container_remove_all(GtkContainer *container) { | ||
| 64 | 64 | ||
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | -/* | ||
| 68 | -GtkWidget * pw3270_frame_new(GtkWidget * child, const gchar *title) { | ||
| 69 | - | ||
| 70 | -GtkFrame * frame = GTK_FRAME(gtk_frame_new("")); | ||
| 71 | -g_autofree gchar * markup = g_strdup_printf("<b>%s</b>",title); | ||
| 72 | -GtkWidget * label = gtk_label_new(NULL); | ||
| 73 | - | ||
| 74 | -gtk_frame_set_shadow_type(GTK_FRAME(frame),GTK_SHADOW_NONE); | ||
| 75 | -gtk_label_set_markup(GTK_LABEL(label),markup); | ||
| 76 | -gtk_frame_set_label_widget(GTK_FRAME(frame),label); | ||
| 77 | - gtk_container_set_border_width(GTK_CONTAINER(child),12); | ||
| 78 | - | ||
| 79 | -gtk_container_add(GTK_CONTAINER(frame),GTK_WIDGET(child)); | ||
| 80 | - | ||
| 81 | -g_object_set(G_OBJECT(frame),"margin-top",6,NULL); | ||
| 82 | - | ||
| 83 | -return GTK_WIDGET(frame); | ||
| 84 | - | ||
| 85 | -} | ||
| 86 | -*/ | ||
| 87 | - | ||
| 88 | void gtk_file_chooser_set_pw3270_filters(GtkFileChooser *chooser) { | 67 | void gtk_file_chooser_set_pw3270_filters(GtkFileChooser *chooser) { |
| 89 | 68 | ||
| 90 | static const struct Filter { | 69 | static const struct Filter { |
| @@ -112,4 +91,15 @@ void gtk_file_chooser_set_pw3270_filters(GtkFileChooser *chooser) { | @@ -112,4 +91,15 @@ void gtk_file_chooser_set_pw3270_filters(GtkFileChooser *chooser) { | ||
| 112 | 91 | ||
| 113 | } | 92 | } |
| 114 | 93 | ||
| 94 | +H3270 * pw3270_get_active_session() { | ||
| 95 | + | ||
| 96 | + GApplication *app = g_application_get_default(); | ||
| 97 | + | ||
| 98 | + g_return_val_if_fail(GTK_IS_APPLICATION(app),NULL); | ||
| 99 | + | ||
| 100 | + GtkWindow * window = gtk_application_get_active_window(GTK_APPLICATION(app)); | ||
| 101 | + | ||
| 102 | + return pw3270_window_get_session_handle(GTK_WIDGET(window)); | ||
| 103 | + | ||
| 104 | +} | ||
| 115 | 105 |
src/objects/window/tools.c
| @@ -28,28 +28,16 @@ | @@ -28,28 +28,16 @@ | ||
| 28 | */ | 28 | */ |
| 29 | 29 | ||
| 30 | #include "private.h" | 30 | #include "private.h" |
| 31 | -#include <pw3270/application.h> | 31 | +#include <pw3270/window.h> |
| 32 | 32 | ||
| 33 | -/* | ||
| 34 | -GtkWidget * pw3270_setup_image_button(GtkWidget *button, const gchar *image_name) { | 33 | +H3270 * pw3270_window_get_session_handle(GtkWidget *window) { |
| 35 | 34 | ||
| 36 | -gtk_button_set_image(GTK_BUTTON(button),gtk_image_new_from_icon_name(image_name,GTK_ICON_SIZE_MENU)); | 35 | + g_return_val_if_fail(PW3270_IS_APPLICATION_WINDOW(window),NULL); |
| 37 | 36 | ||
| 38 | -gtk_widget_set_can_focus(button,FALSE); | ||
| 39 | -gtk_widget_set_can_default(button,FALSE); | ||
| 40 | -gtk_widget_set_focus_on_click(button,FALSE); | 37 | + GtkWidget * terminal = PW3270_APPLICATION_WINDOW(window)->terminal; |
| 38 | + if(!terminal) | ||
| 39 | + return NULL; | ||
| 41 | 40 | ||
| 42 | -return button; | 41 | + return v3270_get_session(terminal); |
| 43 | 42 | ||
| 44 | } | 43 | } |
| 45 | -*/ | ||
| 46 | - | ||
| 47 | -/* | ||
| 48 | - gboolean pw3270_settings_set_int(const gchar *key, gint value) { | ||
| 49 | - | ||
| 50 | - GSettings * settings = pw3270_application_get_settings(g_application_get_default()); | ||
| 51 | - if(settings) | ||
| 52 | - return g_settings_set_int(settings,key,value); | ||
| 53 | - return FALSE; | ||
| 54 | - } | ||
| 55 | -*/ |