/* * 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; }
/* * 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_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_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; }