Beispiel #1
0
void
ghack_menu_window_display(GtkWidget *menuWin, gboolean blocking,
                          gpointer data)
{
    //if(blocking) {
        gnome_dialog_close_hides (GNOME_DIALOG (menuWin), TRUE);
	gnome_dialog_set_close (GNOME_DIALOG (menuWin), TRUE);
	gnome_dialog_run_and_close(GNOME_DIALOG (menuWin));
    //}
    //else {
        //gtk_widget_show(menuWin);
    //}
}
Beispiel #2
0
/*
 * Sets the properties of the widget. This is used for both applying the
 * properties changed in the property editor, and also for loading.
 */
static void
gb_gnome_dialog_set_properties (GtkWidget * widget, GbWidgetSetArgData * data)
{
  gboolean auto_close, hide_on_close;

  gb_window_set_standard_properties (widget, data,
				     Title, Type, Position, Modal,
				     DefaultWidth, DefaultHeight,
				     Shrink, Grow, AutoShrink,
				     IconName, FocusOnMap,
				     Resizable, DestroyWithParent, Icon,
				     Role, TypeHint, SkipTaskbar,
				     SkipPager, Decorated, Gravity, Urgency);

  auto_close = gb_widget_input_bool (data, AutoClose);
  if (data->apply)
    gnome_dialog_set_close (GNOME_DIALOG (widget), auto_close);

  hide_on_close = gb_widget_input_bool (data, HideOnClose);
  if (data->apply)
    gnome_dialog_close_hides (GNOME_DIALOG (widget), hide_on_close);
}
/*
 * Sets the properties of the widget. This is used for both applying the
 * properties changed in the property editor, and also for loading.
 */
static void
gb_gnome_message_box_set_properties (GtkWidget * widget, GbWidgetSetArgData * data)
{
  GtkWidget *pixmap, *label;
  gchar *message, *type_name;
  gboolean auto_close, hide_on_close;

  get_message_box_widgets (widget, &pixmap, &label);
  g_return_if_fail (pixmap != NULL);
  g_return_if_fail (label != NULL);

  type_name = gb_widget_input_choice (data, MessageBoxType);
  if (data->apply)
    {
      set_message_box_type (widget, pixmap, type_name);
    }

  message = gb_widget_input_text (data, Message);
  if (data->apply)
    {
      gtk_label_set_text (GTK_LABEL (label), message);
    }
  if (data->action == GB_APPLYING)
    g_free (message);

  gb_window_set_standard_properties (widget, data,
				     Title, NULL, Position, Modal,
				     DefaultWidth, DefaultHeight,
				     Shrink, Grow, AutoShrink,
				     WMName, WMClass);

  auto_close = gb_widget_input_bool (data, AutoClose);
  if (data->apply)
    gnome_dialog_set_close (GNOME_DIALOG (widget), auto_close);

  hide_on_close = gb_widget_input_bool (data, HideOnClose);
  if (data->apply)
    gnome_dialog_close_hides (GNOME_DIALOG (widget), hide_on_close);
}
Beispiel #4
0
static PropDlg *
prop_dialog_new (void)
{
	PropDlg *dlg;
	GladeXML *gtxml;

	dlg = g_new0(PropDlg, 1);

	gtxml = gtt_glade_xml_new ("glade/project_properties.glade", "Project Properties");
	dlg->gtxml = gtxml;

	dlg->dlg = GNOME_PROPERTY_BOX (glade_xml_get_widget (gtxml,  "Project Properties"));

	gtk_signal_connect(GTK_OBJECT(dlg->dlg), "help",
	                   GTK_SIGNAL_FUNC(help_cb),
			             "projects-editing");

	gtk_signal_connect(GTK_OBJECT(dlg->dlg), "apply",
			   GTK_SIGNAL_FUNC(prop_set), dlg);

	/* ------------------------------------------------------ */
	/* grab the various entry boxes and hook them up */

	dlg->title      = GTK_ENTRY(TAGGED("title box"));
	dlg->desc       = GTK_ENTRY(TAGGED("desc box"));
	dlg->notes      = GTK_TEXT_VIEW(TEXTED("notes box"));

	dlg->regular    = GTK_ENTRY(TAGGED("regular box"));
	dlg->overtime   = GTK_ENTRY(TAGGED("overtime box"));
	dlg->overover   = GTK_ENTRY(TAGGED("overover box"));
	dlg->flatfee    = GTK_ENTRY(TAGGED("flatfee box"));

	dlg->minimum    = GTK_ENTRY(TAGGED("minimum box"));
	dlg->interval   = GTK_ENTRY(TAGGED("interval box"));
	dlg->gap        = GTK_ENTRY(TAGGED("gap box"));

	dlg->urgency    = MUGGED("urgency menu");
	dlg->importance = MUGGED("importance menu");
	dlg->status     = MUGGED("status menu");

	dlg->start      = DATED("start date");
	dlg->end        = DATED("end date");
	dlg->due        = DATED("due date");

	dlg->sizing     = GTK_ENTRY(TAGGED("sizing box"));
	dlg->percent    = GTK_ENTRY(TAGGED("percent box"));

	/* ------------------------------------------------------ */
	/* initialize menu values */

	MENTRY (dlg->urgency, "urgency", 0, GTT_UNDEFINED);
	MENTRY (dlg->urgency, "urgency", 1, GTT_LOW);
	MENTRY (dlg->urgency, "urgency", 2, GTT_MEDIUM);
	MENTRY (dlg->urgency, "urgency", 3, GTT_HIGH);

	MENTRY (dlg->importance, "importance", 0, GTT_UNDEFINED);
	MENTRY (dlg->importance, "importance", 1, GTT_LOW);
	MENTRY (dlg->importance, "importance", 2, GTT_MEDIUM);
	MENTRY (dlg->importance, "importance", 3, GTT_HIGH);

	MENTRY (dlg->status, "status", 0, GTT_NO_STATUS);
	MENTRY (dlg->status, "status", 1, GTT_NOT_STARTED);
	MENTRY (dlg->status, "status", 2, GTT_IN_PROGRESS);
	MENTRY (dlg->status, "status", 3, GTT_ON_HOLD);
	MENTRY (dlg->status, "status", 4, GTT_CANCELLED);
	MENTRY (dlg->status, "status", 5, GTT_COMPLETED);

	gnome_dialog_close_hides(GNOME_DIALOG(dlg->dlg), TRUE);

	return dlg;
}
Beispiel #5
0
void
ghack_settings_dialog()
{
    int i;
    static GtkWidget* dialog;
    static GtkWidget* swin;
    static GtkWidget* frame1;

    dialog = gnome_dialog_new (_("GnomeHack Settings"),
			    GNOME_STOCK_BUTTON_OK,
			    GNOME_STOCK_BUTTON_CANCEL,
			    NULL);
    gnome_dialog_close_hides (GNOME_DIALOG (dialog), FALSE);
    gtk_signal_connect (GTK_OBJECT (dialog), "key_press_event",
		      GTK_SIGNAL_FUNC (opt_sel_key_hit), tilesets );

    frame1 = gtk_frame_new (_("Choose one of the following tilesets:"));
    gtk_object_set_data (GTK_OBJECT (dialog), "frame1", frame1);
    gtk_widget_show (frame1);
    gtk_container_border_width (GTK_CONTAINER (frame1), 3);

    swin = gtk_scrolled_window_new (NULL, NULL);
    clist = gtk_clist_new (2);
    gtk_clist_column_titles_hide (GTK_CLIST (clist));
    gtk_widget_set_usize (GTK_WIDGET (clist), 100, 180);
    gtk_container_add (GTK_CONTAINER (swin), clist);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
	    GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

    gtk_signal_connect (GTK_OBJECT (clist), "select_row",
			GTK_SIGNAL_FUNC (opt_sel_row_selected), NULL );

    gtk_container_add (GTK_CONTAINER (frame1), swin);
    gtk_box_pack_start_defaults (GTK_BOX (GNOME_DIALOG (dialog)->vbox), frame1);

    /* Add the tilesets into the list here... */
    for (i=0; i < no_tilesets; i++) {
	    gchar accelBuf[BUFSZ];
	    const char *text[3]={accelBuf, tilesets[i].name,NULL};
	    if ((tilesets[i].flags & ~TILESET_TRANSPARENT) != 0)
		continue;		/* Unsupported flag set */
	    sprintf( accelBuf, "%c ", tolower(tilesets[i].name[0]));
	    gtk_clist_insert (GTK_CLIST (clist), i, (char**)text);
    }


    gtk_clist_columns_autosize (GTK_CLIST (clist));
    gtk_widget_show_all (swin);

    /* Center the dialog over over parent */
    gnome_dialog_set_default( GNOME_DIALOG(dialog), 0);
    gtk_window_set_modal( GTK_WINDOW(dialog), TRUE);
    gnome_dialog_set_parent (GNOME_DIALOG (dialog),
	    GTK_WINDOW (ghack_get_main_window ()) );

    /* Run the dialog -- returning whichever button was pressed */
    i = gnome_dialog_run (GNOME_DIALOG (dialog));
    gnome_dialog_close (GNOME_DIALOG (dialog));

    /* They hit Quit or error */
    if (i != 0 ) {
	return;
    }
    if (gn_tileset < no_tilesets) {
	    if (tilesets[gn_tileset].file[0] != '/') {
		char *path;
		path = (char *)alloc(strlen(TILESETDIR) +
		  strlen(tilesets[gn_tileset].file) + 2);
		sprintf(path, TILESETDIR "/%s", tilesets[gn_tileset].file);
		ghack_free_glyphs();
		if (ghack_init_glyphs(path))
			  g_error ("ERROR:  Could not initialize glyphs.\n");
		free(path);
	    }
	    else {
		ghack_free_glyphs();
		if (ghack_init_glyphs(tilesets[gn_tileset].file))
			  g_error ("ERROR:  Could not initialize glyphs.\n");
	    }
	    ghack_reinit_map_window();
    } else {
	    /* This shouldn't happen */
	    g_warning("This shouldn't happen\n");
    }
}
Beispiel #6
0
int
ghack_player_sel_dialog(const char** choices,
			const gchar* title,
			const gchar* prompt)
{
    int i;
    static GtkWidget* dialog;
    static GtkWidget* swin;
    static GtkWidget* frame1;

    dialog = gnome_dialog_new(title,
			    GNOME_STOCK_BUTTON_OK,
			    _("Random"),
			    GNOME_STOCK_BUTTON_CANCEL,
			    NULL);
    gnome_dialog_close_hides (GNOME_DIALOG (dialog), FALSE);
    gtk_signal_connect (GTK_OBJECT (dialog), "key_press_event",
                      GTK_SIGNAL_FUNC (player_sel_key_hit), choices );

    frame1 = gtk_frame_new(prompt);
    gtk_object_set_data (GTK_OBJECT (dialog), "frame1", frame1);
    gtk_widget_show (frame1);
    gtk_container_border_width (GTK_CONTAINER (frame1), 3);

    swin = gtk_scrolled_window_new (NULL, NULL);
    clist = gtk_clist_new (2);
    gtk_clist_column_titles_hide (GTK_CLIST (clist));
    gtk_widget_set_usize (GTK_WIDGET (clist), 100, 180);
    gtk_container_add (GTK_CONTAINER (swin), clist);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
	    GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

    gtk_signal_connect (GTK_OBJECT (clist), "select_row",
			GTK_SIGNAL_FUNC (player_sel_row_selected), NULL );

    gtk_container_add (GTK_CONTAINER (frame1), swin);
    gtk_box_pack_start_defaults (GTK_BOX (GNOME_DIALOG (dialog)->vbox), frame1);

    /* Add the roles into the list here... */
    for (i=0; choices[i]; i++) {
	    gchar accelBuf[BUFSZ];
	    const char *text[3]={accelBuf, choices[i],NULL};
	    sprintf( accelBuf, "%c ", tolower(choices[i][0]));
	    gtk_clist_insert (GTK_CLIST (clist), i, (char**)text);
    }

    gtk_clist_columns_autosize (GTK_CLIST (clist));
    gtk_widget_show_all (swin);

    /* Center the dialog over over parent */
    gnome_dialog_set_default( GNOME_DIALOG(dialog), 0);
    gtk_window_set_modal( GTK_WINDOW(dialog), TRUE);
    gnome_dialog_set_parent (GNOME_DIALOG (dialog),
	    GTK_WINDOW (ghack_get_main_window ()) );

    /* Run the dialog -- returning whichever button was pressed */
    i = gnome_dialog_run_and_close(GNOME_DIALOG(dialog));

    /* Quit on button 2 or error */
    if (i < 0  || i > 1) {
	return(ROLE_NONE);
    }
    /* Random is button 1*/
    if (i == 1 ) {
	return(ROLE_RANDOM);
    }
    return ( role_number);
}
Beispiel #7
0
int
ghack_menu_ext_cmd(void)
{
    int n;
    GtkWidget* dialog;
    GtkWidget* swin;
    GtkWidget* frame1;
    GtkWidget* clist;
    extMenu info;

    dialog = gnome_dialog_new("Extended Commands",
			      GNOME_STOCK_BUTTON_OK,
			      GNOME_STOCK_BUTTON_CANCEL,
			      NULL);
    gnome_dialog_close_hides(GNOME_DIALOG(dialog), FALSE);
    gtk_signal_connect(GTK_OBJECT(dialog), "key_press_event",
		       GTK_SIGNAL_FUNC(ghack_ext_key_hit), &info);

    frame1 = gtk_frame_new("Make your selection");
    gtk_object_set_data(GTK_OBJECT(dialog), "frame1", frame1);
    gtk_widget_show(frame1);
    gtk_container_border_width(GTK_CONTAINER(frame1), 3);

    swin = gtk_scrolled_window_new(NULL, NULL);
    clist = gtk_clist_new(2);
    gtk_object_set_data(GTK_OBJECT(dialog), "clist", clist);
    gtk_widget_set_usize(clist, 500, 400);
    gtk_container_add(GTK_CONTAINER(swin), clist);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin),
				   GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

    gtk_signal_connect(GTK_OBJECT(clist), "select_row",
		       GTK_SIGNAL_FUNC(ghack_menu_row_selected), NULL);

    gtk_container_add(GTK_CONTAINER(frame1), swin);
    gtk_box_pack_start_defaults(GTK_BOX(GNOME_DIALOG(dialog)->vbox), frame1);

    /* Add the extended commands into the list here... */
    for (n = 0; extcmdlist[n].ef_txt; ++n) {
	const char *text[3]={extcmdlist[n].ef_txt,extcmdlist[n].ef_desc,NULL};
	gtk_clist_insert(GTK_CLIST(clist), n, (char**) text);
    }

    /* fill in starting info fields */
    info.curItem = -1;
    info.numRows = n;
    info.charIdx = 0;
    info.lastTime = 0;

    gtk_clist_columns_autosize(GTK_CLIST(clist));
    gtk_widget_show_all(swin);

    /* Center the dialog over over parent */
    gnome_dialog_set_default(GNOME_DIALOG(dialog), 0);
    gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
    gnome_dialog_set_parent(GNOME_DIALOG(dialog),
			    GTK_WINDOW(ghack_get_main_window()));

    /* Run the dialog -- returning whichever button was pressed */
    n = gnome_dialog_run_and_close(GNOME_DIALOG(dialog));

    /* Quit on button 2 or error */
    return (n != 0) ? -1 : info.curItem;
}
Beispiel #8
0
int 
ghack_menu_window_select_menu (GtkWidget *menuWin, 
	MENU_ITEM_P **_selected, gint how)
{
   gint rc;
   guint num_sel, i, idx;
   GtkWidget *clist;
   GList *cur;
   MENU_ITEM_P *selected = NULL;
   menuItem*	item;

   g_assert (_selected != NULL);
   *_selected = NULL;


   if (how == PICK_NONE) {
     gnome_dialog_close_hides (GNOME_DIALOG (menuWin), TRUE);
     rc = gnome_dialog_run_and_close (GNOME_DIALOG (menuWin));
     return( rc == 1 ? -1 : 0);
   }

   clist = GTK_WIDGET (gtk_object_get_data (GTK_OBJECT (menuWin), "clist"));
   g_assert (clist != NULL);

   gtk_object_set_data (GTK_OBJECT (clist), "selection_mode",
                   GINT_TO_POINTER ((how == PICK_ANY)? 
		       GTK_SELECTION_MULTIPLE : GTK_SELECTION_SINGLE));
   gtk_clist_set_selection_mode (GTK_CLIST (clist), 
	   (how == PICK_ANY)? GTK_SELECTION_MULTIPLE : GTK_SELECTION_SINGLE);
   gnome_dialog_close_hides (GNOME_DIALOG (menuWin), TRUE);
   rc = gnome_dialog_run_and_close (GNOME_DIALOG (menuWin));
   if ((rc == 1) || (GTK_CLIST (clist)->selection == NULL)) {
     return(-1);
   }

   num_sel = g_list_length (GTK_CLIST (clist)->selection);
   if (num_sel < 1) {
     return(-1);
   }

   /* fill in array with selections from clist */
   selected =  g_new0( MENU_ITEM_P, num_sel);
   g_assert (selected != NULL);
   cur = GTK_CLIST (clist)->selection;
   i = 0;
   while (cur) {
     g_assert (i < num_sel);

     /* grab row number from clist selection list */
     idx = GPOINTER_TO_INT (cur->data);

     item = (menuItem*) gtk_clist_get_row_data( GTK_CLIST (clist), idx);
     selected[i].item = item->identifier;
     selected[i].count = -1;
     cur = g_list_next(cur);
     i++;
   }

   *_selected = selected;

   return( (int) num_sel);
}