libxputty  0.1
A damn tiny abstraction Layer to create X11 window/widgets with cairo surfaces
xmessage-dialog.h File Reference
#include "xwidgets.h"
Include dependency graph for xmessage-dialog.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  MessageBox
 

Macros

#define XMESSAGE_DIALOG_H_
 

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 More...
 

Macro Definition Documentation

◆ XMESSAGE_DIALOG_H_

#define XMESSAGE_DIALOG_H_

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

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  {
33  INFO_BOX,
35  ERROR_BOX,
38  ENTRY_BOX,
39 };

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 322 of file xmessage-dialog.c.

323  {
324 
325  MessageBox *mb = (MessageBox*)malloc(sizeof(MessageBox));
326  mb->response = 0;
327  mb->message_type = 0;
328  mb->lin = 0;
329  mb->width = 330;
330  mb->height = 200;
331  mb->message = NULL;
332  mb->sel = 0;
333  mb->choices = NULL;
334  mb->icon = NULL;
335  check_for_message(mb, message);
336  check_for_choices(mb, choices);
337  check_for_style(mb, style);
338  Widget_t *wid = create_window(w->app, DefaultRootWindow(w->app->dpy), 0, 0, mb->width, mb->height);
339  wid->label = message;
340  wid->flags |= HAS_MEM;
341  wid->scale.gravity = CENTER;
342  wid->parent_struct = mb;
343  wid->parent = w;
344  wid->func.mem_free_callback = mg_mem_free;
345  wid->func.expose_callback = draw_message_window;
346  char *alternate_title = NULL;
347  char *button_title = (char*)"OK";
348  Widget_t *no;
349  switch (style) {
350  case INFO_BOX:
351  widget_get_png(wid, LDVAR(info_png));
352  alternate_title = (char*)"INFO";
353  mb->message_type = INFO_BOX;
355  break;
356  case WARNING_BOX:
357  widget_get_png(wid, LDVAR(warning_png));
358  alternate_title = (char*)"WARNING";
361  break;
362  case ERROR_BOX:
363  widget_get_png(wid, LDVAR(error_png));
364  alternate_title = (char*)"ERROR";
365  mb->message_type = ERROR_BOX;
367  break;
368  case QUESTION_BOX:
369  widget_get_png(wid, LDVAR(question_png));
370  alternate_title = (char*)"QUESTION";
371  no = add_button(wid, "NO", 10, mb->height-40, 60, 30);
372  no->scale.gravity = CENTER;
373  no->func.value_changed_callback = message_no_callback;
375  button_title = (char*)"YES";
377  break;
378  case SELECTION_BOX:
379  widget_get_png(wid, LDVAR(choice_png));
380  alternate_title = (char*)"SELECTION";
382  create_checkboxes(wid);
384  break;
385  case ENTRY_BOX:
386  widget_get_png(wid, LDVAR(message_png));
387  alternate_title = (char*)"TEXT ENTRY";
388  mb->message_type = ENTRY_BOX;
389  create_entry_box(wid);
391  break;
392  }
393  widget_set_title(wid, (title)? title : alternate_title);
394 
395  Widget_t *okay = add_button(wid, button_title, mb->width-70, mb->height-40, 60, 30);
396  okay->scale.gravity = CENTER;
397  okay->func.value_changed_callback = message_okay_callback;
398 
399  widget_show_all(wid);
400  return wid;
401 }

References MessageBox::choices, MessageBox::height, MessageBox::icon, MessageBox::lin, MessageBox::message, MessageBox::message_type, MessageBox::response, MessageBox::sel, and MessageBox::width.

QUESTION_BOX
@ QUESTION_BOX
Definition: xmessage-dialog.h:36
Resize_t::gravity
Gravity gravity
Definition: xwidget.h:192
MessageBox::message
char ** message
Definition: xmessage-dialog.h:49
widget_set_title
void widget_set_title(Widget_t *w, const char *title)
widget_set_title - set window title for a Widget_t
Definition: xwidget.c:387
Widget_t::image
cairo_surface_t * image
Definition: xwidget.h:320
MessageBox::width
unsigned int width
Definition: xmessage-dialog.h:44
widget_set_icon_from_surface
void widget_set_icon_from_surface(Widget_t *w, Pixmap *icon_, 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:98
Widget_t::parent_struct
void * parent_struct
Definition: xwidget.h:306
MessageBox::sel
unsigned int sel
Definition: xmessage-dialog.h:50
Func_t::expose_callback
xevfunc expose_callback
Definition: xwidget.h:80
CENTER
@ CENTER
Definition: xwidget.h:165
ERROR_BOX
@ ERROR_BOX
Definition: xmessage-dialog.h:35
Widget_t::flags
long long flags
Definition: xwidget.h:324
Widget_t::scale
Resize_t scale
Definition: xwidget.h:356
WARNING_BOX
@ WARNING_BOX
Definition: xmessage-dialog.h:34
HAS_MEM
@ HAS_MEM
Definition: xwidget.h:251
Widget_t::app
Xputty * app
Definition: xwidget.h:300
MessageBox
Definition: xmessage-dialog.h:41
Xputty::dpy
Display * dpy
Definition: xputty.h:181
widget_get_png
void widget_get_png(Widget_t *w, const unsigned char *name)
widget_get_png - read png into Widget_t xlib surface
Definition: xpngloader.c:41
INFO_BOX
@ INFO_BOX
Definition: xmessage-dialog.h:33
Widget_t
Widget_t - struct to hold the basic Widget_t info.
Definition: xwidget.h:298
MessageBox::height
unsigned int height
Definition: xmessage-dialog.h:45
MessageBox::choices
char ** choices
Definition: xmessage-dialog.h:51
LDVAR
#define LDVAR(NAME)
Definition: xpngloader.h:71
Func_t::mem_free_callback
xevfunc mem_free_callback
Definition: xwidget.h:87
create_window
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:145
ENTRY_BOX
@ ENTRY_BOX
Definition: xmessage-dialog.h:38
Widget_t::func
Func_t func
Definition: xwidget.h:310
MessageBox::response
int response
Definition: xmessage-dialog.h:42
MessageBox::message_type
int message_type
Definition: xmessage-dialog.h:43
MessageBox::lin
unsigned int lin
Definition: xmessage-dialog.h:46
Widget_t::parent
void * parent
Definition: xwidget.h:304
MessageBox::icon
Pixmap * icon
Definition: xmessage-dialog.h:48
SELECTION_BOX
@ SELECTION_BOX
Definition: xmessage-dialog.h:37
Widget_t::label
const char * label
Definition: xwidget.h:326
Func_t::value_changed_callback
xevfunc value_changed_callback
Definition: xwidget.h:85
add_button
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
widget_show_all
void widget_show_all(Widget_t *w)
widget_show_all - map/show Widget_t with all childs
Definition: xwidget.c:405