libxputty 0.1
Loading...
Searching...
No Matches
Data Structures | Enumerations | Functions
xmessage-dialog.h File Reference

Go to the source code of this file.

Data Structures

struct  MessageDialog
 

Enumerations

enum  {
  INFO_BOX , WARNING_BOX , ERROR_BOX , QUESTION_BOX ,
  SELECTION_BOX , ENTRY_BOX
}
 

Functions

Widget_topen_message_dialog (Widget_t *w, int style, const char *title, const char *message, const char *choices)
 open_message_dialog - open a non blocking dialog window, lines in message chould be separated by the character "|" choices for the SELECTION_BOX should be separated as well with the character "|". message and/or choices could be NULL when not needed. To fetch the response of a dialog, connect to the dialog_callback supported "styles" been
INFO_BOX - a message dialog display a info text
WARNING_BOX - a message dialog display a warning
ERROR_BOX - a message dialog display a error message
QUESTION_BOX - a no/yes dialog message
SELECTION_BOX - a dialog to select between multiple options
ENTRY_BOX - a dialog to get text input
 
void radio_box_set_active (Widget_t *w)
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
INFO_BOX 
WARNING_BOX 
ERROR_BOX 
QUESTION_BOX 
SELECTION_BOX 
ENTRY_BOX 

Definition at line 32 of file xmessage-dialog.h.

32 {
39};
@ QUESTION_BOX
@ WARNING_BOX
@ ENTRY_BOX
@ SELECTION_BOX
@ ERROR_BOX
@ INFO_BOX

Function Documentation

◆ open_message_dialog()

Widget_t * open_message_dialog ( Widget_t w,
int  style,
const char *  title,
const char *  message,
const char *  choices 
)

open_message_dialog - open a non blocking dialog window, lines in message chould be separated by the character "|" choices for the SELECTION_BOX should be separated as well with the character "|". message and/or choices could be NULL when not needed. To fetch the response of a dialog, connect to the dialog_callback supported "styles" been
INFO_BOX - a message dialog display a info text
WARNING_BOX - a message dialog display a warning
ERROR_BOX - a message dialog display a error message
QUESTION_BOX - a no/yes dialog message
SELECTION_BOX - a dialog to select between multiple options
ENTRY_BOX - a dialog to get text input

Returns
Widget_t* - pointer to the Widget_t struct

Definition at line 386 of file xmessage-dialog.c.

387 {
388
389 MessageDialog *mb = (MessageDialog*)malloc(sizeof(MessageDialog));
390 mb->response = 0;
391 mb->message_type = 0;
392 mb->lin = 0;
393 mb->width = 330;
394 mb->height = 200;
395 mb->message = NULL;
396 mb->sel = 0;
397 mb->choices = NULL;
398 check_for_message(mb, message);
399 check_for_choices(mb, choices);
400 check_for_style(mb, style);
401 Widget_t *wid = create_window(w->app, os_get_root_window(w->app, IS_WINDOW), 0, 0, mb->width, mb->height);
402 wid->label = message;
403 wid->flags |= HAS_MEM;
404 wid->scale.gravity = CENTER;
405 wid->parent_struct = mb;
406 wid->parent = w;
407 wid->func.mem_free_callback = mg_mem_free;
408 wid->func.expose_callback = draw_message_window;
409 check_for_hyperlinks(wid);
410 char *alternate_title = NULL;
411 char *button_title = (char*)_("OK");
412 Widget_t *no;
413 switch (style) {
414 case INFO_BOX:
415 widget_get_png(wid, LDVAR(info_png));
416 alternate_title = (char*)_("INFO");
419 break;
420 case WARNING_BOX:
421 widget_get_png(wid, LDVAR(warning_png));
422 alternate_title = (char*)_("WARNING");
425 break;
426 case ERROR_BOX:
427 widget_get_png(wid, LDVAR(error_png));
428 alternate_title = (char*)_("ERROR");
431 break;
432 case QUESTION_BOX:
433 widget_get_png(wid, LDVAR(question_png));
434 alternate_title = (char*)_("QUESTION");
435 no = add_button(wid, _("NO"), 10, mb->height-40, 60, 30);
436 no->scale.gravity = CENTER;
437 no->func.value_changed_callback = message_no_callback;
439 button_title = (char*)_("YES");
441 break;
442 case SELECTION_BOX:
443 widget_get_png(wid, LDVAR(choice_png));
444 alternate_title = (char*)_("SELECTION");
446 create_checkboxes(wid);
448 break;
449 case ENTRY_BOX:
450 widget_get_png(wid, LDVAR(message_png));
451 alternate_title = (char*)_("TEXT ENTRY");
453 create_entry_box(wid);
455 break;
456 }
457 widget_set_title(wid, (title)? title : alternate_title);
458
459 Widget_t *okay = add_button(wid, button_title, mb->width-70, mb->height-40, 60, 30);
460 okay->scale.gravity = CENTER;
461 okay->func.value_changed_callback = message_okay_callback;
462
463 widget_show_all(wid);
464 return wid;
465}
xevfunc expose_callback
Definition xwidget.h:85
xevfunc value_changed_callback
Definition xwidget.h:90
xevfunc mem_free_callback
Definition xwidget.h:92
unsigned int lin
unsigned int height
unsigned int sel
unsigned int width
Gravity gravity
Definition xwidget.h:347
Widget_t - struct to hold the basic Widget_t info.
Definition xwidget.h:457
Resize_t scale
Definition xwidget.h:525
cairo_surface_t * image
Definition xwidget.h:491
void * parent
Definition xwidget.h:471
long long flags
Definition xwidget.h:461
const char * label
Definition xwidget.h:463
void * parent_struct
Definition xwidget.h:473
Func_t func
Definition xwidget.h:481
Xputty * app
Definition xwidget.h:465
Widget_t * add_button(Widget_t *parent, const char *label, int x, int y, int width, int height)
add_button - add a button to a Widget_t connect to func.value_changed_callback to implement your acti...
Definition xbutton.c:26
void widget_get_png(Widget_t *w, const unsigned char *name)
widget_get_png - read png into Widget_t xlib surface
Definition xpngloader.c:75
void widget_set_icon_from_surface(Widget_t *w, cairo_surface_t *image)
widget_set_icon_from_surface - set icon image from cairo surface for Widget_t those icon will be used...
Definition xpngloader.c:119
Window os_get_root_window(Xputty *main, int flag)
os_get_root_window - get a pointer to the root window (desktop)
void widget_set_title(Widget_t *w, const char *title)
widget_set_title - set window title for a Widget_t
Definition xwidget.c:359
Widget_t * create_window(Xputty *app, Window win, int x, int y, int width, int height)
*create_window - create a Window You need to create as least minimun one Window to get started....
Definition xwidget.c:163
@ CENTER
Definition xwidget.h:320
@ HAS_MEM
Definition xwidget.h:406
@ IS_WINDOW
Definition xwidget.h:390
void widget_show_all(Widget_t *w)
widget_show_all - map/show Widget_t with all childs
Definition xwidget.c:386

References add_button(), Widget_t::app, CENTER, MessageDialog::choices, create_window(), ENTRY_BOX, ERROR_BOX, Func_t::expose_callback, Widget_t::flags, Widget_t::func, Resize_t::gravity, HAS_MEM, MessageDialog::height, Widget_t::image, INFO_BOX, IS_WINDOW, Widget_t::label, MessageDialog::lin, Func_t::mem_free_callback, MessageDialog::message, MessageDialog::message_type, os_get_root_window(), Widget_t::parent, Widget_t::parent_struct, QUESTION_BOX, MessageDialog::response, Widget_t::scale, MessageDialog::sel, SELECTION_BOX, Func_t::value_changed_callback, WARNING_BOX, widget_get_png(), widget_set_icon_from_surface(), widget_set_title(), widget_show_all(), and MessageDialog::width.

Referenced by hyperlink_pressed().

◆ radio_box_set_active()

void radio_box_set_active ( Widget_t w)

Definition at line 235 of file xmessage-dialog.c.

235 {
236 Widget_t * p = (Widget_t*)w->parent;
237 MessageDialog *mb = (MessageDialog *)p->parent_struct;
238 int response = 0;
239 int i = 0;
240 for(;i<p->childlist->elem;i++) {
241 Widget_t *wid = p->childlist->childs[i];
242 if (wid->adj && wid->flags & IS_RADIO) {
243 ++response;
244 if (wid != w) adj_set_value(wid->adj_y, 0.0);
245 else if (wid == w) mb->response = response;
246 }
247 }
248}
Widget_t ** childs
Definition xchildlist.h:51
Adjustment_t * adj_y
Definition xwidget.h:495
Adjustment_t * adj
Definition xwidget.h:497
Childlist_t * childlist
Definition xwidget.h:499
void adj_set_value(Adjustment_t *adj, float value)
adj_set_value - set the current value to the Adjustment_t
@ IS_RADIO
Definition xwidget.h:394

References Widget_t::adj, adj_set_value(), Widget_t::adj_y, Widget_t::childlist, Childlist_t::childs, Childlist_t::elem, Widget_t::flags, IS_RADIO, Widget_t::parent, Widget_t::parent_struct, and MessageDialog::response.