Exemplo n.º 1
0
/*
 * Writes the source code needed to create this widget.
 * You have to output everything necessary to create the widget here, though
 * there are some convenience functions to help.
 */
static void
gb_label_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data)
{
  if (data->create_widget)
    {
      const gchar *label_text = gtk_label_get_label (GTK_LABEL (widget));

      if (gtk_label_get_use_underline (GTK_LABEL (widget)))
	source_add (data, "  %s = gtk_label_new_with_mnemonic (%s);\n",
		    data->wname,
		    source_make_string (label_text, data->use_gettext));
      else
	source_add (data, "  %s = gtk_label_new (%s);\n",
		    data->wname,
		    source_make_string (label_text, data->use_gettext));
    }

  gb_widget_write_standard_source (widget, data);

  gb_label_write_standard_source (widget, data,
				  Label, UseUnderline, UseMarkup,
				  Justify, Wrap, Selectable,
				  XAlign, YAlign, XPad, YPad,
				  FocusTarget);
}
Exemplo n.º 2
0
/*
 * Writes the source code needed to create this widget.
 * You have to output everything necessary to create the widget here, though
 * there are some convenience functions to help.
 */
static void
gb_menu_item_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data)
{
  GtkWidget *child = GTK_BIN (widget)->child;
  gchar *label_text;
  gboolean translatable, context;
  gchar *comments;

#ifdef USE_GNOME
  if (data->project->gnome_support)
    {
      glade_gnome_write_menu_item_source (GTK_MENU_ITEM (widget), data);
      return;
    }
#endif

  if (child && GTK_IS_LABEL (child) && !GB_IS_GB_WIDGET (child))
    {
      glade_util_get_translation_properties (widget, Label, &translatable,
					     &comments, &context);
      source_add_translator_comments (data, translatable, comments);

      label_text = glade_util_get_label_text (child);
      source_add (data, "  %s = gtk_menu_item_new_with_mnemonic (%s);\n",
		  data->wname,
		  source_make_string_full (label_text, data->use_gettext && translatable, context));
      g_free (label_text);
    }
  else
    {
      source_add (data, "  %s = gtk_menu_item_new ();\n", data->wname);
    }

  gb_widget_write_standard_source (widget, data);
}
Exemplo n.º 3
0
/*
 * Writes the source code needed to create this widget.
 * You have to output everything necessary to create the widget here, though
 * there are some convenience functions to help.
 */
static void
gb_font_selection_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data)
{
  const gchar *preview_text;

  if (data->create_widget)
    {
      source_add (data, "  %s = gtk_font_selection_new ();\n", data->wname);
    }

  gb_widget_write_standard_source (widget, data);

  preview_text = gtk_font_selection_get_preview_text (GTK_FONT_SELECTION (widget));
  if (strcmp (preview_text, DEFAULT_PREVIEW_TEXT))
    {
      gboolean translatable, context;
      gchar *comments;

      glade_util_get_translation_properties (widget, PreviewText,
					     &translatable,
					     &comments, &context);
      source_add_translator_comments (data, translatable, comments);

      source_add (data,
	"  gtk_font_selection_set_preview_text (GTK_FONT_SELECTION (%s), %s);\n",
		  data->wname,
		  source_make_string_full (preview_text, data->use_gettext && translatable, context));
    }
}
Exemplo n.º 4
0
/*
 * Writes the source code needed to create this widget.
 * You have to output everything necessary to create the widget here, though
 * there are some convenience functions to help.
 */
static void
gb_accel_label_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data)
{
    gboolean translatable, context;
    gchar *comments;

    if (data->create_widget)
    {
        const gchar *label_text = gtk_label_get_label (GTK_LABEL (widget));

        glade_util_get_translation_properties (widget, Label, &translatable,
                                               &comments, &context);
        source_add_translator_comments (data, translatable, comments);

        source_add (data, "  %s = gtk_accel_label_new (%s);\n", data->wname,
                    source_make_string_full (label_text,
                                             data->use_gettext && translatable,
                                             context));
    }

    gb_widget_write_standard_source (widget, data);

    if (gtk_label_get_use_underline (GTK_LABEL (widget)))
        source_add (data,
                    "  gtk_label_set_use_underline (GTK_LABEL (%s), TRUE);\n",
                    data->wname);

    gb_label_write_standard_source (widget, data,
                                    Label, UseUnderline, UseMarkup,
                                    Justify, Wrap, Selectable,
                                    XAlign, YAlign, XPad, YPad,
                                    FocusTarget, Ellipsize, WidthChars,
                                    SingleLineMode, Angle);
}
Exemplo n.º 5
0
/*
 * Writes the source code needed to create this widget.
 * You have to output everything necessary to create the widget here, though
 * there are some convenience functions to help.
 */
static void
gb_vbutton_box_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data)
{
  GtkButtonBoxStyle layout_style;
  gint spacing, i;

  if (data->create_widget)
    {
      source_add (data, "  %s = gtk_vbutton_box_new ();\n", data->wname);
    }

  gb_widget_write_standard_source (widget, data);

  layout_style = GTK_BUTTON_BOX (widget)->layout_style;
  if (layout_style != GTK_BUTTONBOX_DEFAULT_STYLE)
    {
      for (i = 0; i < sizeof (GbLayoutValues) / sizeof (GbLayoutValues[0]); i
	   ++)
	{
	  if (GbLayoutValues[i] == layout_style)
	    source_add (data,
		 "  gtk_button_box_set_layout (GTK_BUTTON_BOX (%s), %s);\n",
			data->wname, GbLayoutSymbols[i]);
	}
    }

  spacing = gtk_box_get_spacing (GTK_BOX (widget));
  if (spacing != 0)
    {
      source_add (data,
		"  gtk_box_set_spacing (GTK_BOX (%s), %i);\n",
		  data->wname, spacing);
    }
}
Exemplo n.º 6
0
/* Outputs source to add a child widget to a hbuttonbox. We need to check if
   the hbuttonbox is a GtkDialog action area, and if it is we use the special
   gtk_dialog_add_action_widget() function to add it. */
void
gb_hbutton_box_write_add_child_source (GtkWidget * parent,
                                       const gchar *parent_name,
                                       GtkWidget *child,
                                       GbWidgetWriteSourceData * data)
{
    if (gb_hbutton_box_is_dialog_action_area (parent)
            && G_OBJECT_TYPE (child) == GTK_TYPE_BUTTON)
    {
        gint response_id;
        char *response_name, *dialog_name;

        response_id = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (child), GladeDialogResponseIDKey));
        response_name = gb_dialog_response_id_to_string (response_id);

        dialog_name = (char*) gtk_widget_get_name (parent->parent->parent);
        dialog_name = source_create_valid_identifier (dialog_name);

        source_add (data,
                    "  gtk_dialog_add_action_widget (GTK_DIALOG (%s), %s, %s);\n",
                    dialog_name, data->wname, response_name);

        g_free (dialog_name);
    }
    else
    {
        /* Use the standard gtk_container_add(). */
        source_add (data, "  gtk_container_add (GTK_CONTAINER (%s), %s);\n",
                    parent_name, data->wname);
    }
}
Exemplo n.º 7
0
/*
 * Writes the source code needed to create this widget.
 * You have to output everything necessary to create the widget here, though
 * there are some convenience functions to help.
 */
static void
gb_tool_item_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data)
{
  if (data->create_widget)
    {
      source_add (data,
		  "  %s = (GtkWidget*) gtk_tool_item_new ();\n",
		  data->wname);
    }

  gb_widget_write_standard_source (widget, data);

  if (gtk_object_get_data (GTK_OBJECT (widget), VisibleHorz) != NULL)
    {
      source_add (data,
		  "  gtk_tool_item_set_visible_horizontal (GTK_TOOL_ITEM (%s), FALSE);\n",
		  data->wname);
    }

  if (gtk_object_get_data (GTK_OBJECT (widget), VisibleVert) != NULL)
    {
      source_add (data,
		  "  gtk_tool_item_set_visible_vertical (GTK_TOOL_ITEM (%s), FALSE);\n",
		  data->wname);
    }

  if (gtk_tool_item_get_is_important (GTK_TOOL_ITEM (widget)))
    {
      source_add (data,
		  "  gtk_tool_item_set_is_important (GTK_TOOL_ITEM (%s), TRUE);\n",
		  data->wname);
    }
}
Exemplo n.º 8
0
/*
 * Writes the source code needed to create this widget.
 * You have to output everything necessary to create the widget here, though
 * there are some convenience functions to help.
 */
static void
gb_list_item_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data)
{
  GtkWidget *child = GTK_BIN (widget)->child;
  const gchar *label_text;
  gboolean translatable, context;
  gchar *comments;

  if (data->create_widget)
    {
      if (child && GTK_IS_LABEL (child) && !GB_IS_GB_WIDGET (child))
	{
	  glade_util_get_translation_properties (widget, Label, &translatable,
						 &comments, &context);
	  source_add_translator_comments (data, translatable, comments);

	  label_text = gtk_label_get_text (GTK_LABEL (child));
	  source_add (data, "  %s = gtk_list_item_new_with_label (%s);\n",
		      data->wname,
		      source_make_string_full (label_text, data->use_gettext && translatable, context));
	}
      else
	{
	  source_add (data, "  %s = gtk_list_item_new ();\n", data->wname);
	}
    }

  gb_widget_write_standard_source (widget, data);
}
Exemplo n.º 9
0
/*
 * Writes the source code needed to create this widget.
 * You have to output everything necessary to create the widget here, though
 * there are some convenience functions to help.
 */
static void
gb_vbutton_box_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data)
{
  GtkButtonBoxStyle layout_style;
  gint spacing, default_spacing, i;
  gint min_width, min_height, ipad_x, ipad_y;
  gint default_min_width, default_min_height, default_ipad_x, default_ipad_y;

  if (data->create_widget)
    {
      source_add (data, "  %s = gtk_vbutton_box_new ();\n", data->wname);
    }

  gb_widget_write_standard_source (widget, data);

  layout_style = GTK_BUTTON_BOX (widget)->layout_style;
  if (layout_style != GTK_BUTTONBOX_DEFAULT_STYLE)
    {
      for (i = 0; i < sizeof (GbLayoutValues) / sizeof (GbLayoutValues[0]); i
	   ++)
	{
	  if (GbLayoutValues[i] == layout_style)
	    source_add (data,
		 "  gtk_button_box_set_layout (GTK_BUTTON_BOX (%s), %s);\n",
			data->wname, GbLayoutSymbols[i]);
	}
    }

  spacing = gtk_button_box_get_spacing (GTK_BUTTON_BOX (widget));
  default_spacing = gtk_vbutton_box_get_spacing_default ();
  if (spacing != GTK_BUTTONBOX_DEFAULT && spacing != default_spacing)
    {
      source_add (data,
		"  gtk_button_box_set_spacing (GTK_BUTTON_BOX (%s), %i);\n",
		  data->wname, spacing);
    }

  gtk_button_box_get_child_size_default (&default_min_width,
					 &default_min_height);
  gtk_button_box_get_child_size (GTK_BUTTON_BOX (widget), &min_width,
				 &min_height);
  if ((min_width != GTK_BUTTONBOX_DEFAULT && min_width != default_min_width)
      || (min_height != GTK_BUTTONBOX_DEFAULT
	  && min_height != default_min_height))
    {
      source_add (data,
	 "  gtk_button_box_set_child_size (GTK_BUTTON_BOX (%s), %i, %i);\n",
		  data->wname, min_width, min_height);
    }

  gtk_button_box_get_child_ipadding_default (&default_ipad_x, &default_ipad_y);
  gtk_button_box_get_child_ipadding (GTK_BUTTON_BOX (widget), &ipad_x, &ipad_y);
  if ((ipad_x != GTK_BUTTONBOX_DEFAULT && ipad_x != default_ipad_x)
      || (ipad_y != GTK_BUTTONBOX_DEFAULT && ipad_y != default_ipad_y))
    {
      source_add (data,
      "  gtk_button_box_set_child_ipadding (GTK_BUTTON_BOX (%s), %i, %i);\n",
		  data->wname, ipad_x, ipad_y);
    }
}
Exemplo n.º 10
0
/* Outputs source to add a child widget to a hbox/vbox. */
void
gb_box_write_add_child_source (GtkWidget * parent,
			       const gchar *parent_name,
			       GtkWidget *child,
			       GbWidgetWriteSourceData * data)
{
  gboolean expand, fill;
  guint padding;
  GtkPackType pack_type;

  gtk_box_query_child_packing (GTK_BOX (parent), child,
			       &expand, &fill, &padding, &pack_type);
  if (pack_type == GTK_PACK_START)
    {
      source_add (data,
		  "  gtk_box_pack_start (GTK_BOX (%s), %s, %s, %s, %i);\n",
		  parent_name, data->wname,
		  expand ? "TRUE" : "FALSE", fill ? "TRUE" : "FALSE", padding);
    }
  else
    {
      source_add (data,
		  "  gtk_box_pack_end (GTK_BOX (%s), %s, %s, %s, %i);\n",
		  parent_name, data->wname,
		  expand ? "TRUE" : "FALSE", fill ? "TRUE" : "FALSE", padding);
    }
}
Exemplo n.º 11
0
/*
 * Writes the source code needed to create this widget.
 * You have to output everything necessary to create the widget here, though
 * there are some convenience functions to help.
 */
static void
gb_file_selection_write_source (GtkWidget * widget,
				GbWidgetWriteSourceData *data)
{
  gchar *wname, *child_name;

  if (data->create_widget)
    {
      source_add (data, "  %s = gtk_file_selection_new (%s);\n",
		  data->wname,
		  source_make_string (GTK_WINDOW (widget)->title,
				      data->use_gettext));
    }

  gb_widget_write_standard_source (widget, data);

  /* The title is already set above, so we pass NULL to skip it. */
  gb_window_write_standard_source (widget, data,
				   NULL, Type, Position, Modal,
				   DefaultWidth, DefaultHeight,
				   Shrink, Grow, AutoShrink,
				   WMName, WMClass,
				   Resizable, DestroyWithParent, Icon);

  if (GTK_FILE_SELECTION (widget)->fileop_c_dir == NULL)
    {
      source_add (data,
		  "  gtk_file_selection_hide_fileop_buttons (GTK_FILE_SELECTION (%s));\n",
		  data->wname);
    }


  /* We output the source code for the buttons here, but we don't want them
     to be created. We need to remember the dialog's name since data->wname
     will be overwritten. */
  wname = g_strdup (data->wname);

  source_add (data, "\n");
  child_name = (gchar*) gtk_widget_get_name (GTK_FILE_SELECTION (widget)->ok_button);
  child_name = source_create_valid_identifier (child_name);
  source_add (data, "  %s = GTK_FILE_SELECTION (%s)->ok_button;\n",
	      child_name, wname);
  g_free (child_name);
  data->create_widget = FALSE;
  gb_widget_write_source (GTK_FILE_SELECTION (widget)->ok_button, data);

  child_name = (gchar*) gtk_widget_get_name (GTK_FILE_SELECTION (widget)->cancel_button);
  child_name = source_create_valid_identifier (child_name);
  source_add (data, "  %s = GTK_FILE_SELECTION (%s)->cancel_button;\n",
	      child_name, wname);
  g_free (child_name);
  data->create_widget = FALSE;
  gb_widget_write_source (GTK_FILE_SELECTION (widget)->cancel_button, data);

  g_free (wname);

  data->write_children = FALSE;
}
Exemplo n.º 12
0
/*
 * Writes the source code needed to create this widget.
 * You have to output everything necessary to create the widget here, though
 * there are some convenience functions to help.
 */
static void
gb_input_dialog_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data)
{
  gchar *wname, *child_name;

  if (data->create_widget)
    {
      source_add (data, "  %s = gtk_input_dialog_new ();\n", data->wname);
    }

  gb_widget_write_standard_source (widget, data);

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

  /* We output the source code for the buttons here, but we don't want them
     to be created. We need to remember the dialog's name since data->wname
     will be overwritten. */
  wname = g_strdup (data->wname);

  source_add (data, "\n");

  child_name = (gchar*) gtk_widget_get_name (GTK_INPUT_DIALOG (widget)->save_button);
  child_name = source_create_valid_identifier (child_name);
  source_add (data, "  %s = GTK_INPUT_DIALOG (%s)->save_button;\n",
	      child_name, wname);
  g_free (child_name);
  data->create_widget = FALSE;
  gb_widget_write_source (GTK_INPUT_DIALOG (widget)->save_button,
			  data);

  child_name = (gchar*) gtk_widget_get_name (GTK_INPUT_DIALOG (widget)->close_button);
  child_name = source_create_valid_identifier (child_name);
  source_add (data, "  %s = GTK_INPUT_DIALOG (%s)->close_button;\n",
	      child_name, wname);
  g_free (child_name);
  data->create_widget = FALSE;
  gb_widget_write_source (GTK_INPUT_DIALOG (widget)->close_button,
			  data);

  g_free (wname);

  data->write_children = FALSE;
}
Exemplo n.º 13
0
/*
 * Writes the source code needed to create this widget.
 * You have to output everything necessary to create the widget here, though
 * there are some convenience functions to help.
 */
static void
gb_gnome_app_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data)
{
  gchar *appname;
  gboolean translatable, context;
  gchar *comments;

  if (data->create_widget)
    {
      appname = glade_project_get_name (data->project);
      appname = appname ? source_make_string (appname, FALSE) : "\"\"";
      appname = g_strdup (appname);

      glade_util_get_translation_properties (widget, Title, &translatable,
					     &comments, &context);
      source_add_translator_comments (data, translatable, comments);

      /* Note that this assumes that we use the same appname for each GnomeApp.
	 FIXME: I think this is correct, but I'm not sure.
	 Note also that we don't translate the project name. Maybe we should.*/
      source_add (data, "  %s = gnome_app_new (%s, %s);\n", data->wname,
		  appname,
		  GTK_WINDOW (widget)->title
		  ? source_make_string_full (GTK_WINDOW (widget)->title,
					     data->use_gettext && translatable,
					     context)
		  : "NULL");
      g_free (appname);
    }

  gb_widget_write_standard_source (widget, data);

  /* The title is already set above, so we pass NULL to skip it. */
  gb_window_write_standard_source (widget, data,
				   NULL, Type, Position, Modal,
				   DefaultWidth, DefaultHeight,
				   Shrink, Grow, AutoShrink,
				   IconName, FocusOnMap,
				   Resizable, DestroyWithParent, Icon,
				   Role, TypeHint, SkipTaskbar,
				   SkipPager, Decorated, Gravity, Urgency);

  if (!GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget),
					     EnableLayoutConfig)))
    {
      source_add (data,
		  "  gnome_app_enable_layout_config (GNOME_APP (%s), FALSE);\n",
		  data->wname);
    }
}
Exemplo n.º 14
0
/*
 * Writes the source code needed to create this widget.
 * You have to output everything necessary to create the widget here, though
 * there are some convenience functions to help.
 */
static void
gb_gnome_color_picker_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data)
{
  if (data->create_widget)
    {
      source_add (data, "  %s = gnome_color_picker_new ();\n", data->wname);
    }

  gb_widget_write_standard_source (widget, data);

  if (strcmp (gnome_color_picker_get_title (GNOME_COLOR_PICKER (widget)),
	      dgettext (GLADE_LIBGNOMEUI_GETTEXT_PACKAGE, "Pick a color")))
    {
      gboolean translatable, context;
      gchar *comments;

      glade_util_get_translation_properties (widget, Title, &translatable,
					     &comments, &context);
      source_add_translator_comments (data, translatable, comments);

      source_add (data,
		  "  gnome_color_picker_set_title (GNOME_COLOR_PICKER (%s), %s);\n",
		  data->wname,
		  source_make_string_full (gnome_color_picker_get_title (GNOME_COLOR_PICKER (widget)),
					   data->use_gettext && translatable,
					   context));
    }

  if (!gnome_color_picker_get_dither (GNOME_COLOR_PICKER (widget)))
    {
      source_add (data,
		  "  gnome_color_picker_set_dither (GNOME_COLOR_PICKER (%s), FALSE);\n",
		  data->wname);

    }

  if (gnome_color_picker_get_use_alpha (GNOME_COLOR_PICKER (widget)))
    {
      source_add (data,
		  "  gnome_color_picker_set_use_alpha (GNOME_COLOR_PICKER (%s), TRUE);\n",
		  data->wname);
    }

  if (!gtk_button_get_focus_on_click (GTK_BUTTON (widget)))
    {
      source_add (data,
		  "  gtk_button_set_focus_on_click (GTK_BUTTON (%s), FALSE);\n",
		  data->wname);
    }
}
Exemplo n.º 15
0
/*
 * Writes the source code needed to create this widget.
 * You have to output everything necessary to create the widget here, though
 * there are some convenience functions to help.
 */
static void
gb_scrolled_window_write_source (GtkWidget * widget, GbWidgetWriteSourceData *
				 data)
{
  const gchar *hpolicy = GbPolicySymbols[0], *vpolicy = GbPolicySymbols[0];
  gint i;

  if (data->create_widget)
    {
      source_add (data, "  %s = gtk_scrolled_window_new (NULL, NULL);\n",
		  data->wname);
    }

  gb_widget_write_standard_source (widget, data);

  if (GTK_SCROLLED_WINDOW (widget)->hscrollbar_policy != GTK_POLICY_ALWAYS
    || GTK_SCROLLED_WINDOW (widget)->vscrollbar_policy != GTK_POLICY_ALWAYS)
    {
      for (i = 0; i < sizeof (GbPolicyValues)
	   / sizeof (GbPolicyValues[0]); i++)
	{
	  if (GbPolicyValues[i] == GTK_SCROLLED_WINDOW (widget)->hscrollbar_policy)
	    hpolicy = GbPolicySymbols[i];
	  if (GbPolicyValues[i] == GTK_SCROLLED_WINDOW (widget)->vscrollbar_policy)
	    vpolicy = GbPolicySymbols[i];
	}
      source_add (data, "  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (%s), %s, %s);\n",
		  data->wname, hpolicy, vpolicy);
    }

  if (GTK_SCROLLED_WINDOW (widget)->shadow_type != GTK_SHADOW_NONE)
    {
      for (i = 0; i < GladeShadowChoicesSize; i++)
	{
	  if (GladeShadowValues[i] == GTK_SCROLLED_WINDOW (widget)->shadow_type)
	    source_add (data, "  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (%s), %s);\n",
			data->wname, GladeShadowSymbols[i]);
	}
    }

  if (GTK_SCROLLED_WINDOW (widget)->window_placement != GTK_CORNER_TOP_LEFT)
    {
      for (i = 0; i < GladeCornerChoicesSize; i++)
	{
	  if (GladeCornerValues[i] == GTK_SCROLLED_WINDOW (widget)->window_placement)
	    source_add (data, "  gtk_scrolled_window_set_placement (GTK_SCROLLED_WINDOW (%s), %s);\n",
			data->wname, GladeCornerSymbols[i]);
	}
    }
}
Exemplo n.º 16
0
/*
 * Writes the source code needed to create this widget.
 * You have to output everything necessary to create the widget here, though
 * there are some convenience functions to help.
 */
static void
gb_menu_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data)
{
  gchar *accel_group_decl;

#ifdef USE_GNOME
  /* For Gnome projects the menus are created using GnomeUIInfo structs, so
     we just create the start of the struct here, and output code to fill
     the menu from the GnomeUIInfo structs. */
  if (data->project->gnome_support)
    {
      glade_gnome_start_menu_source (GTK_MENU_SHELL (widget), data);

      /* We only need to create the toplevel menu. */
      if (gtk_menu_get_attach_widget (GTK_MENU (widget)) == NULL)
	{
	  if (data->create_widget)
	    {
	      source_add (data, "  %s = gtk_menu_new ();\n", data->wname);
	    }

	  gb_widget_write_standard_source (widget, data);

	  source_add (data,
		      "  gnome_app_fill_menu (GTK_MENU_SHELL (%s), %s_uiinfo,\n"
		      "                       NULL, FALSE, 0);\n",
		      data->wname, data->real_wname);
	}

      return;
    }
#endif

  if (data->create_widget)
    {
      source_add (data, "  %s = gtk_menu_new ();\n", data->wname);
    }

  gb_widget_write_standard_source (widget, data);

  accel_group_decl = g_strdup_printf ("  GtkAccelGroup *%s_accels;\n",
				      data->real_wname);
  source_ensure_decl (data, accel_group_decl);
  source_add (data,
	      "  %s_accels = gtk_menu_ensure_uline_accel_group (GTK_MENU (%s));\n",
	      data->wname, data->wname);
  g_free (accel_group_decl);
}
Exemplo n.º 17
0
/*
 * Writes the source code needed to create this widget.
 * You have to output everything necessary to create the widget here, though
 * there are some convenience functions to help.
 */
static void
gb_handle_box_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data)
{
  gint i;

  if (data->create_widget)
    {
      source_add (data, "  %s = gtk_handle_box_new ();\n", data->wname);
    }
  gb_widget_write_standard_source (widget, data);

  if (GTK_HANDLE_BOX (widget)->shadow_type != GTK_SHADOW_OUT)
    {
      for (i = 0; i < sizeof (GbShadowValues) / sizeof (GbShadowValues[0]);
	   i++)
	if (GbShadowValues[i] == GTK_HANDLE_BOX (widget)->shadow_type)
	  {
	    source_add (data,
			"  gtk_handle_box_set_shadow_type (GTK_HANDLE_BOX (%s), %s);\n",
			data->wname, GbShadowSymbols[i]);
	    break;
	  }
    }

  if (GTK_HANDLE_BOX (widget)->handle_position != GTK_POS_LEFT)
    {
      for (i = 0; i < sizeof (GbPositionValues) / sizeof (GbPositionValues[0]);
	   i++)
	{
	  if (GbPositionValues[i] == GTK_HANDLE_BOX (widget)->handle_position)
	    source_add (data,
		    "  gtk_handle_box_set_handle_position (GTK_HANDLE_BOX (%s), %s);\n",
			data->wname, GbPositionSymbols[i]);
	}
    }

  if (GTK_HANDLE_BOX (widget)->snap_edge != GTK_POS_TOP)
    {
      for (i = 0; i < sizeof (GbPositionValues) / sizeof (GbPositionValues[0]);
	   i++)
	{
	  if (GbPositionValues[i] == GTK_HANDLE_BOX (widget)->snap_edge)
	    source_add (data,
		    "  gtk_handle_box_set_snap_edge (GTK_HANDLE_BOX (%s), %s);\n",
			data->wname, GbPositionSymbols[i]);
	}
    }
}
Exemplo n.º 18
0
int source_set_exec_line(struct sviewer *sview, const char *path, int sel_line, int exe_line)
{
    if (path) {
        /* If they passed us a path, try to locate that node */
        sview->cur = source_get_node(sview, path);

        /* Not found.... */
        if (!sview->cur) {
            /* Check that the file exists */
            if (!fs_verify_file_exists(path))
                return 5;

            /* Add a new node for this file */
            sview->cur = source_add(sview, path);
        }
    }

    /* Buffer the file if it's not already */
    if (load_file(sview->cur))
        return 4;

    /* Update line, if set */
    if (sel_line > 0)
        sview->cur->sel_line = clamp_line(sview, sel_line - 1);

    /* Set executing line if passed a valid value */
    if (exe_line == -1) {
        sview->cur->exe_line = -1;
    } else if (exe_line > 0) {
        sview->cur->exe_line = clamp_line(sview, exe_line - 1);
    }

    return 0;
}
Exemplo n.º 19
0
void
gb_paned_write_add_child_source (GtkWidget * parent,
				 const gchar *parent_name,
				 GtkWidget *child,
				 GbWidgetWriteSourceData * data)
{
  gint child_num;
  gchar *resize, *shrink;

  if (child == GTK_PANED (parent)->child1) {
    child_num = 1;
    resize = GTK_PANED (parent)->child1_resize ? "TRUE" : "FALSE";
    shrink = GTK_PANED (parent)->child1_shrink ? "TRUE" : "FALSE";
  } else if (child == GTK_PANED (parent)->child2) {
    child_num = 2;
    resize = GTK_PANED (parent)->child2_resize ? "TRUE" : "FALSE";
    shrink = GTK_PANED (parent)->child2_shrink ? "TRUE" : "FALSE";
  } else {
    g_warning ("Paned child not found");
    return;
  }

  source_add (data, "  gtk_paned_pack%i (GTK_PANED (%s), %s, %s, %s);\n",
	      child_num, parent_name, data->wname, resize, shrink);
}
Exemplo n.º 20
0
/*
 * Writes the source code needed to create this widget.
 * You have to output everything necessary to create the widget here, though
 * there are some convenience functions to help.
 */
static void
gb_statusbar_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data)
{
  if (data->create_widget)
    {
      source_add (data, "  %s = gtk_statusbar_new ();\n", data->wname);
    }
  gb_widget_write_standard_source (widget, data);

  if (!GTK_STATUSBAR (widget)->has_resize_grip)
    {
      source_add (data,
	  "  gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (%s), FALSE);\n",
		  data->wname);
    }
}
Exemplo n.º 21
0
static void
add_menuitem_to_source (GtkWidget * widget,
			GbWriteMenuItemSourceData * write_data)
{
  gchar *label_text;
  GtkWidget *menuitem, *child = GTK_BIN (widget)->child;

  menuitem = GTK_OPTION_MENU (write_data->option_menu)->menu_item;
  if (child == NULL && menuitem == widget)
    {
      child = GTK_BUTTON (write_data->option_menu)->child;
      write_data->selected_index = write_data->index;
    }

  if (child && GTK_IS_LABEL (child))
    {
      gtk_label_get (GTK_LABEL (child), &label_text);

      source_add (write_data->data,
		  "  glade_menuitem = gtk_menu_item_new_with_label (%s);\n"
		  "  gtk_widget_show (glade_menuitem);\n"
		  "  gtk_menu_append (GTK_MENU (%s_menu), glade_menuitem);\n",
		  source_make_string (label_text,
				      write_data->data->use_gettext),
		  write_data->data->real_wname);
    }

  write_data->index++;
}
Exemplo n.º 22
0
/*
 * Writes the source code needed to create this widget.
 * You have to output everything necessary to create the widget here, though
 * there are some convenience functions to help.
 */
static void
gb_accel_label_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data)
{
  if (data->create_widget)
    {
      const gchar *label_text = gtk_label_get_label (GTK_LABEL (widget));

      source_add (data, "  %s = gtk_accel_label_new (%s);\n", data->wname,
		  source_make_string (label_text, data->use_gettext));
    }

  gb_widget_write_standard_source (widget, data);

  if (gtk_label_get_use_underline (GTK_LABEL (widget)))
    source_add (data, "  gtk_label_set_use_underline (%s, TRUE);\n",
		data->wname);
}
Exemplo n.º 23
0
/*
 * Writes the source code needed to create this widget.
 * You have to output everything necessary to create the widget here, though
 * there are some convenience functions to help.
 */
static void
gb_gnome_db_data_source_selector_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data)
{
  if (data->create_widget)
    {
      source_add (data, "  %s = gnome_db_data_source_selector_new (NULL);\n", data->wname);
    }
  gb_widget_write_standard_source (widget, data);
}
Exemplo n.º 24
0
/*
 * Writes the source code needed to create this widget.
 * You have to output everything necessary to create the widget here, though
 * there are some convenience functions to help.
 */
static void
gb_option_menu_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data)
{
  gint history;

  if (data->create_widget)
    {
      source_add (data, "  %s = gtk_option_menu_new ();\n", data->wname);
    }

  gb_widget_write_standard_source (widget, data);

  history = gtk_option_menu_get_history (GTK_OPTION_MENU (widget));
  if (history > 0)
    source_add (data,
	      "  gtk_option_menu_set_history (GTK_OPTION_MENU (%s), %i);\n",
		data->wname, history);
}
Exemplo n.º 25
0
/*
 * Writes the source code needed to create this widget.
 * You have to output everything necessary to create the widget here, though
 * there are some convenience functions to help.
 */
static void
gb_vseparator_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data)
{
  if (data->create_widget)
    {
      source_add (data, "  %s = gtk_vseparator_new ();\n", data->wname);
    }
  gb_widget_write_standard_source (widget, data);
}
Exemplo n.º 26
0
/* Outputs source to add a child menu to a menu item. */
static void
gb_menu_item_write_add_child_source (GtkWidget * parent,
				     const gchar *parent_name,
				     GtkWidget *child,
				     GbWidgetWriteSourceData * data)
{
  if (GTK_IS_MENU (child))
    {
      source_add (data,
		  "  gtk_menu_item_set_submenu (GTK_MENU_ITEM (%s), %s);\n",
		  parent_name, data->wname);
    }
  else
    {
      source_add (data, "  gtk_container_add (GTK_CONTAINER (%s), %s);\n",
		  parent_name, data->wname);
    }
}
Exemplo n.º 27
0
static void
write_items_source_callback (GtkWidget * item, GbWidgetWriteSourceData * data)
{
  gchar *label_text;
  gtk_label_get (GTK_LABEL (GTK_BIN (item)->child), &label_text);
  /* The (gpointer) cast is just to keep g++ happy. */
  source_add (data, "  %s_items = g_list_append (%s_items, (gpointer) %s);\n",
	      data->real_wname, data->real_wname,
	      source_make_string (label_text, data->use_gettext));
}
Exemplo n.º 28
0
/*
 * Writes the source code needed to create this widget.
 * You have to output everything necessary to create the widget here, though
 * there are some convenience functions to help.
 */
static void
gb_toggle_button_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data)
{
  gb_button_write_standard_source (widget, data, Label);

  if (data->widget_data->flags & GLADE_ACTIVE)
    {
      source_add (data,
	  "  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (%s), TRUE);\n",
		  data->wname);
    }

  if (GTK_TOGGLE_BUTTON (widget)->inconsistent)
    {
      source_add (data,
      "  gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (%s), TRUE);\n",
		  data->wname);
    }
}
Exemplo n.º 29
0
/*
 * Writes the source code needed to create this widget.
 * You have to output everything necessary to create the widget here, though
 * there are some convenience functions to help.
 */
static void
gb_hpaned_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data)
{
  gint position;

  if (data->create_widget)
    {
      source_add (data, "  %s = gtk_hpaned_new ();\n", data->wname);
    }
  gb_widget_write_standard_source (widget, data);

  if (GTK_PANED (widget)->position_set)
    {
      position = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget),
						       Position));
      source_add (data, "  gtk_paned_set_position (GTK_PANED (%s), %d);\n",
		  data->wname, position);
    }
}
Exemplo n.º 30
0
/* Outputs source to add a child widget to a table. */
static void
gb_gnome_druid_write_add_child_source (GtkWidget * parent,
				       const gchar *parent_name,
				       GtkWidget *child,
				       GbWidgetWriteSourceData * data)
{
  source_add (data,
	      "  gnome_druid_append_page (GNOME_DRUID (%s),\n"
	      "                           GNOME_DRUID_PAGE (%s));\n",
	      parent_name, data->wname);
}