/* * 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; }
/* * 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; }
/* 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); } }
/* * 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_combo_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data) { gchar *wname, *child_name; gboolean value_in_list, ok_if_empty; if (data->create_widget) { source_add (data, " %s = gtk_combo_new ();\n", data->wname); } gb_widget_write_standard_source (widget, data); value_in_list = gtk_object_get_data (GTK_OBJECT (widget), ValueInList) != NULL ? TRUE : FALSE; if (value_in_list) { ok_if_empty = gtk_object_get_data (GTK_OBJECT (widget), OKIfEmpty) != NULL ? TRUE : FALSE; source_add (data, " gtk_combo_set_value_in_list (GTK_COMBO (%s), %s, %s);\n", data->wname, value_in_list ? "TRUE" : "FALSE", ok_if_empty ? "TRUE" : "FALSE"); } if (GTK_COMBO (widget)->case_sensitive) { source_add (data, " gtk_combo_set_case_sensitive (GTK_COMBO (%s), TRUE);\n", data->wname); } if (!GTK_COMBO (widget)->use_arrows) { source_add (data, " gtk_combo_set_use_arrows (GTK_COMBO (%s), FALSE);\n", data->wname); } if (GTK_COMBO (widget)->use_arrows_always) { source_add (data, " gtk_combo_set_use_arrows_always (GTK_COMBO (%s), TRUE);\n", data->wname); } if (is_simple_combo (widget) > 0) { source_add_decl (data, " GList *%s_items = NULL;\n", data->real_wname); gtk_container_foreach (GTK_CONTAINER (GTK_COMBO (widget)->list), (GtkCallback) write_items_source_callback, data); source_add (data, " gtk_combo_set_popdown_strings (GTK_COMBO (%s), %s_items);\n", data->wname, data->real_wname); source_add (data, " g_list_free (%s_items);\n", data->real_wname); } /* We output the source code for the children here, since the code should not include calls to create the widgets. We need to specify that the names used are like: "GTK_COMBO (<combo-name>)->entry". 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 = gtk_widget_get_name (GTK_COMBO (widget)->entry); child_name = source_create_valid_identifier (child_name); source_add (data, " %s = GTK_COMBO (%s)->entry;\n", child_name, wname); g_free (child_name); data->create_widget = FALSE; gb_widget_write_source (GTK_COMBO (widget)->entry, data); g_free (wname); data->write_children = FALSE; }
/* * 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_radio_button_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data) { GtkWidget *child = GTK_BUTTON (widget)->child; gchar *label_text; gchar buffer[256]; gchar *group_name = gtk_object_get_data (GTK_OBJECT (widget), Group); if (!group_name) group_name = gtk_widget_get_name (widget->parent); if (data->create_widget) { if (gb_toolbar_is_toolbar_button (widget)) { gb_toolbar_write_toolbar_button_source (widget, data); } else { /* Make sure the temporary group list variable is declared. */ group_name = source_create_valid_identifier (group_name); sprintf (buffer, " GSList *%s_group = NULL;\n", group_name); source_ensure_decl (data, buffer); if (child && GTK_IS_LABEL (child) && !GB_IS_GB_WIDGET (child)) { label_text = glade_util_get_label_text (GTK_BIN (widget)->child); /* If there is an underlined accelerator, set up the signal. */ if (strchr (label_text, '_')) { source_add (data, " %s = gtk_radio_button_new_with_label (%s_group, \"\");\n", data->wname, group_name); gb_button_write_uline_accel_source (widget, data, label_text); } else { source_add (data, " %s = gtk_radio_button_new_with_label (%s_group, %s);\n", data->wname, group_name, source_make_string (label_text, data->use_gettext)); } g_free (label_text); } else { source_add (data, " %s = gtk_radio_button_new (%s_group);\n", data->wname, group_name); } source_add (data, " %s_group = gtk_radio_button_group (GTK_RADIO_BUTTON (%s));\n", group_name, data->wname); g_free (group_name); } } gb_widget_write_standard_source (widget, data); 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)->draw_indicator) { source_add (data, " gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (%s), FALSE);\n", data->wname); } }
void gb_label_write_standard_source (GtkWidget * widget, GbWidgetWriteSourceData * data, const char *label_p, const char *use_underline_p, const char *use_markup_p, const char *justify_p, const char *wrap_p, const char *selectable_p, const char *xalign_p, const char *yalign_p, const char *xpad_p, const char *ypad_p, const char *focus_target_p) { GtkWidget *accel_target = NULL; gint i; if (gtk_object_get_data (GTK_OBJECT (widget), use_markup_p)) source_add (data, " gtk_label_set_use_markup (GTK_LABEL (%s), TRUE);\n", data->wname); /* If there is an underlined accelerator, set up the accel signal. If the label is in a button or something similar, this is now setup automatically by GTK+. If the accelerator is being used to set focus to something like a GtkEntry, we need to set the mnemonic_widget. */ if (gtk_label_get_use_underline (GTK_LABEL (widget)) && !gb_label_find_mnemonic_widget (widget)) { gchar *target_name = gtk_object_get_data (GTK_OBJECT (widget), focus_target_p); if (target_name) accel_target = glade_util_find_widget (gtk_widget_get_toplevel (widget), target_name); if (!accel_target) accel_target = glade_util_find_default_accelerator_target (widget); if (accel_target) { target_name = (gchar*) gtk_widget_get_name (accel_target); target_name = source_create_valid_identifier (target_name); source_add_to_buffer (data, GLADE_ACCELERATORS, " gtk_label_set_mnemonic_widget (GTK_LABEL (%s), %s);\n", data->wname, target_name); g_free (target_name); } } if (GTK_LABEL (widget)->jtype != GTK_JUSTIFY_CENTER) { for (i = 0; i < sizeof (GbJustifyValues) / sizeof (GbJustifyValues[0]); i++) { if (GbJustifyValues[i] == GTK_LABEL (widget)->jtype) source_add (data, " gtk_label_set_justify (GTK_LABEL (%s), %s);\n", data->wname, GbJustifySymbols[i]); } } if (GTK_LABEL (widget)->wrap) source_add (data, " gtk_label_set_line_wrap (GTK_LABEL (%s), TRUE);\n", data->wname); if (gtk_label_get_selectable (GTK_LABEL (widget))) source_add (data, " gtk_label_set_selectable (GTK_LABEL (%s), TRUE);\n", data->wname); if (fabs (GTK_MISC (widget)->xalign - 0.5) > 0.0001 || fabs (GTK_MISC (widget)->yalign - 0.5) > 0.0001) source_add (data, " gtk_misc_set_alignment (GTK_MISC (%s), %g, %g);\n", data->wname, GTK_MISC (widget)->xalign, GTK_MISC (widget)->yalign); if (GTK_MISC (widget)->xpad != 0 || GTK_MISC (widget)->ypad != 0) source_add (data, " gtk_misc_set_padding (GTK_MISC (%s), %i, %i);\n", data->wname, GTK_MISC (widget)->xpad, GTK_MISC (widget)->ypad); }
/* * 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_custom_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data) { gchar *creation_func, *string1, *string2; gint int1, int2; time_t last_mod_time; creation_func = gtk_object_get_data (GTK_OBJECT (widget), CreationFunction); string1 = gtk_object_get_data (GTK_OBJECT (widget), String1); string2 = gtk_object_get_data (GTK_OBJECT (widget), String2); int1 = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget), Int1)); int2 = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget), Int2)); /* If no creation function has been set, we skip the widget. */ if (creation_func == NULL) return; creation_func = source_create_valid_identifier (creation_func); /* Output "" if the strings are NULL, for consistency. */ if (string1 == NULL) string1 = ""; if (string2 == NULL) string2 = ""; if (string1) string1 = g_strdup (source_make_string (string1, FALSE)); if (string2) string2 = g_strdup (source_make_string (string2, FALSE)); /* Example output: custom1 = create_custom1 ("custom1", "string1", "string2", 5, 10); */ source_add (data, " %s = %s (%s, %s, %s, %i, %i);\n", data->wname, creation_func, source_make_string (data->real_wname, FALSE), string1 ? string1 : "NULL", string2 ? string2 : "NULL", int1, int2); gb_widget_write_standard_source (widget, data); /* Add declaration of creation function and empty function, just like a signal handler. We need a last_modification_time property. */ last_mod_time = gb_custom_get_last_mod_time (widget); if (data->creating_callback_files || (last_mod_time > data->last_write_time)) { source_add_to_buffer (data, GLADE_CALLBACK_DECLARATIONS, "\nGtkWidget*\n" "%s (gchar *widget_name, gchar *string1, gchar *string2,\n" " gint int1, gint int2);\n", creation_func); source_add_to_buffer (data, GLADE_CALLBACK_SOURCE, "\nGtkWidget*\n" "%s (gchar *widget_name, gchar *string1, gchar *string2,\n" " gint int1, gint int2)\n" "{\n\n}\n\n", creation_func); } g_free (creation_func); g_free (string1); g_free (string2); }
/* * 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_dialog_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data) { gchar *wname, *child_name; gboolean translatable, context; gchar *comments; if (data->create_widget) { gchar *title; glade_util_get_translation_properties (widget, Title, &translatable, &comments, &context); source_add_translator_comments (data, translatable, comments); title = GTK_WINDOW (widget)->title; source_add (data, " %s = gnome_dialog_new (%s, NULL);\n", data->wname, title ? source_make_string_full (title, data->use_gettext && translatable, context) : "NULL"); } 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 (GNOME_DIALOG (widget)->click_closes) { source_add (data, " gnome_dialog_set_close (GNOME_DIALOG (%s), TRUE);\n", data->wname); } if (GNOME_DIALOG (widget)->just_hide) { source_add (data, " gnome_dialog_close_hides (GNOME_DIALOG (%s), TRUE);\n", data->wname); } /* We output the source code for the children here, since the code should not include calls to create the widgets. We need to specify that the names used are like: "GTK_DIALOG (<dialog-name>)->vbox". 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 = (char*) gtk_widget_get_name (GNOME_DIALOG (widget)->vbox); child_name = source_create_valid_identifier (child_name); source_add (data, " %s = GNOME_DIALOG (%s)->vbox;\n", child_name, wname); g_free (child_name); data->create_widget = FALSE; gb_widget_write_source (GNOME_DIALOG (widget)->vbox, data); /* action_area is a child of vbox so I had to add a kludge to stop it being written as a normal child - we need to do it here so that we don't output code to create it. */ child_name = (char*) gtk_widget_get_name (GNOME_DIALOG (widget)->action_area); child_name = source_create_valid_identifier (child_name); source_add (data, " %s = GNOME_DIALOG (%s)->action_area;\n", child_name, wname); g_free (child_name); data->create_widget = FALSE; gb_widget_write_source (GNOME_DIALOG (widget)->action_area, data); g_free (wname); data->write_children = FALSE; }
/* * 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_radio_tool_button_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data) { GladeFindGroupData find_data; GtkWidget *group_widget; gchar *stock_id, *label, *icon_name; gchar buffer[256], *group_name; gboolean translatable, context; gchar *comments; stock_id = gtk_object_get_data (GTK_OBJECT (widget), GladeToolButtonStockIDKey); icon_name = gtk_object_get_data (GTK_OBJECT (widget), GladeToolButtonIconKey); label = (gchar*) gtk_tool_button_get_label (GTK_TOOL_BUTTON (widget)); glade_util_get_translation_properties (widget, Label, &translatable, &comments, &context); find_data.group = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (widget)); find_data.found_widget = NULL; gb_widget_children_foreach (widget->parent, (GtkCallback) find_radio_group, &find_data); group_widget = find_data.found_widget; if (!group_widget) { g_warning ("Radiotoolbutton has no group"); group_widget = widget; } group_name = (char*) gtk_widget_get_name (group_widget); group_name = source_create_valid_identifier (group_name); sprintf (buffer, " GSList *%s_group = NULL;\n", group_name); source_ensure_decl (data, buffer); if (data->create_widget) { if (stock_id) { /* Stock Button */ source_add (data, " %s = (GtkWidget*) gtk_radio_tool_button_new_from_stock (NULL, %s);\n", data->wname, source_make_string (stock_id, FALSE)); } else if (icon_name) { /* Icon and Label */ source_add (data, " %s = (GtkWidget*) gtk_radio_tool_button_new (NULL);\n", data->wname); source_add_translator_comments (data, translatable, comments); source_add (data, " gtk_tool_button_set_label (GTK_TOOL_BUTTON (%s), %s);\n", data->wname, label ? source_make_string_full (label, data->use_gettext && translatable, context) : "NULL"); source_ensure_decl (data, " GtkWidget *tmp_image;\n"); if (glade_util_check_is_stock_id (icon_name)) { source_add (data, " tmp_image = gtk_image_new_from_stock (\"%s\", tmp_toolbar_icon_size);\n", icon_name); } else { source_create_pixmap (data, "tmp_image", icon_name); } source_add (data, " gtk_widget_show (tmp_image);\n"); source_add (data, " gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (%s), tmp_image);\n", data->wname); } else { /* Just a Label */ source_add (data, " %s = (GtkWidget*) gtk_radio_tool_button_new (NULL);\n", data->wname); source_add_translator_comments (data, translatable, comments); source_add (data, " gtk_tool_button_set_label (GTK_TOOL_BUTTON (%s), %s);\n", data->wname, label ? source_make_string_full (label, data->use_gettext && translatable, context) : "NULL"); } } gb_widget_write_standard_source (widget, data); source_add (data, " gtk_radio_tool_button_set_group (GTK_RADIO_TOOL_BUTTON (%s), %s_group);\n", data->wname, group_name); source_add (data, " %s_group = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (%s));\n", group_name, data->wname); if (data->widget_data->flags & GLADE_ACTIVE) { source_add (data, " gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (%s), TRUE);\n", data->wname); } 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); } g_free (group_name); }
/* * 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_message_box_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data) { GtkWidget *pixmap, *label; gchar *label_text; gint type_index; gchar *wname, *child_name; get_message_box_widgets (widget, &pixmap, &label); g_return_if_fail (pixmap != NULL); g_return_if_fail (label != NULL); type_index = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget), MessageBoxType)); gtk_label_get (GTK_LABEL (label), &label_text); if (data->create_widget) { source_add (data, " /* We create it with an OK button, and then remove the button, to work\n" " around a bug in gnome-libs. */\n" " %s = gnome_message_box_new (%s,\n" " %s,\n" " GNOME_STOCK_BUTTON_OK, NULL);\n", data->wname, source_make_string (label_text, data->use_gettext), GbMessageBoxTypeSymbols[type_index]); source_add (data, " gtk_container_remove (GTK_CONTAINER (GNOME_DIALOG (%s)->action_area), GNOME_DIALOG (%s)->buttons->data);\n" " GNOME_DIALOG (%s)->buttons = NULL;\n", data->wname, data->wname, data->wname); } gb_widget_write_standard_source (widget, data); gb_window_write_standard_source (widget, data, Title, NULL, Position, Modal, DefaultWidth, DefaultHeight, Shrink, Grow, AutoShrink, WMName, WMClass); if (!GNOME_DIALOG (widget)->click_closes) { source_add (data, " gnome_dialog_set_close (GNOME_DIALOG (%s), FALSE);\n", data->wname); } if (GNOME_DIALOG (widget)->just_hide) { source_add (data, " gnome_dialog_close_hides (GNOME_DIALOG (%s), TRUE);\n", data->wname); } /* We output the source code for the children here, since the code should not include calls to create the widgets. We need to specify that the names used are like: "GTK_DIALOG (<dialog-name>)->vbox". 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 = gtk_widget_get_name (GNOME_DIALOG (widget)->vbox); child_name = source_create_valid_identifier (child_name); source_add (data, " %s = GNOME_DIALOG (%s)->vbox;\n", child_name, wname); g_free (child_name); data->create_widget = FALSE; gb_widget_write_source (GNOME_DIALOG (widget)->vbox, data); /* action_area is a child of vbox so I had to add a kludge to stop it being written as a normal child - we need to do it here so that we don't output code to create it. */ child_name = gtk_widget_get_name (GNOME_DIALOG (widget)->action_area); child_name = source_create_valid_identifier (child_name); data->create_widget = FALSE; gb_widget_write_source (GNOME_DIALOG (widget)->action_area, data); /* We need to move this after the above, because GnomeMessageBox doesn't actually create the action_area until a button is added. Note that this means we mustn't set any properties of the action_area above, (see gbhbuttonbox.c), and the GnomeMessageBox must have at least one button. */ source_add (data, " %s = GNOME_DIALOG (%s)->action_area;\n", child_name, wname); /* Copied from gb_widget_write_standard_source(), until we decide on a better way to structure this. */ source_add_decl (data, " GtkWidget *%s;\n", child_name); /* If there aren't any buttons the pointer may be NULL, so we add a test. */ if (data->set_widget_names) source_add (data, " if (%s != NULL)\n" " gtk_widget_set_name (%s, \"%s\");\n", child_name, child_name, child_name); if (!data->use_component_struct) { source_add (data, " gtk_widget_ref (%s);\n" " gtk_object_set_data_full (GTK_OBJECT (%s), %s, %s,\n" " (GtkDestroyNotify) gtk_widget_unref);\n", child_name, data->component_name, source_make_string (child_name, FALSE), child_name); } g_free (child_name); g_free (wname); data->write_children = FALSE; }
/* * 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_druid_page_standard_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data) { GnomeDruidPageStandard *page; gchar *filename, *title; gchar *wname, *child_name; GdkColor title_color, background_color, logo_background_color; gboolean title_color_set, background_color_set, logo_background_color_set; page = GNOME_DRUID_PAGE_STANDARD (widget); /* We do this to make sure the colors are set. */ gtk_widget_ensure_style (widget); if (data->create_widget) { source_add (data, " %s = gnome_druid_page_standard_new ();\n", data->wname); } gb_widget_write_standard_source (widget, data); g_object_get (G_OBJECT (widget), "title-foreground-set", &title_color_set, "title-foreground-gdk", &title_color, "background-set", &background_color_set, "background-gdk", &background_color, "logo-background-set", &logo_background_color_set, "logo-background-gdk", &logo_background_color, "title", &title, NULL); if (background_color_set) { source_add_decl (data, " GdkColor %s_bg_color = { 0, %i, %i, %i };\n", data->real_wname, background_color.red, background_color.green, background_color.blue); source_add (data, " gnome_druid_page_standard_set_background (GNOME_DRUID_PAGE_STANDARD (%s), &%s_bg_color);\n", data->wname, data->real_wname); } if (logo_background_color_set) { source_add_decl (data, " GdkColor %s_logo_bg_color = { 0, %i, %i, %i };\n", data->real_wname, logo_background_color.red, logo_background_color.green, logo_background_color.blue); source_add (data, " gnome_druid_page_standard_set_logo_background (GNOME_DRUID_PAGE_STANDARD (%s), &%s_logo_bg_color);\n", data->wname, data->real_wname); } if (title_color_set) { source_add_decl (data, " GdkColor %s_title_color = { 0, %i, %i, %i };\n", data->real_wname, title_color.red, title_color.green, title_color.blue); source_add (data, " gnome_druid_page_standard_set_title_foreground (GNOME_DRUID_PAGE_STANDARD (%s), &%s_title_color);\n", data->wname, data->real_wname); } if (gtk_object_get_data (GTK_OBJECT (widget), ContentsBackgroundColor)) { GdkColor *color = &page->contents_background; source_add_decl (data, " GdkColor %s_contents_bg_color = { 0, %i, %i, %i };\n", data->real_wname, color->red, color->green, color->blue); source_add (data, " gnome_druid_page_standard_set_contents_background (GNOME_DRUID_PAGE_STANDARD (%s), &%s_contents_bg_color);\n", data->wname, data->real_wname); } if (title && *title) { 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_druid_page_standard_set_title (GNOME_DRUID_PAGE_STANDARD (%s), %s);\n", data->wname, source_make_string_full (title, data->use_gettext && translatable, context)); } g_free (title); filename = gtk_object_get_data (GTK_OBJECT (widget), LogoImage); if (filename && filename[0]) { source_ensure_decl (data, " GdkPixbuf *tmp_pixbuf;\n"); source_add (data, " tmp_pixbuf = create_pixbuf (\"%s/%s\");\n" " if (tmp_pixbuf)\n" " {\n" " gnome_druid_page_standard_set_logo (GNOME_DRUID_PAGE_STANDARD (%s),\n" " tmp_pixbuf);\n" " gdk_pixbuf_unref (tmp_pixbuf);\n" " }\n", data->program_name, g_basename (filename), data->wname); } filename = gtk_object_get_data (GTK_OBJECT (widget), TopWatermark); if (filename && filename[0]) { source_ensure_decl (data, " GdkPixbuf *tmp_pixbuf;\n"); source_add (data, " tmp_pixbuf = create_pixbuf (\"%s/%s\");\n" " if (tmp_pixbuf)\n" " {\n" " gnome_druid_page_standard_set_top_watermark (GNOME_DRUID_PAGE_STANDARD (%s),\n" " tmp_pixbuf);\n" " gdk_pixbuf_unref (tmp_pixbuf);\n" " }\n", data->program_name, g_basename (filename), data->wname); } /* We output the source code for the children here, since the code should not include calls to create the widgets. We need to specify that the names used are like: "GTK_COMBO (<combo-name>)->entry". 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 = (char*) gtk_widget_get_name (GNOME_DRUID_PAGE_STANDARD (widget)->vbox); child_name = source_create_valid_identifier (child_name); source_add (data, " %s = GNOME_DRUID_PAGE_STANDARD (%s)->vbox;\n", child_name, wname); g_free (child_name); data->create_widget = FALSE; gb_widget_write_source (GNOME_DRUID_PAGE_STANDARD (widget)->vbox, data); g_free (wname); data->write_children = FALSE; }