Commit 2b27f48edb3c46d3f6e2243dd7b97862a5ca9aa0
1 parent
b70bb2fc
Exists in
master
and in
5 other branches
Incluindo suporte a popups na interface dbus
Showing
5 changed files
with
72 additions
and
2 deletions
Show diff stats
src/classlib/remote.cc
... | ... | @@ -222,7 +222,9 @@ |
222 | 222 | |
223 | 223 | dbus_message_unref(msg); |
224 | 224 | throw e; |
225 | + return -1; | |
225 | 226 | } |
227 | + dbus_message_unref(msg); | |
226 | 228 | } |
227 | 229 | return -1; |
228 | 230 | } |
... | ... | @@ -982,6 +984,59 @@ |
982 | 984 | { |
983 | 985 | return query_intval("setClipboard", DBUS_TYPE_STRING, &text, DBUS_TYPE_INVALID); |
984 | 986 | } |
987 | + | |
988 | + int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...) | |
989 | + { | |
990 | + DBusMessage * msg = dbus_message_new_method_call( this->dest, // Destination | |
991 | + this->path, // Path | |
992 | + this->intf, // Interface | |
993 | + "showPopup"); // method | |
994 | + | |
995 | + if (!msg) | |
996 | + { | |
997 | + throw exception("%s","Error creating DBUS message for popup"); | |
998 | + return -1; | |
999 | + } | |
1000 | + else | |
1001 | + { | |
1002 | + char text[4096]; | |
1003 | + char * ptr = text; | |
1004 | + va_list arg_ptr; | |
1005 | + dbus_int32_t i = (dbus_int32_t) id; | |
1006 | + | |
1007 | + va_start(arg_ptr, fmt); | |
1008 | + vsnprintf(text,4095,fmt,arg_ptr); | |
1009 | + va_end(arg_ptr); | |
1010 | + | |
1011 | + if(!dbus_message_append_args(msg, DBUS_TYPE_INT32, &i, DBUS_TYPE_STRING, &title, DBUS_TYPE_STRING, &message, DBUS_TYPE_STRING, &ptr, DBUS_TYPE_INVALID)) | |
1012 | + { | |
1013 | + dbus_message_unref(msg); | |
1014 | + throw exception("%s","Cant append args for popup message"); | |
1015 | + } | |
1016 | + else | |
1017 | + { | |
1018 | + DBusMessage * reply; | |
1019 | + DBusError error; | |
1020 | + | |
1021 | + dbus_error_init(&error); | |
1022 | + reply = dbus_connection_send_with_reply_and_block(conn,msg,DBUS_TIMEOUT_INFINITE,&error); | |
1023 | + dbus_message_unref(msg); | |
1024 | + | |
1025 | + if(!reply) | |
1026 | + { | |
1027 | + exception e = exception("%s",error.message); | |
1028 | + dbus_error_free(&error); | |
1029 | + throw e; | |
1030 | + return -1; | |
1031 | + } | |
1032 | + | |
1033 | + return get_intval(reply); | |
1034 | + | |
1035 | + } | |
1036 | + } | |
1037 | + return 0; | |
1038 | + } | |
1039 | + | |
985 | 1040 | #endif // HAVE_DBUS |
986 | 1041 | |
987 | 1042 | }; | ... | ... |
src/plugins/dbus3270/gobject.c
... | ... | @@ -446,3 +446,9 @@ void pw3270_dbus_set_script(PW3270Dbus *object, const gchar *text, int mode, DBu |
446 | 446 | |
447 | 447 | dbus_g_method_return(context,v3270_set_script(widget,*text,mode != 0)); |
448 | 448 | } |
449 | + | |
450 | +void pw3270_dbus_show_popup(PW3270Dbus *object, int id, const gchar *title, const gchar *msg, const gchar *text, DBusGMethodInvocation *context) | |
451 | +{ | |
452 | + lib3270_popup_dialog(pw3270_dbus_get_session_handle(object), (LIB3270_NOTIFY) id , title, msg, "%s", text); | |
453 | + dbus_g_method_return(context,0); | |
454 | +} | ... | ... |
src/plugins/dbus3270/pw3270dbus.xml
... | ... | @@ -142,6 +142,13 @@ |
142 | 142 | <arg type="i" name="status" direction="in" /> |
143 | 143 | <arg type="i" name="result" direction="out" /> |
144 | 144 | </method> |
145 | + <method name="showPopup"> | |
146 | + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | |
147 | + <arg type="i" name="id" direction="in" /> | |
148 | + <arg type="s" name="title" direction="in" /> | |
149 | + <arg type="s" name="msg" direction="in" /> | |
150 | + <arg type="s" name="text" direction="in" /> | |
151 | + </method> | |
145 | 152 | </interface> |
146 | 153 | |
147 | 154 | </node> | ... | ... |
src/plugins/dbus3270/service.h
... | ... | @@ -91,6 +91,8 @@ |
91 | 91 | |
92 | 92 | void pw3270_dbus_set_script(PW3270Dbus *object, const gchar *text, int mode, DBusGMethodInvocation *context); |
93 | 93 | |
94 | + void pw3270_dbus_show_popup(PW3270Dbus *object, int id, const gchar *title, const gchar *msg, const gchar *text, DBusGMethodInvocation *context); | |
95 | + | |
94 | 96 | // Actions |
95 | 97 | void pw3270_dbus_enter(PW3270Dbus *object, DBusGMethodInvocation *context); |
96 | 98 | void pw3270_dbus_pf_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context); | ... | ... |
src/pw3270/v3270/widget.c
... | ... | @@ -217,10 +217,10 @@ void v3270_popup_message(GtkWidget *widget, LIB3270_NOTIFY type , const gchar *t |
217 | 217 | if(message) |
218 | 218 | { |
219 | 219 | dialog = gtk_message_dialog_new_with_markup(GTK_WINDOW(toplevel),GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,msgtype,buttons,"%s",message); |
220 | - if(text) | |
220 | + if(text && *text) | |
221 | 221 | gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(dialog),"%s",text); |
222 | 222 | } |
223 | - else if(text) | |
223 | + else if(text && *text) | |
224 | 224 | { |
225 | 225 | dialog = gtk_message_dialog_new_with_markup(GTK_WINDOW(toplevel),GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,msgtype,buttons,"%s",text); |
226 | 226 | } | ... | ... |