示例#1
0
/*
 * Creates a new GtkWidget of class GtkInputDialog, performing any specialized
 * initialization needed for the widget to work correctly in this environment.
 * If a dialog box is used to initialize the widget, return NULL from this
 * function, and call data->callback with your new widget when it is done.
 * If the widget needs a special destroy handler, add a signal here.
 */
GtkWidget*
gb_input_dialog_new (GbWidgetNewData *data)
{
  GtkWidget *new_widget = gtk_input_dialog_new ();

  GtkInputDialog *inputdlg = GTK_INPUT_DIALOG (new_widget);

  /* We want it to be treated as a normal window. */
  gtk_window_set_type_hint (GTK_WINDOW (new_widget),
			    GDK_WINDOW_TYPE_HINT_NORMAL);

  gtk_signal_connect (GTK_OBJECT (new_widget), "delete_event",
		      GTK_SIGNAL_FUNC (editor_close_window), NULL);

  gb_widget_create_from (inputdlg->save_button,
			 data->action == GB_CREATING ? "save_button" : NULL);
  gb_widget_set_child_name (inputdlg->save_button, GladeChildSaveButton);
  /* We need to set it sensitive so the user can select it. */
  gtk_widget_set_sensitive (inputdlg->save_button, TRUE);

  gb_widget_create_from (inputdlg->close_button,
			 data->action == GB_CREATING ? "close_button" : NULL);
  gb_widget_set_child_name (inputdlg->close_button, GladeChildCloseButton);

  gtk_object_set_data (GTK_OBJECT (new_widget), TypeHint,
		       GINT_TO_POINTER (GLADE_TYPE_HINT_DIALOG_INDEX));

  return new_widget;
}
/*
 * Creates a new GtkWidget of class GnomeMessageBox, performing any specialized
 * initialization needed for the widget to work correctly in this environment.
 * If a dialog box is used to initialize the widget, return NULL from this
 * function, and call data->callback with your new widget when it is done.
 * If the widget needs a special destroy handler, add a signal here.
 */
static GtkWidget*
gb_gnome_message_box_new (GbWidgetNewData *data)
{
  GtkWidget *new_widget;
  GList *elem;

  if (data->action == GB_CREATING)
    {
      /* When creating a new dialog, we add a few standard buttons, which
	 the user can change/delete easily. */
      new_widget = gnome_message_box_new ("", GNOME_MESSAGE_BOX_INFO,
					  GNOME_STOCK_BUTTON_OK, NULL);

      /* Now turn the buttons into GbWidgets so the user can edit them. */
      elem = GNOME_DIALOG (new_widget)->buttons;
      gb_widget_create_from (GTK_WIDGET (elem->data), "button");
      gtk_object_set_data (GTK_OBJECT (elem->data), "GtkButton::stock_button",
			   GINT_TO_POINTER (GladeStockButtonOK));
    }
  else
    {
      /* FIXME: We create it with an OK button, and then remove the button,
	 to work around a bug in gnome_message_box_new() - it tries to set the
	 keyboard focus to the last button, which may not exist. It also
	 ensures that gnome_dialog_init_action_area() has been called. */
      new_widget = gnome_message_box_new ("",  GNOME_MESSAGE_BOX_INFO,
					  GNOME_STOCK_BUTTON_OK, NULL);

      gtk_container_remove (GTK_CONTAINER (GNOME_DIALOG (new_widget)->action_area), GNOME_DIALOG (new_widget)->buttons->data);
      GNOME_DIALOG (new_widget)->buttons = NULL;
    }

  gb_widget_create_from (GNOME_DIALOG (new_widget)->vbox,
			 data->action == GB_CREATING ? "dialog-vbox" : NULL);
  gb_widget_set_child_name (GNOME_DIALOG (new_widget)->vbox, DialogVBox);

  gb_widget_create_from (GNOME_DIALOG (new_widget)->action_area,
			 data->action == GB_CREATING ? "dialog-action_area"
						     : NULL);
  gb_widget_set_child_name (GNOME_DIALOG (new_widget)->action_area,
			    DialogActionArea);

  /* We connect a close signal handler which always returns TRUE so that
     the built-in close functionality is skipped. */
  gtk_signal_connect (GTK_OBJECT (new_widget), "close",
		      GTK_SIGNAL_FUNC (gtk_true), NULL);

  /* Now we connect our normal delete_event handler. */
  gtk_signal_connect (GTK_OBJECT (new_widget), "delete_event",
		      GTK_SIGNAL_FUNC (editor_close_window), NULL);

  return new_widget;
}
示例#3
0
/*
 * Creates a new GtkWidget of class GnomeApp, performing any specialized
 * initialization needed for the widget to work correctly in this environment.
 * If a dialog box is used to initialize the widget, return NULL from this
 * function, and call data->callback with your new widget when it is done.
 * If the widget needs a special destroy handler, add a signal here.
 */
static GtkWidget*
gb_gnome_app_new (GbWidgetNewData *data)
{
  GtkWidget *new_widget;
  gchar *project_name;

  project_name = glade_project_get_name (data->project);
  new_widget = gnome_app_new (project_name ? project_name : "", project_name);
  gtk_object_set_data (GTK_OBJECT (new_widget), EnableLayoutConfig,
		       GINT_TO_POINTER (TRUE));

  /* Turn off the automatic loading/saving of the configuration, and
     destroy the BonoboDockLayout, so that when items are added they are
     added straight away. If we don't do this, items don't get added to
     the widget tree. */
  gnome_app_enable_layout_config (GNOME_APP (new_widget), FALSE);
  g_object_unref (G_OBJECT (GNOME_APP (new_widget)->layout));
  GNOME_APP (new_widget)->layout = NULL;

  gtk_signal_connect (GTK_OBJECT (new_widget), "delete_event",
		      GTK_SIGNAL_FUNC (editor_close_window), NULL);

  gb_widget_create_from (GNOME_APP (new_widget)->dock,
			 data->action == GB_CREATING ? "BonoboDock" : NULL);
  gb_widget_set_child_name (GNOME_APP (new_widget)->dock, GladeChildGnomeAppDock);

  if (data->action == GB_CREATING)
    gb_gnome_app_setup_initial_app (new_widget);

  return new_widget;
}
示例#4
0
static GtkWidget *
new_label (GtkWidget * parent)
{
  GtkWidget *label;

  label = gb_widget_new ("GtkLabel", parent);
  g_return_val_if_fail (label != NULL, NULL);
  gb_widget_set_child_name (label,CListTitle);
  return label;
}
示例#5
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_app_set_properties (GtkWidget * widget, GbWidgetSetArgData * data)
{
  gboolean statusbar, enable_layout_config;

  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);

  if (data->action == GB_APPLYING)
    {
      statusbar = gb_widget_input_bool (data, StatusBar);
      if (data->apply)
	{
	  if (statusbar)
	    {
	      if (!GNOME_APP (widget)->statusbar)
		{
		  gnome_app_set_statusbar (GNOME_APP (widget),
					   gb_widget_new ("GnomeAppBar",
							  widget));
		  gb_widget_set_child_name (GNOME_APP (widget)->statusbar,
					    GladeChildGnomeAppBar);
		  tree_add_widget (GNOME_APP (widget)->statusbar);
		}
	    }
	  else
	    {
	      if (GNOME_APP (widget)->statusbar)
		{
		  /* This is not very clean, but there's no proper way to
		     remove the statusbar. The statusbar has an hbox inserted
		     above it which is added to the GnomeApp's vbox, so we
		     remove the hbox. */
		  GtkWidget *hbox = GNOME_APP (widget)->statusbar->parent;
		  gtk_container_remove (GTK_CONTAINER (hbox->parent), hbox);
		  GNOME_APP (widget)->statusbar = NULL;
		}
	    }
	}
    }

  enable_layout_config = gb_widget_input_bool (data, EnableLayoutConfig);
  if (data->apply)
    {
      gtk_object_set_data (GTK_OBJECT (widget), EnableLayoutConfig,
			   GINT_TO_POINTER (enable_layout_config));
    }
}
示例#6
0
static GtkWidget *
new_unnamed_label (GtkWidget * parent)
{
  GtkWidget *label;

  label = gb_widget_new_full ("GtkLabel", FALSE, parent, NULL, 0, 0, NULL,
			      GB_CREATING, NULL);
  g_return_val_if_fail (label != NULL, NULL);
  gb_widget_set_child_name (label, CListTitle);
  return label;
}
示例#7
0
/*
 * Creates a new GtkWidget of class GtkFileSelection, performing any specialized
 * initialization needed for the widget to work correctly in this environment.
 * If a dialog box is used to initialize the widget, return NULL from this
 * function, and call data->callback with your new widget when it is done.
 * If the widget needs a special destroy handler, add a signal here.
 */
GtkWidget *
gb_file_selection_new (GbWidgetNewData * data)
{
  GtkWidget *new_widget = gtk_file_selection_new (_("Select File"));

  GtkFileSelection *filesel = GTK_FILE_SELECTION (new_widget);

  /* We want it to be treated as a normal window. */
  gtk_window_set_type_hint (GTK_WINDOW (new_widget),
			    GDK_WINDOW_TYPE_HINT_NORMAL);

  gtk_signal_connect (GTK_OBJECT (new_widget), "delete_event",
		      GTK_SIGNAL_FUNC (editor_close_window), NULL);

  gb_widget_create_from (filesel->ok_button,
			 data->action == GB_CREATING ? "ok_button" : NULL);
  gb_widget_set_child_name (filesel->ok_button, GladeChildOKButton);

  gb_widget_create_from (filesel->cancel_button,
			 data->action == GB_CREATING ? "cancel_button" : NULL);
  gb_widget_set_child_name (filesel->cancel_button, GladeChildCancelButton);

  return new_widget;
}
示例#8
0
/*
 * Creates a new GtkWidget of class GtkCombo, performing any specialized
 * initialization needed for the widget to work correctly in this environment.
 * If a dialog box is used to initialize the widget, return NULL from this
 * function, and call data->callback with your new widget when it is done.
 * If the widget needs a special destroy handler, add a signal here.
 */
GtkWidget*
gb_combo_new(GbWidgetNewData *data)
{
  GtkWidget *new_widget;

  new_widget = gtk_combo_new ();

  gb_widget_create_from (GTK_COMBO (new_widget)->entry,
			 data->action == GB_CREATING ? "combo-entry" : NULL);
  gb_widget_set_child_name (GTK_COMBO (new_widget)->entry, ComboEntry);

  /* This defaults to TRUE. */
  gtk_object_set_data (GTK_OBJECT (new_widget), OKIfEmpty, "TRUE");

  return new_widget;
}
示例#9
0
static void
gb_gnome_app_setup_initial_app (GtkWidget *widget)
{
  GtkWidget *placeholder, *toolbar;

  /* We create a standard menubar and toolbar which the user can edit or
     simply delete anything they don't want. */
  glade_gnome_setup_initial_menus (widget);

  /* We need to get rid of the accelerators, since they aren't used, and
     they would override our default accelerators. */
  gtk_window_remove_accel_group (GTK_WINDOW (widget),
				 GNOME_APP (widget)->accel_group);

  /* FIXME: GnomeLibs bug workaround. It sets the initial border width
     to -2, which causes us lots of problems. */
#if 0
  gtk_container_set_border_width (GTK_CONTAINER (GNOME_APP (widget)->menubar),
				  0);
#endif
  gb_widget_create_from (GNOME_APP (widget)->menubar, "GtkMenubar");
  gb_widget_create_from (GNOME_APP (widget)->menubar->parent, "BonoboDockItem");

  /* Toolbar */
  toolbar = gtk_toolbar_new ();
  gnome_app_set_toolbar (GNOME_APP (widget), GTK_TOOLBAR (toolbar));
  gb_widget_create_from (toolbar, "GtkToolbar");
  gb_widget_create_from (toolbar->parent, "BonoboDockItem");

  gb_gnome_app_add_toolbar_button (GTK_TOOLBAR (toolbar), GTK_STOCK_NEW,
				   _("New File"));
  gb_gnome_app_add_toolbar_button (GTK_TOOLBAR (toolbar), GTK_STOCK_OPEN,
				   _("Open File"));
  gb_gnome_app_add_toolbar_button (GTK_TOOLBAR (toolbar), GTK_STOCK_SAVE,
				   _("Save File"));


  /* Statusbar */
  gnome_app_set_statusbar (GNOME_APP (widget),
			   gb_widget_new ("GnomeAppBar", widget));
  gb_widget_set_child_name (GNOME_APP (widget)->statusbar, GladeChildGnomeAppBar);

  /* We need to size the placeholders or the dialog is very small. */
  placeholder = editor_new_placeholder ();
  gtk_widget_set_usize (placeholder, 300, 200);
  gnome_app_set_contents (GNOME_APP (widget), placeholder);
}
示例#10
0
/*
 * Creates a new GtkWidget of class GnomeDruidPageStandard, performing any specialized
 * initialization needed for the widget to work correctly in this environment.
 * If a dialog box is used to initialize the widget, return NULL from this
 * function, and call data->callback with your new widget when it is done.
 */
static GtkWidget*
gb_gnome_druid_page_standard_new (GbWidgetNewData *data)
{
  GtkWidget *new_widget, *placeholder;

  if (data->action == GB_CREATING)
    {
      new_widget = gnome_druid_page_standard_new_with_vals ("", NULL, NULL);
      placeholder = editor_new_placeholder ();
      gtk_box_pack_start (GTK_BOX (GNOME_DRUID_PAGE_STANDARD (new_widget)->vbox),
			  placeholder, TRUE, TRUE, 0);
    }
  else
    {
      new_widget = gnome_druid_page_standard_new_with_vals ("", NULL, NULL);
    }
  gb_widget_create_from (GNOME_DRUID_PAGE_STANDARD (new_widget)->vbox,
			 "druid-vbox");
  gb_widget_set_child_name (GNOME_DRUID_PAGE_STANDARD (new_widget)->vbox,
			    GladeChildGnomeDruidVBox);
  gtk_widget_show_all (new_widget);
  return new_widget;
}
示例#11
0
/*
 * Creates a new GtkWidget of class GnomeDialog, performing any specialized
 * initialization needed for the widget to work correctly in this environment.
 * If a dialog box is used to initialize the widget, return NULL from this
 * function, and call data->callback with your new widget when it is done.
 * If the widget needs a special destroy handler, add a signal here.
 */
static GtkWidget*
gb_gnome_dialog_new (GbWidgetNewData *data)
{
  GtkWidget *new_widget, *placeholder;
  GList *elem;

  if (data->action == GB_CREATING)
    {
      /* When creating a new dialog, we add a few standard buttons, which
	 the user can change/delete easily. */
      new_widget = gnome_dialog_new (NULL, 
				     GTK_STOCK_CANCEL, 
				     GTK_STOCK_OK,
				     NULL);

      /* Now turn the buttons into GbWidgets so the user can edit them. */
      elem = GNOME_DIALOG (new_widget)->buttons;
      gb_widget_create_from (GTK_WIDGET (elem->data), "button");
      gtk_object_set_data (GTK_OBJECT (elem->data), GladeButtonStockIDKey,
			   GTK_STOCK_CANCEL);

      elem = elem->next;
      gb_widget_create_from (GTK_WIDGET (elem->data), "button");
      gtk_object_set_data (GTK_OBJECT (elem->data), GladeButtonStockIDKey,
			   GTK_STOCK_OK);

      /* We need to size the placeholders or the dialog is very small. */
      placeholder = editor_new_placeholder ();
      gtk_widget_set_usize (placeholder, 300, 200);
      gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (new_widget)->vbox),
			  placeholder, TRUE, TRUE, 0);
    }
  else
    {
      /* When loading we create the bare dialog with no buttons. */
      new_widget = gnome_dialog_new (NULL, NULL);
    }

  gb_widget_create_from (GNOME_DIALOG (new_widget)->vbox,
			 data->action == GB_CREATING ? "dialog-vbox" : NULL);
  gb_widget_set_child_name (GNOME_DIALOG (new_widget)->vbox, GladeChildDialogVBox);

  gb_widget_create_from (GNOME_DIALOG (new_widget)->action_area,
			 data->action == GB_CREATING ? "dialog-action_area"
						     : NULL);
  gb_widget_set_child_name (GNOME_DIALOG (new_widget)->action_area,
			    GladeChildDialogActionArea);

  /* We connect a close signal handler which always returns TRUE so that
     the built-in close functionality is skipped. */
  gtk_signal_connect (GTK_OBJECT (new_widget), "close",
		      GTK_SIGNAL_FUNC (gtk_true), NULL);

  /* Now we connect our normal delete_event handler. */
  gtk_signal_connect (GTK_OBJECT (new_widget), "delete_event",
		      GTK_SIGNAL_FUNC (editor_close_window), NULL);

  gtk_object_set_data (GTK_OBJECT (new_widget), TypeHint,
		       GINT_TO_POINTER (GLADE_TYPE_HINT_DIALOG_INDEX));

  return new_widget;
}