Yattm - unified GTK instant-messaging client logo
   [Generated for version 0.2-17 - Mon Jan 6 19:01:23 GMT+1 2003]

Home - Main Page - Data Structures - File List - Data Fields - Globals

dialog.c File Reference

#include "intl.h"
#include <string.h>
#include <gtk/gtk.h>
#include <gdk/gdkprivate.h>
#include <stdlib.h>
#include "dialog.h"
#include "util.h"
#include "status.h"
#include "pixmaps/yattm.xpm"
#include "pixmaps/tb_yes.xpm"
#include "pixmaps/tb_no.xpm"
#include "pixmaps/ok.xpm"
#include "libproxy/libproxy.h"
#include "gtk_globals.h"

Include dependency graph for dialog.c:

Include dependency graph

Go to the source code of this file.

Functions

void set_option (GtkWidget *w, int *data)
GtkWidget * eb_button (const char *text, int *value, GtkWidget *page)
GtkWidget * eb_push_button (const char *text, GtkWidget *page)
GSList * eb_radio (GSList *group, const char *text, int curr_val, int set_val, GtkWidget *page, void *set_element)
GtkWidget * eb_menu_button (GtkMenu *menu, gchar *label, GtkSignalFunc callback_func, gpointer callback_arg)
GtkWidget * eb_menu_submenu (GtkMenu *menu, gchar *label, GtkWidget *submenu)
void eb_icon (GdkWindow *w)
void list_dialog_callback (GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data)
void do_list_dialog (gchar *message, gchar *title, char **list, void(*action)(char *text, gpointer data), gpointer data)
void do_dialog (gchar *message, gchar *title, void(*action)(GtkWidget *widget, gpointer data), gpointer data)
GtkWidget * do_error_dialog (char *message, char *title)
void input_window_destroy (GtkWidget *widget, gpointer data)
void input_window_ok (GtkWidget *widget, gpointer data)
void do_text_input_window (gchar *title, gchar *value, void(*action)(char *text, gpointer data), gpointer data)

Variables

GdkPixmap * icon_pm = NULL
GdkBitmap * icon_bm = NULL


Function Documentation

void do_dialog gchar *    message,
gchar *    title,
void(*    action)(GtkWidget *widget, gpointer data),
gpointer    data
 

Definition at line 260 of file dialog.c.

References _, and title.

Referenced by eb_do_dialog(), get_file(), ignore_callback(), invite_dialog(), offer_remove_account_callback(), offer_remove_contact_callback(), and offer_remove_group_callback().

00261 {
00262     GtkWidget * dialog_window;
00263     GtkWidget * button;
00264     GtkWidget * label;
00265     GdkPixmap *pm;
00266     GdkBitmap *bm;
00267     GtkWidget * button_box;
00268 
00269     dialog_window = gtk_dialog_new();
00270     gtk_window_set_position(GTK_WINDOW(dialog_window), GTK_WIN_POS_MOUSE);
00271     gtk_widget_realize(dialog_window);
00272     gtk_window_set_title(GTK_WINDOW(dialog_window), title );
00273 
00274 
00275 
00276     label = gtk_label_new(message);
00277     gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
00278     gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog_window)->vbox),
00279         label, FALSE, FALSE, 5);
00280 
00281     button_box = gtk_hbox_new(FALSE, 5);
00282     pm = gdk_pixmap_create_from_xpm_d(statuswindow->window, &bm, NULL, tb_yes_xpm);
00283     label = gtk_pixmap_new(pm, bm);
00284 
00285     gtk_box_pack_start(GTK_BOX(button_box), label, FALSE, FALSE, 2 );
00286 
00287     label = gtk_label_new(_("Yes"));
00288     gtk_box_pack_start(GTK_BOX(button_box), label, FALSE, FALSE, 2 );
00289 
00290 
00291     button = gtk_button_new();
00292     gtk_container_add(GTK_CONTAINER(button), button_box);
00293     gtk_widget_show(button_box);
00294     gtk_signal_connect(GTK_OBJECT(button), "clicked",
00295                        GTK_SIGNAL_FUNC(action), data );
00296     gtk_signal_connect_object(GTK_OBJECT(button), "clicked",
00297                               GTK_SIGNAL_FUNC(gtk_widget_destroy),
00298                               (gpointer)dialog_window);
00299     gtk_object_set_user_data(GTK_OBJECT(button), (gpointer)1);
00300     
00301     gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog_window)->action_area), 
00302                         button, FALSE, FALSE, 5 );
00303 
00304     button_box = gtk_hbox_new(FALSE, 5);
00305     pm = gdk_pixmap_create_from_xpm_d(statuswindow->window, &bm, NULL, tb_no_xpm);
00306     label = gtk_pixmap_new(pm, bm);
00307 
00308     gtk_box_pack_start(GTK_BOX(button_box), label, FALSE, FALSE, 2 );
00309 
00310     label = gtk_label_new(_("No"));
00311     gtk_box_pack_start(GTK_BOX(button_box), label, FALSE, FALSE, 2 );
00312 
00313 
00314     button = gtk_button_new();
00315     gtk_container_add(GTK_CONTAINER(button), button_box);
00316 
00317     gtk_signal_connect(GTK_OBJECT(button), "clicked",
00318                        GTK_SIGNAL_FUNC(action), data);
00319     gtk_signal_connect_object(GTK_OBJECT(button), "clicked",
00320                               GTK_SIGNAL_FUNC(gtk_widget_destroy),
00321                               (gpointer)dialog_window);
00322     gtk_object_set_user_data(GTK_OBJECT(button), (gpointer)0 );
00323 
00324     gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog_window)->action_area), 
00325                         button, FALSE, FALSE, 5 );
00326 
00327     gtk_widget_show_all(dialog_window);
00328 }

GtkWidget* do_error_dialog char *    message,
char *    title
 

Definition at line 338 of file dialog.c.

References _, and title.

Referenced by add_account_verbose(), add_button_callback(), add_callback(), file_ok(), get_file2(), load_modules(), load_utility_plugin(), main(), ok_callback(), reload_service_accounts(), send_file(), unload_module(), and update_send_progress().

00339 {
00340     GtkWidget *d;
00341     GtkWidget *label;
00342     GtkWidget *close;
00343 
00344 
00345     d = gtk_dialog_new();
00346     /* if parent is not main window, set it.
00347      * This prevents this dialog from popping up 'underneath' another
00348      * dialog to which it applies
00349      */
00350     /*if(current_parent_widget)
00351     {
00352     gtk_window_set_transient_for(GTK_WINDOW(d),
00353                      GTK_WINDOW(current_parent_widget));
00354     }*/
00355     label = gtk_label_new(message);
00356     gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
00357     gtk_widget_show(label);
00358     close = gtk_button_new_with_label(_("OK"));
00359     gtk_widget_show(close);
00360     gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->vbox),
00361         label, FALSE, FALSE, 5);
00362     gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->action_area),
00363         close, FALSE, FALSE, 5);
00364     /* so text isn't up against the border */
00365     gtk_container_set_border_width(GTK_CONTAINER(d), 5);
00366     gtk_widget_realize(d);
00367     gtk_window_set_title(GTK_WINDOW(d), title);
00368     gtk_window_set_position(GTK_WINDOW(d), GTK_WIN_POS_MOUSE);
00369     gtk_signal_connect_object(GTK_OBJECT(close), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(d));
00370     gtk_window_set_modal(GTK_WINDOW(d), TRUE);
00371 
00372     gtk_widget_show(d);
00373     return d;
00374 }

void do_list_dialog gchar *    message,
gchar *    title,
char **    list,
void(*    action)(char *text, gpointer data),
gpointer    data
 

Definition at line 194 of file dialog.c.

References _list_dialog_data::callback, _list_dialog_data::data, DBG_CORE, eb_debug, list_dialog_callback(), and title.

00195 {
00196     GtkWidget * dialog_window;
00197     GtkWidget * label;
00198     GtkWidget * clist;
00199     /*  UNUSED GtkWidget * button_box; */
00200     char *Row[2]={NULL, NULL};
00201     list_dialog_data *ldata;
00202     char **ptr=list;
00203 
00204     eb_debug(DBG_CORE, ">Entering\n");
00205     if(list[0]==NULL) {
00206         eb_debug(DBG_CORE, ">Leaving as list[0]==NULL\n");
00207         return;
00208     }
00209     dialog_window = gtk_dialog_new();
00210 
00211     gtk_widget_realize(dialog_window);
00212     gtk_window_set_title(GTK_WINDOW(dialog_window), title );
00213 
00214     label = gtk_label_new(message);
00215     gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
00216     gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog_window)->vbox),
00217         label, FALSE, FALSE, 5);
00218 
00219     /* Convert the **list to a GList */
00220     clist = gtk_clist_new(1);   /* Only 1 column */
00221     gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_SINGLE);
00222     gtk_clist_set_column_width (GTK_CLIST(clist), 0, 200);
00223     /* Array of pointers to elements, one per column */
00224     while(*ptr) {
00225         Row[0]=*ptr;
00226         ptr++;
00227         gtk_clist_append(GTK_CLIST(clist), Row);
00228         free(Row[0]);
00229     }
00230     free(list);
00231 
00232     ldata=calloc(1, sizeof(list_dialog_data));
00233     ldata->callback=action;
00234     ldata->data=data;
00235     gtk_signal_connect(GTK_OBJECT(clist),
00236         "select_row",
00237         GTK_SIGNAL_FUNC(list_dialog_callback),
00238         ldata);
00239     gtk_signal_connect_object(GTK_OBJECT(clist),
00240         "select_row",
00241         GTK_SIGNAL_FUNC(gtk_widget_destroy),
00242         (gpointer)dialog_window);
00243     gtk_widget_show(clist);
00244     /* End list construction */
00245 /*
00246     button_box = gtk_hbox_new(FALSE, 5);
00247 
00248     gtk_box_pack_start(GTK_BOX(button_box), label, FALSE, FALSE, 2 );
00249 
00250     gtk_container_add(GTK_CONTAINER(button_box), button_box);
00251     gtk_widget_show(button_box);
00252 */  
00253     gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog_window)->action_area), 
00254                         clist, FALSE, FALSE, 5 );
00255 
00256     gtk_widget_show_all(dialog_window);
00257     eb_debug(DBG_CORE, ">Leaving, all done\n");
00258 }

void do_text_input_window gchar *    title,
gchar *    value,
void(*    action)(char *text, gpointer data),
gpointer    data
 

Definition at line 393 of file dialog.c.

References _, _text_input_window::callback, _text_input_window::data, eb_icon(), input_window_destroy(), input_window_ok(), _text_input_window::text, title, and _text_input_window::window.

00396 {
00397     GtkWidget * vbox = gtk_vbox_new(FALSE, 5);
00398     GtkWidget * frame = gtk_frame_new(NULL); 
00399     GtkWidget * hbox;
00400     GtkWidget * hbox2;
00401     GtkWidget * separator;
00402     GtkWidget * iconwid;
00403     GdkPixmap * icon;
00404     GdkBitmap * mask;
00405     GtkWidget * label;
00406     GtkWidget * button;
00407 
00408     text_input_window * input_window = g_new0(text_input_window, 1);
00409     input_window->callback = action;
00410     input_window->data = data;
00411 
00412     input_window->window = gtk_window_new(GTK_WINDOW_DIALOG);
00413     gtk_window_set_position(GTK_WINDOW(input_window->window), GTK_WIN_POS_MOUSE);
00414         gtk_widget_realize(input_window->window);
00415 
00416     gtk_container_set_border_width(GTK_CONTAINER(input_window->window), 5);
00417     gtk_frame_set_label(GTK_FRAME(frame), title);
00418 
00419     input_window->text = gtk_text_new(NULL, NULL);
00420     gtk_widget_set_usize(input_window->text, 400, 200);
00421     gtk_text_insert(GTK_TEXT(input_window->text),
00422             NULL, NULL, NULL, value, strlen(value));
00423     gtk_text_set_editable(GTK_TEXT(input_window->text),
00424             TRUE);
00425 
00426     gtk_container_add(GTK_CONTAINER(frame), input_window->text);
00427     gtk_widget_show(input_window->text);
00428 
00429     gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
00430     gtk_widget_show(frame);
00431 
00432 
00433     separator = gtk_hseparator_new();
00434     gtk_box_pack_start(GTK_BOX(vbox), separator, FALSE, FALSE, 5);
00435     gtk_widget_show(separator);
00436 
00437     hbox = gtk_hbox_new(FALSE, 5);
00438     hbox2 = gtk_hbox_new(TRUE, 5);
00439 
00440     gtk_widget_set_usize(hbox2, 100,25);
00441 
00442     icon = gdk_pixmap_create_from_xpm_d(input_window->window->window, &mask, NULL, ok_xpm);
00443     iconwid = gtk_pixmap_new(icon, mask);
00444     label = gtk_label_new(_("OK"));
00445          
00446     gtk_box_pack_start(GTK_BOX(hbox), iconwid, FALSE, FALSE, 2);
00447     gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
00448          
00449     gtk_widget_show(iconwid);
00450     gtk_widget_show(label);
00451          
00452     button = gtk_button_new();
00453          
00454     gtk_signal_connect(GTK_OBJECT(button), "clicked", input_window_ok,
00455             input_window);
00456 
00457     gtk_signal_connect_object(GTK_OBJECT(button), "clicked",
00458                   GTK_SIGNAL_FUNC(gtk_widget_destroy),
00459                   GTK_OBJECT(input_window->window));
00460          
00461     gtk_container_add(GTK_CONTAINER (button), hbox);        
00462     gtk_widget_show(hbox);     
00463          
00464     gtk_box_pack_start(GTK_BOX(hbox2), button, TRUE, TRUE, 0);
00465     gtk_widget_show(button);
00466 
00467     hbox = gtk_hbox_new(FALSE, 0);
00468         
00469     gtk_box_pack_end(GTK_BOX(hbox),hbox2, FALSE, FALSE, 0);
00470     gtk_widget_show(hbox2);      
00471       
00472     gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
00473     gtk_widget_show(hbox);
00474 
00475     gtk_container_add(GTK_CONTAINER(input_window->window), vbox);
00476     gtk_widget_show(vbox);
00477 
00478         gtk_window_set_title(GTK_WINDOW(input_window->window), title);
00479     eb_icon(input_window->window->window);
00480 
00481     gtk_signal_connect(GTK_OBJECT(input_window->window), "destroy",
00482             GTK_SIGNAL_FUNC(input_window_destroy), input_window);
00483 
00484     gtk_widget_show(input_window->window);
00485         
00486 
00487 }

GtkWidget* eb_button const char *    text,
int *    value,
GtkWidget *    page
 

Definition at line 54 of file dialog.c.

References set_option().

Referenced by build_chat_prefs(), build_general_prefs(), build_layout_prefs(), build_logs_prefs(), build_proxy_prefs(), build_sound_tab(), and eb_input_render().

00055 {
00056     GtkWidget *button;
00057     button = gtk_check_button_new_with_label(text);
00058     gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), *value);
00059     gtk_box_pack_start(GTK_BOX(page), button, FALSE, FALSE, 0);
00060     gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_option), value);
00061     gtk_widget_show(button);
00062     return button;
00063 }

void eb_icon GdkWindow *    w
 

Definition at line 157 of file dialog.c.

References icon_bm, and icon_pm.

Referenced by build_prefs(), do_text_input_window(), draw_edit_account_window(), eb_chat_window_new(), eb_info_window_new(), eb_join_chat_room(), eb_new_user(), eb_status_window(), edit_contact_window_new(), edit_group_window_new(), show_about(), show_add_defined_contact_window(), show_away(), show_away2(), and show_trigger_window().

00158 {
00159     GdkAtom icon_atom;
00160     glong data[2];
00161         if (icon_pm == NULL) {
00162                 icon_pm = gdk_pixmap_create_from_xpm_d(w, &icon_bm,
00163                           NULL, (gchar **)yattm_xpm);
00164         }
00165 
00166 #ifndef __MINGW32__
00167         data[0] = ((GdkPixmapPrivate *)icon_pm)->xwindow;
00168         data[1] = ((GdkPixmapPrivate *)icon_bm)->xwindow;
00169 
00170         icon_atom = gdk_atom_intern( "KWM_WIN_ICON", FALSE);
00171         gdk_property_change (w, icon_atom, icon_atom,
00172                 32, GDK_PROP_MODE_REPLACE,
00173                 (guchar *)data, 2);
00174 #endif
00175         gdk_window_set_icon(w, NULL, icon_pm, icon_bm);
00176 //      gdk_window_set_back_pixmap(w, icon_pm, 0 );
00177  //       gdk_window_set_group(w, statuswindow->window);
00178 }

GtkWidget* eb_menu_button GtkMenu *    menu,
gchar *    label,
GtkSignalFunc    callback_func,
gpointer    callback_arg
 

Definition at line 115 of file dialog.c.

Referenced by account_menu(), contact_menu(), and group_menu().

00118 {
00119   GtkWidget * button;
00120   if (label == NULL)
00121       button = gtk_menu_item_new();
00122   else
00123       button = gtk_menu_item_new_with_label(label);
00124   if(callback_func != NULL)
00125       gtk_signal_connect(GTK_OBJECT(button), "activate",
00126             callback_func, callback_arg);
00127   gtk_menu_append(menu, button);
00128   gtk_widget_show(button);
00129 
00130   return (button);
00131 }

GtkWidget* eb_menu_submenu GtkMenu *    menu,
gchar *    label,
GtkWidget *    submenu
 

Definition at line 133 of file dialog.c.

Referenced by contact_menu().

00135 {
00136   GtkWidget * button;
00137   
00138   button = gtk_menu_item_new_with_label(label);
00139   gtk_menu_append(GTK_MENU(menu), button);
00140 
00141   gtk_menu_item_set_submenu (GTK_MENU_ITEM (button), submenu);
00142   gtk_widget_show(button);
00143 
00144   return (button);
00145 }

GtkWidget* eb_push_button const char *    text,
GtkWidget *    page
 

Definition at line 65 of file dialog.c.

Referenced by build_modules_prefs(), and plugin_selected().

00066 {
00067     GtkWidget *button;
00068     button = gtk_button_new_with_label(text);
00069     gtk_box_pack_start(GTK_BOX(page), button, FALSE, FALSE, 0);
00070     gtk_widget_show(button);
00071     return button;
00072 }

GSList* eb_radio GSList *    group,
const char *    text,
int    curr_val,
int    set_val,
GtkWidget *    page,
void *    set_element
 

Definition at line 78 of file dialog.c.

Referenced by build_layout_prefs().

00080 {
00081   GtkWidget * radio;
00082 
00083   /* Create Button w/ or w/out text, as requested */
00084   if (text == NULL)
00085     {
00086       radio = gtk_radio_button_new (group);
00087     }
00088   else
00089     {
00090       radio = gtk_radio_button_new_with_label (group, text);
00091     }
00092 
00093   /* select this button if it should be */
00094   gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(radio),
00095                    (curr_val == set_val));
00096 
00097   /* add this button to whatever box given */
00098   gtk_box_pack_start (GTK_BOX(page), radio, FALSE, FALSE, 0);
00099 
00100   /* Set the callback that we're told to set and the argument */
00101   gtk_signal_connect(GTK_OBJECT(radio), "clicked",
00102              GTK_SIGNAL_FUNC(set_element), (void *) set_val);
00103 
00104   /* Make this visible */
00105   gtk_widget_show (radio);
00106 
00107   /* Return the group */
00108   return (gtk_radio_button_group (GTK_RADIO_BUTTON(radio)));
00109 }

void input_window_destroy GtkWidget *    widget,
gpointer    data
[static]
 

Definition at line 381 of file dialog.c.

Referenced by do_text_input_window().

00382 {
00383     g_free(data);
00384 }

void input_window_ok GtkWidget *    widget,
gpointer    data
[static]
 

Definition at line 386 of file dialog.c.

References _text_input_window::callback, _text_input_window::data, and _text_input_window::text.

Referenced by do_text_input_window().

00387 {
00388     text_input_window * window = (text_input_window*)data;
00389     char * text = gtk_editable_get_chars(GTK_EDITABLE(window->text), 0, -1);
00390     window->callback(text, window->data);
00391 }

void list_dialog_callback GtkWidget *    widget,
gint    row,
gint    column,
GdkEventButton *    event,
gpointer    data
 

Definition at line 180 of file dialog.c.

References _list_dialog_data::callback, and _list_dialog_data::data.

Referenced by do_list_dialog().

00185 {
00186     gchar *text;
00187     list_dialog_data *ldd = data;
00188 
00189     gtk_clist_get_text(GTK_CLIST(widget), row, column, &text);
00190     ldd->callback(strdup(text), ldd->data);
00191     free(ldd);
00192 }

void set_option GtkWidget *    w,
int *    data
[static]
 

Definition at line 49 of file dialog.c.

Referenced by eb_button().

00050 {
00051     *data = !(*data);   
00052 }


Variable Documentation

GdkBitmap* icon_bm = NULL [static]
 

Definition at line 43 of file dialog.c.

Referenced by eb_icon().

GdkPixmap* icon_pm = NULL [static]
 

Definition at line 42 of file dialog.c.

Referenced by eb_icon().


Contact: Andy Maloney     [Documentation generated by doxygen]