コード例 #1
0
static void
mail_config_remote_backend_insert_widgets (EMailConfigServiceBackend *backend,
                                           GtkBox *parent)
{
	EMailConfigRemoteBackend *remote_backend;
	CamelProvider *provider;
	CamelSettings *settings;
	ESource *source;
	ESourceBackend *extension;
	EMailConfigServicePage *page;
	EMailConfigServicePageClass *class;
	GtkLabel *label;
	GtkWidget *widget;
	GtkWidget *container;
	const gchar *backend_name;
	const gchar *extension_name;
	const gchar *text;
	gchar *markup;

	remote_backend = E_MAIL_CONFIG_REMOTE_BACKEND (backend);

	page = e_mail_config_service_backend_get_page (backend);
	source = e_mail_config_service_backend_get_source (backend);
	settings = e_mail_config_service_backend_get_settings (backend);

	class = E_MAIL_CONFIG_SERVICE_PAGE_GET_CLASS (page);
	extension_name = class->extension_name;
	extension = e_source_get_extension (source, extension_name);
	backend_name = e_source_backend_get_backend_name (extension);

	text = _("Configuration");
	markup = g_markup_printf_escaped ("<b>%s</b>", text);
	widget = gtk_label_new (markup);
	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
	gtk_box_pack_start (GTK_BOX (parent), widget, FALSE, FALSE, 0);
	gtk_widget_show (widget);
	g_free (markup);

	widget = gtk_grid_new ();
	gtk_widget_set_margin_left (widget, 12);
	gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
	gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
	gtk_box_pack_start (GTK_BOX (parent), widget, FALSE, FALSE, 0);
	gtk_widget_show (widget);

	container = widget;

	widget = gtk_label_new_with_mnemonic (_("_Server:"));
	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 1, 1);
	gtk_widget_show (widget);

	label = GTK_LABEL (widget);

	widget = gtk_entry_new ();
	gtk_widget_set_hexpand (widget, TRUE);
	gtk_label_set_mnemonic_widget (label, widget);
	gtk_grid_attach (GTK_GRID (container), widget, 1, 0, 1, 1);
	remote_backend->host_entry = widget;  /* do not reference */
	gtk_widget_show (widget);

	widget = gtk_label_new_with_mnemonic (_("_Port:"));
	gtk_grid_attach (GTK_GRID (container), widget, 2, 0, 1, 1);
	gtk_widget_show (widget);

	label = GTK_LABEL (widget);

	widget = e_port_entry_new ();
	gtk_label_set_mnemonic_widget (label, widget);
	gtk_grid_attach (GTK_GRID (container), widget, 3, 0, 1, 1);
	remote_backend->port_entry = widget;  /* do not reference */
	gtk_widget_show (widget);

	widget = gtk_image_new_from_icon_name ("dialog-warning", GTK_ICON_SIZE_BUTTON);
	g_object_set (G_OBJECT (widget),
		"visible", FALSE,
		"has-tooltip", TRUE,
		"tooltip-text", _("Port number is not valid"),
		NULL);
	gtk_grid_attach (GTK_GRID (container), widget, 4, 0, 1, 1);
	remote_backend->port_error_image = widget;  /* do not reference */

	widget = gtk_label_new_with_mnemonic (_("User_name:"));
	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
	gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
	gtk_widget_show (widget);

	label = GTK_LABEL (widget);

	widget = gtk_entry_new ();
	gtk_widget_set_hexpand (widget, TRUE);
	gtk_label_set_mnemonic_widget (label, widget);
	gtk_grid_attach (GTK_GRID (container), widget, 1, 1, 4, 1);
	remote_backend->user_entry = widget;  /* do not reference */
	gtk_widget_show (widget);

	text = _("Security");
	markup = g_markup_printf_escaped ("<b>%s</b>", text);
	widget = gtk_label_new (markup);
	gtk_widget_set_margin_top (widget, 6);
	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
	gtk_box_pack_start (GTK_BOX (parent), widget, FALSE, FALSE, 0);
	gtk_widget_show (widget);
	g_free (markup);

	widget = gtk_grid_new ();
	gtk_widget_set_margin_left (widget, 12);
	gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
	gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
	gtk_box_pack_start (GTK_BOX (parent), widget, FALSE, FALSE, 0);
	gtk_widget_show (widget);

	container = widget;

	widget = gtk_label_new_with_mnemonic (_("Encryption _method:"));
	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 1, 1);
	gtk_widget_show (widget);

	label = GTK_LABEL (widget);

	/* The IDs correspond to the CamelNetworkSecurityMethod enum. */
	widget = gtk_combo_box_text_new ();
	gtk_combo_box_text_append (
		GTK_COMBO_BOX_TEXT (widget),
		"none",
		_("No encryption"));
	gtk_combo_box_text_append (
		GTK_COMBO_BOX_TEXT (widget),
		"starttls-on-standard-port",
		_("STARTTLS after connecting"));
	gtk_combo_box_text_append (
		GTK_COMBO_BOX_TEXT (widget),
		"ssl-on-alternate-port",
		_("SSL on a dedicated port"));
	gtk_label_set_mnemonic_widget (label, widget);
	gtk_widget_set_halign (widget, GTK_ALIGN_START);
	gtk_grid_attach (GTK_GRID (container), widget, 1, 0, 1, 1);
	remote_backend->security_combo_box = widget;  /* do not reference */
	gtk_widget_show (widget);

	provider = camel_provider_get (backend_name, NULL);
	if (provider != NULL && provider->port_entries != NULL)
		e_port_entry_set_camel_entries (
			E_PORT_ENTRY (remote_backend->port_entry),
			provider->port_entries);

	text = _("Authentication");
	markup = g_markup_printf_escaped ("<b>%s</b>", text);
	widget = gtk_label_new (markup);
	gtk_widget_set_margin_top (widget, 6);
	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
	gtk_box_pack_start (GTK_BOX (parent), widget, FALSE, FALSE, 0);
	gtk_widget_show (widget);
	g_free (markup);

	widget = e_mail_config_auth_check_new (backend);
	gtk_widget_set_margin_left (widget, 12);
	gtk_box_pack_start (GTK_BOX (parent), widget, FALSE, FALSE, 0);
	remote_backend->auth_check = widget;  /* do not reference */
	gtk_widget_show (widget);

	e_binding_bind_object_text_property (
		settings, "host",
		remote_backend->host_entry, "text",
		G_BINDING_BIDIRECTIONAL |
		G_BINDING_SYNC_CREATE);

	e_binding_bind_property_full (
		settings, "security-method",
		remote_backend->security_combo_box, "active-id",
		G_BINDING_BIDIRECTIONAL |
		G_BINDING_SYNC_CREATE,
		e_binding_transform_enum_value_to_nick,
		e_binding_transform_enum_nick_to_value,
		NULL, (GDestroyNotify) NULL);

	e_binding_bind_property (
		settings, "port",
		remote_backend->port_entry, "port",
		G_BINDING_BIDIRECTIONAL |
		G_BINDING_SYNC_CREATE);

	e_binding_bind_property (
		settings, "security-method",
		remote_backend->port_entry, "security-method",
		G_BINDING_SYNC_CREATE);

	e_binding_bind_object_text_property (
		settings, "user",
		remote_backend->user_entry, "text",
		G_BINDING_BIDIRECTIONAL |
		G_BINDING_SYNC_CREATE);

	/* Don't use G_BINDING_SYNC_CREATE here since the widget
	 * chooses its initial mechanism more intelligently than
	 * a simple property binding would. */
	e_binding_bind_property (
		settings, "auth-mechanism",
		remote_backend->auth_check, "active-mechanism",
		G_BINDING_BIDIRECTIONAL);
}
コード例 #2
0
ファイル: prefs.c プロジェクト: Swetha5/gnome-games
void
prefsbox_open (void)
{
  GtkWidget *notebook;
  GtkWidget *grid;
  GtkWidget *controls_list;
  GtkWidget *label;
  GtkCellRenderer *renderer;
  GtkListStore *model;
  GtkTreeIter iter;
  gint i;

  if (prefsbox != NULL) {
    gtk_window_present (GTK_WINDOW (prefsbox));
    return;
  }

  prefsbox = gtk_dialog_new_with_buttons (_("Four-in-a-Row Preferences"),
					  GTK_WINDOW (app),
					  GTK_DIALOG_DESTROY_WITH_PARENT,
					  GTK_STOCK_CLOSE,
					  GTK_RESPONSE_ACCEPT, NULL);
  gtk_container_set_border_width (GTK_CONTAINER (prefsbox), 5);
  gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (prefsbox))),
		       2);

  g_signal_connect (G_OBJECT (prefsbox), "destroy",
		    G_CALLBACK (gtk_widget_destroyed), &prefsbox);

  notebook = gtk_notebook_new ();
  gtk_container_set_border_width (GTK_CONTAINER (notebook), 5);
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (prefsbox))), notebook, TRUE, TRUE, 0);

  /* game tab */

  grid = gtk_grid_new ();
  gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
  gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
  gtk_container_set_border_width (GTK_CONTAINER (grid), 12);

  label = gtk_label_new (_("Game"));
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), grid, label);

  label = gtk_label_new (_("Player One:"));
  gtk_widget_set_hexpand (label, TRUE);
  gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);

  combobox1 = gtk_combo_box_new ();
  renderer = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox1), renderer, TRUE);
  gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combobox1), renderer, "text", 0);
  model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
  gtk_combo_box_set_model (GTK_COMBO_BOX (combobox1), GTK_TREE_MODEL (model));
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, _("Human"), 1, LEVEL_HUMAN, -1);
  if (p.level[PLAYER1] == LEVEL_HUMAN)
    gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox1), &iter);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, _("Level one"), 1, LEVEL_WEAK, -1);
  if (p.level[PLAYER1] == LEVEL_WEAK)
    gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox1), &iter);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, _("Level two"), 1, LEVEL_MEDIUM, -1);
  if (p.level[PLAYER1] == LEVEL_MEDIUM)
    gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox1), &iter);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, _("Level three"), 1, LEVEL_STRONG, -1);
  if (p.level[PLAYER1] == LEVEL_STRONG)
    gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox1), &iter);
  g_signal_connect (combobox1, "changed", G_CALLBACK (on_select_player1), NULL);
  gtk_grid_attach (GTK_GRID (grid), combobox1, 1, 0, 1, 1);

  label = gtk_label_new (_("Player Two:"));
  gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1);

  combobox2 = gtk_combo_box_new ();
  renderer = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox2), renderer, TRUE);
  gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combobox2), renderer, "text", 0);
  model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
  gtk_combo_box_set_model (GTK_COMBO_BOX (combobox2), GTK_TREE_MODEL (model));
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, _("Human"), 1, LEVEL_HUMAN, -1);
  if (p.level[PLAYER2] == LEVEL_HUMAN)
    gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox2), &iter);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, _("Level one"), 1, LEVEL_WEAK, -1);
  if (p.level[PLAYER2] == LEVEL_WEAK)
    gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox2), &iter);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, _("Level two"), 1, LEVEL_MEDIUM, -1);
  if (p.level[PLAYER2] == LEVEL_MEDIUM)
    gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox2), &iter);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, _("Level three"), 1, LEVEL_STRONG, -1);
  if (p.level[PLAYER2] == LEVEL_STRONG)
    gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox2), &iter);
  g_signal_connect (combobox2, "changed", G_CALLBACK (on_select_player2), NULL);
  gtk_grid_attach (GTK_GRID (grid), combobox2, 1, 1, 1, 1);

  label = gtk_label_new_with_mnemonic (_("_Theme:"));
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
  gtk_grid_attach (GTK_GRID (grid), label, 0, 2, 1, 1);

  combobox_theme = gtk_combo_box_text_new ();
  for (i = 0; i < n_themes; i++) {
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combobox_theme),
		 	            _(theme_get_title (i)));
  }
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), combobox_theme);
  gtk_grid_attach (GTK_GRID (grid), combobox_theme, 1, 2, 1, 1);

  checkbutton_animate =
    gtk_check_button_new_with_mnemonic (_("Enable _animation"));
  gtk_grid_attach (GTK_GRID (grid), checkbutton_animate, 0, 3, 2, 1);

  checkbutton_sound =
    gtk_check_button_new_with_mnemonic (_("E_nable sounds"));
  gtk_grid_attach (GTK_GRID (grid), checkbutton_sound, 0, 4, 2, 1);

  /* keyboard tab */

  label = gtk_label_new_with_mnemonic (_("Keyboard Controls"));

  controls_list = games_controls_list_new (settings);
  games_controls_list_add_controls (GAMES_CONTROLS_LIST (controls_list),
				    "key-left", _("Move left"), DEFAULT_KEY_LEFT,
                                    "key-right", _("Move right"), DEFAULT_KEY_RIGHT,
				    "key-drop", _("Drop marble"), DEFAULT_KEY_DROP,
                                    NULL);
  gtk_container_set_border_width (GTK_CONTAINER (controls_list), 12);
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), controls_list, label);

  /* fill in initial values */

  gtk_combo_box_set_active (GTK_COMBO_BOX (combobox_theme), p.theme_id);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton_animate),
				p.do_animate);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton_sound),
				p.do_sound);

  /* connect signals */

  g_signal_connect (prefsbox, "response", G_CALLBACK (on_dialog_close),
		    &prefsbox);

  g_signal_connect (G_OBJECT (combobox_theme), "changed",
		    G_CALLBACK (on_select_theme), NULL);

  g_signal_connect (G_OBJECT (checkbutton_animate), "toggled",
		    G_CALLBACK (on_toggle_animate), NULL);

  g_signal_connect (G_OBJECT (checkbutton_sound), "toggled",
		    G_CALLBACK (on_toggle_sound), NULL);

  gtk_widget_show_all (prefsbox);
}
コード例 #3
0
ファイル: gbhbox.c プロジェクト: cooljeanius/glade-1.1.3
/* This updates the box size to the given value, adding placeholders or
   deleting widgets as necessary. */
void
gb_box_set_size (GtkWidget * widget, gint size)
{
  GtkWidget *new_child;
  gint current_size = g_list_length (GTK_BOX (widget)->children);
  gint i;

  if (current_size < size)
    {
      /* This avoids any problems with redrawing the selection. */
      editor_clear_selection (NULL);

      for (i = 0; i < size - current_size; i++)
	{
	  if (GTK_IS_BUTTON_BOX (widget))
	    {
	      new_child = gb_widget_new ("GtkButton", widget);
	      GTK_WIDGET_SET_FLAGS (new_child, GTK_CAN_DEFAULT);
	      gtk_box_pack_start (GTK_BOX (widget), new_child, TRUE, TRUE, 0);
	      tree_add_widget (new_child);
	    }
	  else
	    {
	      new_child = editor_new_placeholder ();
	      gtk_box_pack_start (GTK_BOX (widget), new_child, TRUE, TRUE, 0);
	    }
	}
    }
  else if (current_size > size)
    {
      GList *children, *elem;
      GtkWidget *child;
      gchar *error = NULL;

      /* Get a list of children in the order they appear in the box, start at
	 the end and move backwards until we find a widget that can be
	 destroyed. If we can't find any, show a message box. */
      children = gtk_container_get_children (GTK_CONTAINER (widget));
      elem = g_list_last (children);

      while (elem)
	{
	  child = elem->data;
	  error = editor_can_delete_widget (child);
	  if (!error)
	    {
	      gtk_container_remove (GTK_CONTAINER (widget), child);
	      current_size--;
	      if (current_size == size)
		break;
	    }
	  elem = elem->prev;
	}

      g_list_free (children);

      if (current_size > size)
	{
	  glade_util_show_message_box (error ? error
				       : _("Can't delete any children."),
				       widget);
	}
    }
}
コード例 #4
0
/* Run a GUI to select and uninstall products */
int uninstall_ui(int argc, char *argv[])
{
    GtkWidget *window;
    GtkWidget *widget;
    GtkWidget *frame;
    GtkWidget *vbox;
    GtkWidget *button;
    GtkWidget *label;
    const char *product_name;
    product_t *product;
    product_info_t *product_info;
    product_component_t *component;
    component_list *component_list, *addon_list;
    char text[1024];

    gtk_init(&argc,&argv);

    /* Initialize Glade */
    glade_init();
    uninstall_glade = glade_xml_new(DATADIR "/uninstall.glade", "loki_uninstall"); 

    /* Add all signal handlers defined in glade file */
    glade_xml_signal_autoconnect(uninstall_glade);

    /* Make sure the window is visible */
    widget = glade_xml_get_widget(uninstall_glade, "uninstall_button");
    if ( widget ) {
        gtk_button_set_sensitive(widget, FALSE);
    }
    window = glade_xml_get_widget(uninstall_glade, "loki_uninstall");
    gtk_widget_realize(window);
    while( gtk_events_pending() ) {
        gtk_main_iteration();
    }

    /* Add emergency signal handlers */
    signal(SIGHUP, main_signal_abort);
    signal(SIGINT, main_signal_abort);
    signal(SIGQUIT, main_signal_abort);
    signal(SIGTERM, main_signal_abort);

    /* Fill in the list of products and components */
    widget = glade_xml_get_widget(uninstall_glade, "uninstall_vbox");
    if ( ! widget ) {
        fprintf(stderr, _("No uninstall_vbox in glade file!\n"));
        return(-1);
    }
    gtk_container_foreach(GTK_CONTAINER(widget), empty_container, widget);
    for ( product_name=loki_getfirstproduct();
          product_name;
          product_name=loki_getnextproduct() ) {
        /* See if we can open the product */
        product = loki_openproduct(product_name);
        if ( ! product ) {
            continue;
        }
        /* See if we have permissions to remove the product */
        product_info = loki_getinfo_product(product);
        if ( ! check_permissions(product_info, 0) ) {
            loki_closeproduct(product);
            continue;
        }
        /* Add the product and components to our list */
        strncpy(text, product_info->description, sizeof(text));
        frame = gtk_frame_new(text);
        gtk_container_set_border_width(GTK_CONTAINER(frame), 4);
        gtk_box_pack_start(GTK_BOX(widget), frame, FALSE, TRUE, 0);
        gtk_widget_show(frame);
        vbox = gtk_vbox_new(FALSE, 0);
        gtk_container_add (GTK_CONTAINER (frame), vbox);
        gtk_widget_show(vbox);
        component = loki_getdefault_component(product);
        component_list = NULL;
        if ( component ) {
            component_list = create_component_list(product, product_info,
                                                   component);
            strncpy(text, _("Complete uninstall"), sizeof(text));
            button = gtk_check_button_new_with_label(text);
            gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
            gtk_signal_connect(GTK_OBJECT(button), "toggled",
                               GTK_SIGNAL_FUNC(component_toggled_slot),
                               (gpointer)component_list);
            gtk_object_set_data(GTK_OBJECT(button), "data",
                                (gpointer)component_list);
            gtk_widget_show(button);
        }
        for ( component = loki_getfirst_component(product);
              component;
              component = loki_getnext_component(component) ) {
            if ( loki_isdefault_component(component) ) {
                continue;
            }
            addon_list = create_component_list(product, product_info,
                                               component);
            strncpy(text, loki_getname_component(component), sizeof(text));
            button = gtk_check_button_new_with_label(text);
            gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
            gtk_signal_connect(GTK_OBJECT(button), "toggled",
                               GTK_SIGNAL_FUNC(component_toggled_slot),
                               (gpointer)addon_list);
            gtk_object_set_data(GTK_OBJECT(button), "data",
                                (gpointer)addon_list);
            gtk_widget_show(button);
            add_component_list(component_list, button);
        }

        /* Add this product to our list of open products */
        add_product(product);
    }

    /* Check to make sure there's something to uninstall */
    if ( ! product_list ) {
        label = gtk_label_new(
							  _("No products were installed by this user.\n"
								"You may need to run this tool as an administrator."));
        gtk_box_pack_start(GTK_BOX(widget), label, FALSE, TRUE, 0);
        gtk_widget_show(label);
    }

    /* Run the UI.. */
    gtk_main();

    /* Close all the products and return */
    close_products(0);
    return 0;
}
コード例 #5
0
ファイル: browser.c プロジェクト: kba/yad-dialog
gint
main (gint argc, gchar * argv[])
{
  IconBrowserData *data;
  gchar **themes = NULL;
  GList *ic, *icat;
  GtkListStore *store;
  GtkTreeSelection *sel;
  GtkTreeViewColumn *col;
  GtkCellRenderer *r;
  GtkWidget *w, *p, *box, *t;

  GOptionEntry entrs[] = {
    {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &themes, NULL, NULL},
    {NULL}
  };

  data = g_new0 (IconBrowserData, 1);

#ifdef ENABLE_NLS
  bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);
#endif

  data = g_new0 (IconBrowserData, 1);

  /* initialize GTK+ and parse the command line arguments */
  gtk_init_with_args (&argc, &argv, _("- Icon browser"), entrs, GETTEXT_PACKAGE, NULL);

  /* load icon theme */
  if (themes && themes[0])
    {
      data->theme = gtk_icon_theme_new ();
      gtk_icon_theme_set_custom_theme (data->theme, themes[0]);
    }
  else
    data->theme = gtk_icon_theme_get_default ();

  /* create interface */
  data->win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (data->win), _("Icon browser"));
  gtk_window_set_icon_name (GTK_WINDOW (data->win), "gtk-info");
  gtk_window_set_default_size (GTK_WINDOW (data->win), 500, 400);
  g_signal_connect (G_OBJECT (data->win), "delete-event", G_CALLBACK (gtk_main_quit), NULL);
  g_signal_connect (G_OBJECT (data->win), "key-press-event", G_CALLBACK (key_press_cb), NULL);

#if !GTK_CHECK_VERSION(3,0,0)
  box = gtk_vbox_new (FALSE, 5);
#else
  box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
#endif
  gtk_container_add (GTK_CONTAINER (data->win), box);
  gtk_container_set_border_width (GTK_CONTAINER (data->win), 5);

  /* create icon info box */
#if !GTK_CHECK_VERSION(3,0,0)
  t = gtk_table_new (3, 3, FALSE);
  gtk_table_set_col_spacings (GTK_TABLE (t), 5);
  gtk_table_set_row_spacings (GTK_TABLE (t), 5);
#else
  t = gtk_grid_new ();
  gtk_grid_set_row_spacing (GTK_GRID (t), 5);
  gtk_grid_set_column_spacing (GTK_GRID (t), 5);
#endif
  gtk_box_pack_start (GTK_BOX (box), t, FALSE, FALSE, 2);

  data->image = gtk_image_new_from_stock ("gtk-missing-image", GTK_ICON_SIZE_DIALOG);
#if !GTK_CHECK_VERSION(3,0,0)
  gtk_table_attach (GTK_TABLE (t), data->image, 0, 1, 0, 3, GTK_FILL, 0, 0, 0);
#else
  gtk_grid_attach (GTK_GRID (t), data->image, 0, 0, 1, 3);
#endif

  w = gtk_label_new (NULL);
  gtk_label_set_markup (GTK_LABEL (w), _("<b>Name:</b>"));
  gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5);
#if !GTK_CHECK_VERSION(3,0,0)
  gtk_table_attach (GTK_TABLE (t), w, 1, 2, 0, 1, GTK_FILL, 0, 0, 0);
#else
  gtk_grid_attach (GTK_GRID (t), w, 1, 0, 1, 1);
#endif
  data->lname = gtk_label_new (NULL);
  gtk_label_set_selectable (GTK_LABEL (data->lname), TRUE);
  gtk_misc_set_alignment (GTK_MISC (data->lname), 0, 0.5);
#if !GTK_CHECK_VERSION(3,0,0)
  gtk_table_attach (GTK_TABLE (t), data->lname, 2, 3, 0, 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);
#else
  gtk_grid_attach (GTK_GRID (t), data->lname, 2, 0, 1, 1);
  gtk_widget_set_hexpand (data->lname, TRUE);
#endif

  w = gtk_label_new (NULL);
  gtk_label_set_markup (GTK_LABEL (w), _("<b>Sizes:</b>"));
  gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5);
#if !GTK_CHECK_VERSION(3,0,0)
  gtk_table_attach (GTK_TABLE (t), w, 1, 2, 1, 2, GTK_FILL, 0, 0, 0);
#else
  gtk_grid_attach (GTK_GRID (t), w, 1, 1, 1, 1);
#endif
  data->lsize = gtk_label_new (NULL);
  gtk_label_set_selectable (GTK_LABEL (data->lsize), TRUE);
  gtk_misc_set_alignment (GTK_MISC (data->lsize), 0, 0.5);
#if !GTK_CHECK_VERSION(3,0,0)
  gtk_table_attach (GTK_TABLE (t), data->lsize, 2, 3, 1, 2, GTK_FILL | GTK_EXPAND, 0, 0, 0);
#else
  gtk_grid_attach (GTK_GRID (t), data->lsize, 2, 1, 1, 1);
  gtk_widget_set_hexpand (data->lsize, TRUE);
#endif

  w = gtk_label_new (NULL);
  gtk_label_set_markup (GTK_LABEL (w), _("<b>Filename:</b>"));
  gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5);
#if !GTK_CHECK_VERSION(3,0,0)
  gtk_table_attach (GTK_TABLE (t), w, 1, 2, 2, 3, GTK_FILL, 0, 0, 0);
#else
  gtk_grid_attach (GTK_GRID (t), w, 1, 2, 1, 1);
#endif
  data->lfile = gtk_label_new (NULL);
  gtk_label_set_selectable (GTK_LABEL (data->lfile), TRUE);
  gtk_misc_set_alignment (GTK_MISC (data->lfile), 0, 0.5);
#if !GTK_CHECK_VERSION(3,0,0)
  gtk_table_attach (GTK_TABLE (t), data->lfile, 2, 3, 2, 3, GTK_FILL | GTK_EXPAND, 0, 0, 0);
#else
  gtk_grid_attach (GTK_GRID (t), data->lfile, 2, 2, 1, 1);
  gtk_widget_set_hexpand (data->lfile, TRUE);
#endif

  /* create icon browser */
#if !GTK_CHECK_VERSION(3,0,0)
  p = gtk_hpaned_new ();
#else
  p = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
#endif
  gtk_paned_set_position (GTK_PANED (p), 150);
  gtk_box_pack_start (GTK_BOX (box), p, TRUE, TRUE, 2);

  /* create category list */
  w = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (w), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (w), GTK_SHADOW_ETCHED_IN);
  gtk_paned_add1 (GTK_PANED (p), w);

  store = gtk_list_store_new (1, G_TYPE_STRING);

  data->cat_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (data->cat_list), TRUE);
  gtk_container_add (GTK_CONTAINER (w), data->cat_list);

  sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (data->cat_list));
  g_signal_connect (G_OBJECT (sel), "changed", G_CALLBACK (select_cat), data);

  r = gtk_cell_renderer_text_new ();
  col = gtk_tree_view_column_new_with_attributes (_("Category"), r, "text", 0, NULL);
  gtk_tree_view_column_set_expand (col, TRUE);
  gtk_tree_view_append_column (GTK_TREE_VIEW (data->cat_list), col);

  /* load icons category */
  data->icons = g_hash_table_new (g_direct_hash, g_direct_equal);
  icat = gtk_icon_theme_list_contexts (data->theme);
  for (ic = icat; ic; ic = ic->next)
    {
      GtkTreeIter iter;

      gtk_list_store_append (store, &iter);
      gtk_list_store_set (store, &iter, 0, ic->data, -1);
      g_free (ic->data);
    }
  g_list_free (icat);

  /* create icons list */
  w = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (w), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (w), GTK_SHADOW_ETCHED_IN);
  gtk_paned_add2 (GTK_PANED (p), w);

  data->icon_list = gtk_tree_view_new ();
  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (data->icon_list), TRUE);
  gtk_container_add (GTK_CONTAINER (w), data->icon_list);

  sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (data->icon_list));
  g_signal_connect (G_OBJECT (sel), "changed", G_CALLBACK (select_icon), data);

  col = gtk_tree_view_column_new ();
  gtk_tree_view_column_set_title (col, _("Icons"));
  gtk_tree_view_column_set_sort_column_id (col, 1);
  r = gtk_cell_renderer_pixbuf_new ();
  gtk_tree_view_column_pack_start (col, r, FALSE);
  gtk_tree_view_column_set_attributes (col, r, "pixbuf", 0, NULL);
  r = gtk_cell_renderer_text_new ();
  gtk_tree_view_column_pack_start (col, r, FALSE);
  gtk_tree_view_column_set_attributes (col, r, "text", 1, NULL);
  gtk_tree_view_column_set_expand (col, TRUE);
  gtk_tree_view_append_column (GTK_TREE_VIEW (data->icon_list), col);

  gtk_widget_show_all (data->win);

  /* run it */
  gtk_main ();

  return 0;
}
コード例 #6
0
ファイル: startgtk.game.c プロジェクト: agx/jfsw
static GtkWidget *create_window(void)
{
    GtkWidget *startwin;
    GtkWidget *hlayout;
    GtkWidget *banner;
    GtkWidget *vlayout;
    GtkWidget *tabs;
    GtkWidget *configvlayout;
    GtkWidget *configlayout;
    GtkWidget *fullscreencheck;
    GtkWidget *vmode3dlabel;
    GtkWidget *inputdevlabel;
    GtkWidget *inputmousecheck;
    GtkWidget *inputjoycheck;
    GtkWidget *vmode3dcombo;
    GtkWidget *alwaysshowcheck;
    GtkWidget *configtab;
    GtkWidget *gamevlayout;
    GtkWidget *gamelabel;
    GtkWidget *gamescroll;
    GtkWidget *gamelist;
    GtkWidget *gametab;
    GtkWidget *messagesscroll;
    GtkWidget *messagestext;
    GtkWidget *messagestab;
    GtkWidget *buttons;
    GtkWidget *cancelbutton;
    GtkWidget *cancelbuttonalign;
    GtkWidget *cancelbuttonlayout;
    GtkWidget *cancelbuttonicon;
    GtkWidget *cancelbuttonlabel;
    GtkWidget *startbutton;
    GtkWidget *startbuttonalign;
    GtkWidget *startbuttonlayout;
    GtkWidget *startbuttonicon;
    GtkWidget *startbuttonlabel;
    GtkAccelGroup *accel_group;

    accel_group = gtk_accel_group_new ();

    // Basic window
    startwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title (GTK_WINDOW (startwin), apptitle);   // NOTE: use global app title
    gtk_window_set_position (GTK_WINDOW (startwin), GTK_WIN_POS_CENTER);
    gtk_window_set_resizable (GTK_WINDOW (startwin), FALSE);
    gtk_window_set_type_hint (GTK_WINDOW (startwin), GDK_WINDOW_TYPE_HINT_DIALOG);

    // Horizontal layout of banner and controls
    hlayout = gtk_hbox_new (FALSE, 0);
    gtk_widget_show (hlayout);
    gtk_container_add (GTK_CONTAINER (startwin), hlayout);

    // Banner
    {
        GdkPixbuf *pixbuf = load_banner();
        banner = gtk_image_new_from_pixbuf(pixbuf);
        g_object_unref((gpointer)pixbuf);
    }
    gtk_widget_show (banner);
    gtk_box_pack_start (GTK_BOX (hlayout), banner, FALSE, FALSE, 0);
    gtk_misc_set_alignment (GTK_MISC (banner), 0.5, 0);

    // Vertical layout of tab control and start+cancel buttons
    vlayout = gtk_vbox_new (FALSE, 0);
    gtk_widget_show (vlayout);
    gtk_box_pack_start (GTK_BOX (hlayout), vlayout, TRUE, TRUE, 0);

    // Tab control
    tabs = gtk_notebook_new ();
    gtk_widget_show (tabs);
    gtk_box_pack_start (GTK_BOX (vlayout), tabs, TRUE, TRUE, 0);
    gtk_container_set_border_width (GTK_CONTAINER (tabs), 4);

    // Vertical layout of config page main body
    configvlayout = gtk_vbox_new (FALSE, 0);
    gtk_widget_show (configvlayout);
    gtk_container_add (GTK_CONTAINER (tabs), configvlayout);

    // Fixed-position layout of config page controls
    configlayout = gtk_fixed_new ();
    gtk_widget_show (configlayout);
    gtk_box_pack_start (GTK_BOX (configvlayout), configlayout, TRUE, TRUE, 0);
    gtk_container_set_border_width (GTK_CONTAINER (configlayout), 6);

    // Fullscreen checkbox
    fullscreencheck = gtk_check_button_new_with_mnemonic ("_Fullscreen");
    gtk_widget_show (fullscreencheck);
    gtk_fixed_put (GTK_FIXED (configlayout), fullscreencheck, 248, 0);
    gtk_widget_set_size_request (fullscreencheck, 85, 29);
    gtk_widget_add_accelerator (fullscreencheck, "grab_focus", accel_group,
                                GDK_F, GDK_MOD1_MASK,
                                GTK_ACCEL_VISIBLE);

    // 3D video mode label
    vmode3dlabel = gtk_label_new_with_mnemonic ("_Video mode:");
    gtk_widget_show (vmode3dlabel);
    gtk_fixed_put (GTK_FIXED (configlayout), vmode3dlabel, 0, 0);
    gtk_widget_set_size_request (vmode3dlabel, 88, 29);
    gtk_misc_set_alignment (GTK_MISC (vmode3dlabel), 0, 0.5);

    inputdevlabel = gtk_label_new ("Input devices:");
    gtk_widget_show (inputdevlabel);
    gtk_fixed_put (GTK_FIXED (configlayout), inputdevlabel, 0, 120);
    gtk_widget_set_size_request (inputdevlabel, 88, 20);
    gtk_misc_set_alignment (GTK_MISC (inputdevlabel), 0, 0.5);

    inputmousecheck = gtk_check_button_new_with_mnemonic ("Mo_use");
    gtk_widget_show (inputmousecheck);
    gtk_fixed_put (GTK_FIXED (configlayout), inputmousecheck, 88, 120);
    gtk_widget_set_size_request (inputmousecheck, 80, 20);
    gtk_widget_add_accelerator (inputmousecheck, "grab_focus", accel_group,
                                GDK_U, GDK_MOD1_MASK,
                                GTK_ACCEL_VISIBLE);

    inputjoycheck = gtk_check_button_new_with_mnemonic ("_Joystick");
    gtk_widget_show (inputjoycheck);
    gtk_fixed_put (GTK_FIXED (configlayout), inputjoycheck, 168, 120);
    gtk_widget_set_size_request (inputjoycheck, 80, 20);
    gtk_widget_add_accelerator (inputjoycheck, "grab_focus", accel_group,
                                GDK_J, GDK_MOD1_MASK,
                                GTK_ACCEL_VISIBLE);

    // 3D video mode combo
    {
        GtkListStore *list = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
        GtkCellRenderer *cell;

        vmode3dcombo = gtk_combo_box_new_with_model (GTK_TREE_MODEL(list));
        g_object_unref(G_OBJECT(list));

        cell = gtk_cell_renderer_text_new();
        gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(vmode3dcombo), cell, FALSE);
        gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(vmode3dcombo), cell, "text", 0, NULL);
    }
    gtk_widget_show (vmode3dcombo);
    gtk_fixed_put (GTK_FIXED (configlayout), vmode3dcombo, 88, 0);
    gtk_widget_set_size_request (vmode3dcombo, 150, 29);
    gtk_widget_add_accelerator (vmode3dcombo, "grab_focus", accel_group,
                                GDK_V, GDK_MOD1_MASK,
                                GTK_ACCEL_VISIBLE);

    // Always show config checkbox
    alwaysshowcheck = gtk_check_button_new_with_mnemonic ("_Always show configuration on start");
    gtk_widget_show (alwaysshowcheck);
    gtk_box_pack_start (GTK_BOX (configvlayout), alwaysshowcheck, FALSE, FALSE, 0);
    gtk_widget_add_accelerator (alwaysshowcheck, "grab_focus", accel_group,
                                GDK_A, GDK_MOD1_MASK,
                                GTK_ACCEL_VISIBLE);

    // Configuration tab
    configtab = gtk_label_new ("Configuration");
    gtk_widget_show (configtab);
    gtk_notebook_set_tab_label (GTK_NOTEBOOK (tabs), gtk_notebook_get_nth_page (GTK_NOTEBOOK (tabs), 0), configtab);

    // Game data layout
    gamevlayout = gtk_vbox_new (FALSE, 0);
    gtk_widget_show (gamevlayout);
    gtk_container_add (GTK_CONTAINER (tabs), gamevlayout);
    gtk_container_set_border_width (GTK_CONTAINER (gamevlayout), 4);

    // Game data field label
    gamelabel = gtk_label_new_with_mnemonic ("_Game or addon:");
    gtk_widget_show (gamelabel);
    gtk_box_pack_start (GTK_BOX (gamevlayout), gamelabel, FALSE, FALSE, 0);
    gtk_misc_set_alignment (GTK_MISC (gamelabel), 0, 0.5);

    // Game data scrollable area
    gamescroll = gtk_scrolled_window_new (NULL, NULL);
    gtk_widget_show (gamescroll);
    gtk_box_pack_start (GTK_BOX (gamevlayout), gamescroll, TRUE, TRUE, 0);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (gamescroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (gamescroll), GTK_SHADOW_IN);

    // Game data list
    {
        GtkListStore *list = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER);
        GtkCellRenderer *cell;
        GtkTreeViewColumn *col;

        gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(list), 0, name_sorter, NULL, NULL);
        gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(list), 0, GTK_SORT_ASCENDING);

        gamelist = gtk_tree_view_new_with_model (GTK_TREE_MODEL(list));
        g_object_unref(G_OBJECT(list));

        cell = gtk_cell_renderer_text_new();
        col = gtk_tree_view_column_new_with_attributes("Game", cell, "text", 0, NULL);
        gtk_tree_view_column_set_expand(col, TRUE);
        gtk_tree_view_append_column(GTK_TREE_VIEW(gamelist), col);
        col = gtk_tree_view_column_new_with_attributes("GRP file", cell, "text", 1, NULL);
        gtk_tree_view_column_set_min_width(col, 64);
        gtk_tree_view_append_column(GTK_TREE_VIEW(gamelist), col);
    }
    gtk_widget_show (gamelist);
    gtk_container_add (GTK_CONTAINER (gamescroll), gamelist);
    gtk_widget_add_accelerator (gamelist, "grab_focus", accel_group,
                                GDK_G, GDK_MOD1_MASK,
                                GTK_ACCEL_VISIBLE);
    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (gamelist), FALSE);
    gtk_tree_view_set_enable_search (GTK_TREE_VIEW (gamelist), FALSE);

    // Game tab
    gametab = gtk_label_new ("Game");
    gtk_widget_show (gametab);
    gtk_notebook_set_tab_label (GTK_NOTEBOOK (tabs), gtk_notebook_get_nth_page (GTK_NOTEBOOK (tabs), 1), gametab);

    // Messages scrollable area
    messagesscroll = gtk_scrolled_window_new (NULL, NULL);
    gtk_widget_show (messagesscroll);
    gtk_container_add (GTK_CONTAINER (tabs), messagesscroll);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (messagesscroll), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);

    // Messages text area
    messagestext = gtk_text_view_new ();
    gtk_widget_show (messagestext);
    gtk_container_add (GTK_CONTAINER (messagesscroll), messagestext);
    gtk_text_view_set_editable (GTK_TEXT_VIEW (messagestext), FALSE);
    gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (messagestext), GTK_WRAP_WORD);
    gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (messagestext), FALSE);
    gtk_text_view_set_left_margin (GTK_TEXT_VIEW (messagestext), 2);
    gtk_text_view_set_right_margin (GTK_TEXT_VIEW (messagestext), 2);

    // Messages tab
    messagestab = gtk_label_new ("Messages");
    gtk_widget_show (messagestab);
    gtk_notebook_set_tab_label (GTK_NOTEBOOK (tabs), gtk_notebook_get_nth_page (GTK_NOTEBOOK (tabs), 2), messagestab);

    // Dialogue box buttons layout
    buttons = gtk_hbutton_box_new ();
    gtk_widget_show (buttons);
    gtk_box_pack_start (GTK_BOX (vlayout), buttons, FALSE, TRUE, 0);
    gtk_container_set_border_width (GTK_CONTAINER (buttons), 3);
    gtk_button_box_set_layout (GTK_BUTTON_BOX (buttons), GTK_BUTTONBOX_END);

    // Cancel button
    cancelbutton = gtk_button_new ();
    gtk_widget_show (cancelbutton);
    gtk_container_add (GTK_CONTAINER (buttons), cancelbutton);
    GTK_WIDGET_SET_FLAGS (cancelbutton, GTK_CAN_DEFAULT);
    gtk_widget_add_accelerator (cancelbutton, "grab_focus", accel_group,
                                GDK_C, GDK_MOD1_MASK,
                                GTK_ACCEL_VISIBLE);
    gtk_widget_add_accelerator (cancelbutton, "clicked", accel_group,
                                GDK_Escape, 0,
                                GTK_ACCEL_VISIBLE);

    cancelbuttonalign = gtk_alignment_new (0.5, 0.5, 0, 0);
    gtk_widget_show (cancelbuttonalign);
    gtk_container_add (GTK_CONTAINER (cancelbutton), cancelbuttonalign);

    cancelbuttonlayout = gtk_hbox_new (FALSE, 2);
    gtk_widget_show (cancelbuttonlayout);
    gtk_container_add (GTK_CONTAINER (cancelbuttonalign), cancelbuttonlayout);

    cancelbuttonicon = gtk_image_new_from_stock ("gtk-cancel", GTK_ICON_SIZE_BUTTON);
    gtk_widget_show (cancelbuttonicon);
    gtk_box_pack_start (GTK_BOX (cancelbuttonlayout), cancelbuttonicon, FALSE, FALSE, 0);

    cancelbuttonlabel = gtk_label_new_with_mnemonic ("_Cancel");
    gtk_widget_show (cancelbuttonlabel);
    gtk_box_pack_start (GTK_BOX (cancelbuttonlayout), cancelbuttonlabel, FALSE, FALSE, 0);

    // Start button
    startbutton = gtk_button_new ();
    gtk_widget_show (startbutton);
    gtk_container_add (GTK_CONTAINER (buttons), startbutton);
    GTK_WIDGET_SET_FLAGS (startbutton, GTK_CAN_DEFAULT);
    gtk_widget_add_accelerator (startbutton, "grab_focus", accel_group,
                                GDK_S, GDK_MOD1_MASK,
                                GTK_ACCEL_VISIBLE);
    gtk_widget_add_accelerator (startbutton, "clicked", accel_group,
                                GDK_Return, 0,
                                GTK_ACCEL_VISIBLE);

    startbuttonalign = gtk_alignment_new (0.5, 0.5, 0, 0);
    gtk_widget_show (startbuttonalign);
    gtk_container_add (GTK_CONTAINER (startbutton), startbuttonalign);

    startbuttonlayout = gtk_hbox_new (FALSE, 2);
    gtk_widget_show (startbuttonlayout);
    gtk_container_add (GTK_CONTAINER (startbuttonalign), startbuttonlayout);

    startbuttonicon = gtk_image_new_from_stock ("gtk-execute", GTK_ICON_SIZE_BUTTON);
    gtk_widget_show (startbuttonicon);
    gtk_box_pack_start (GTK_BOX (startbuttonlayout), startbuttonicon, FALSE, FALSE, 0);

    startbuttonlabel = gtk_label_new_with_mnemonic ("_Start");
    gtk_widget_show (startbuttonlabel);
    gtk_box_pack_start (GTK_BOX (startbuttonlayout), startbuttonlabel, FALSE, FALSE, 0);

    // Wire up the signals
    g_signal_connect ((gpointer) startwin, "delete_event",
                      G_CALLBACK (on_startwin_delete_event),
                      NULL);
    g_signal_connect ((gpointer) fullscreencheck, "toggled",
                      G_CALLBACK (on_fullscreencheck_toggled),
                      NULL);
    g_signal_connect ((gpointer) inputmousecheck, "toggled",
                      G_CALLBACK (on_inputmousecheck_toggled),
                      NULL);
    g_signal_connect ((gpointer) inputjoycheck, "toggled",
                      G_CALLBACK (on_inputjoycheck_toggled),
                      NULL);
    g_signal_connect ((gpointer) vmode3dcombo, "changed",
                      G_CALLBACK (on_vmode3dcombo_changed),
                      NULL);
    g_signal_connect ((gpointer) alwaysshowcheck, "toggled",
                      G_CALLBACK (on_alwaysshowcheck_toggled),
                      NULL);
    g_signal_connect ((gpointer) cancelbutton, "clicked",
                      G_CALLBACK (on_cancelbutton_clicked),
                      NULL);
    g_signal_connect ((gpointer) startbutton, "clicked",
                      G_CALLBACK (on_startbutton_clicked),
                      NULL);
    {
        GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gamelist));
        gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
        g_signal_connect ((gpointer) sel, "changed",
                          G_CALLBACK (on_gamelist_selection_changed),
                          NULL);
    }

    // Associate labels with their controls
    gtk_label_set_mnemonic_widget (GTK_LABEL (vmode3dlabel), vmode3dcombo);
    gtk_label_set_mnemonic_widget (GTK_LABEL (gamelabel), gamelist);

    /* Store pointers to all widgets, for use by lookup_widget(). */
    GLADE_HOOKUP_OBJECT_NO_REF (startwin, startwin, "startwin");
    GLADE_HOOKUP_OBJECT (startwin, hlayout, "hlayout");
    GLADE_HOOKUP_OBJECT (startwin, banner, "banner");
    GLADE_HOOKUP_OBJECT (startwin, vlayout, "vlayout");
    GLADE_HOOKUP_OBJECT (startwin, tabs, "tabs");
    GLADE_HOOKUP_OBJECT (startwin, configvlayout, "configvlayout");
    GLADE_HOOKUP_OBJECT (startwin, configlayout, "configlayout");
    GLADE_HOOKUP_OBJECT (startwin, fullscreencheck, "fullscreencheck");
    GLADE_HOOKUP_OBJECT (startwin, vmode3dlabel, "vmode3dlabel");
    GLADE_HOOKUP_OBJECT (startwin, inputdevlabel, "inputdevlabel");
    GLADE_HOOKUP_OBJECT (startwin, inputmousecheck, "inputmousecheck");
    GLADE_HOOKUP_OBJECT (startwin, inputjoycheck, "inputjoycheck");
    GLADE_HOOKUP_OBJECT (startwin, vmode3dcombo, "vmode3dcombo");
    GLADE_HOOKUP_OBJECT (startwin, alwaysshowcheck, "alwaysshowcheck");
    GLADE_HOOKUP_OBJECT (startwin, configtab, "configtab");
    GLADE_HOOKUP_OBJECT (startwin, gamevlayout, "gamevlayout");
    GLADE_HOOKUP_OBJECT (startwin, gamelabel, "gamelabel");
    GLADE_HOOKUP_OBJECT (startwin, gamescroll, "gamescroll");
    GLADE_HOOKUP_OBJECT (startwin, gamelist, "gamelist");
    GLADE_HOOKUP_OBJECT (startwin, gametab, "gametab");
    GLADE_HOOKUP_OBJECT (startwin, messagesscroll, "messagesscroll");
    GLADE_HOOKUP_OBJECT (startwin, messagestext, "messagestext");
    GLADE_HOOKUP_OBJECT (startwin, messagestab, "messagestab");
    GLADE_HOOKUP_OBJECT (startwin, buttons, "buttons");
    GLADE_HOOKUP_OBJECT (startwin, cancelbutton, "cancelbutton");
    GLADE_HOOKUP_OBJECT (startwin, cancelbuttonalign, "cancelbuttonalign");
    GLADE_HOOKUP_OBJECT (startwin, cancelbuttonlayout, "cancelbuttonlayout");
    GLADE_HOOKUP_OBJECT (startwin, cancelbuttonicon, "cancelbuttonicon");
    GLADE_HOOKUP_OBJECT (startwin, cancelbuttonlabel, "cancelbuttonlabel");
    GLADE_HOOKUP_OBJECT (startwin, startbutton, "startbutton");
    GLADE_HOOKUP_OBJECT (startwin, startbuttonalign, "startbuttonalign");
    GLADE_HOOKUP_OBJECT (startwin, startbuttonlayout, "startbuttonlayout");
    GLADE_HOOKUP_OBJECT (startwin, startbuttonicon, "startbuttonicon");
    GLADE_HOOKUP_OBJECT (startwin, startbuttonlabel, "startbuttonlabel");

    gtk_window_add_accel_group (GTK_WINDOW (startwin), accel_group);

    return startwin;
}
コード例 #7
0
ファイル: testspreadtable.c プロジェクト: wolfv/libegg
static GtkWidget *
create_window (void)
{
  GtkWidget *window;
  GtkWidget *hbox, *vbox, *widget;
  GtkWidget *swindow, *frame, *expander;
  GtkWidget *paper_cntl, *items_cntl;

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  hbox   = gtk_hbox_new (FALSE, 2);
  vbox   = gtk_vbox_new (FALSE, 6);

  gtk_container_set_border_width (GTK_CONTAINER (window), 8);

  gtk_widget_show (vbox);
  gtk_widget_show (hbox);
  gtk_container_add (GTK_CONTAINER (window), hbox);
  gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);

  frame = gtk_frame_new ("SpreadTable");
  gtk_widget_show (frame);
  gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);

  swindow = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
                                  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  
  gtk_widget_show (swindow);
  gtk_container_add (GTK_CONTAINER (frame), swindow);

  paper = egg_spread_table_new (GTK_ORIENTATION_VERTICAL, INITIAL_LINES);
  egg_spread_table_set_vertical_spacing (EGG_SPREAD_TABLE (paper), INITIAL_VSPACING);
  egg_spread_table_set_horizontal_spacing (EGG_SPREAD_TABLE (paper), INITIAL_HSPACING);
  gtk_widget_show (paper);

  gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (swindow), paper);

  /* Add SpreadTable test control frame */
  expander = gtk_expander_new ("SpreadTable controls");
  gtk_expander_set_expanded (GTK_EXPANDER (expander), TRUE);
  paper_cntl = gtk_vbox_new (FALSE, 2);
  gtk_widget_show (paper_cntl);
  gtk_widget_show (expander);
  gtk_container_add (GTK_CONTAINER (expander), paper_cntl);
  gtk_box_pack_start (GTK_BOX (vbox), expander, FALSE, FALSE, 0);

  /* Add Orientation control */
  widget = gtk_combo_box_text_new ();
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Horizontal");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Vertical");
  gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 1);
  gtk_widget_show (widget);

  gtk_widget_set_tooltip_text (widget, "Set the spread_table orientation");
  gtk_box_pack_start (GTK_BOX (paper_cntl), widget, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (widget), "changed",
                    G_CALLBACK (orientation_changed), paper);


  /* Add horizontal/vertical spacing controls */
  hbox = gtk_hbox_new (FALSE, 2);
  gtk_widget_show (hbox);

  widget = gtk_label_new ("H Spacing");
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);

  widget = gtk_spin_button_new_with_range (0, 30, 1);
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), INITIAL_HSPACING);
  gtk_widget_show (widget);

  gtk_widget_set_tooltip_text (widget, "Set the horizontal spacing between children");
  gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (widget), "changed",
                    G_CALLBACK (spacing_changed), GINT_TO_POINTER (GTK_ORIENTATION_HORIZONTAL));
  g_signal_connect (G_OBJECT (widget), "value-changed",
                    G_CALLBACK (spacing_changed), GINT_TO_POINTER (GTK_ORIENTATION_HORIZONTAL));

  gtk_box_pack_start (GTK_BOX (paper_cntl), hbox, FALSE, FALSE, 0);

  hbox = gtk_hbox_new (FALSE, 2);
  gtk_widget_show (hbox);

  widget = gtk_label_new ("V Spacing");
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);

  widget = gtk_spin_button_new_with_range (0, 30, 1);
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), INITIAL_VSPACING);
  gtk_widget_show (widget);

  gtk_widget_set_tooltip_text (widget, "Set the vertical spacing between children");
  gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (widget), "changed",
                    G_CALLBACK (spacing_changed), GINT_TO_POINTER (GTK_ORIENTATION_VERTICAL));
  g_signal_connect (G_OBJECT (widget), "value-changed",
                    G_CALLBACK (spacing_changed), GINT_TO_POINTER (GTK_ORIENTATION_VERTICAL));

  gtk_box_pack_start (GTK_BOX (paper_cntl), hbox, FALSE, FALSE, 0);


  /* Add lines controls */
  hbox = gtk_hbox_new (FALSE, 2);
  gtk_widget_show (hbox);

  widget = gtk_label_new ("Lines");
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);

  widget = gtk_spin_button_new_with_range (1, 30, 1);
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), INITIAL_LINES);
  gtk_widget_show (widget);

  gtk_widget_set_tooltip_text (widget, "Set the horizontal spacing between children");
  gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (widget), "changed",
                    G_CALLBACK (lines_changed), NULL);
  g_signal_connect (G_OBJECT (widget), "value-changed",
                    G_CALLBACK (lines_changed), NULL);

  gtk_box_pack_start (GTK_BOX (paper_cntl), hbox, FALSE, FALSE, 0);


  /* Add test items control frame */
  expander = gtk_expander_new ("Test item controls");
  gtk_expander_set_expanded (GTK_EXPANDER (expander), TRUE);
  items_cntl = gtk_vbox_new (FALSE, 2);
  gtk_widget_show (items_cntl);
  gtk_widget_show (expander);
  gtk_container_add (GTK_CONTAINER (expander), items_cntl);
  gtk_box_pack_start (GTK_BOX (vbox), expander, FALSE, FALSE, 0);

  /* Add child halign control */
  widget = gtk_combo_box_text_new ();
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Fill");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Start");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "End");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Center");
  gtk_combo_box_set_active (GTK_COMBO_BOX (widget), INITIAL_HALIGN);
  gtk_widget_show (widget);

  gtk_widget_set_tooltip_text (widget, "Set the children's halign property");
  gtk_box_pack_start (GTK_BOX (items_cntl), widget, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (widget), "changed",
                    G_CALLBACK (halign_changed), paper);


  /* Add image control */
  widget = gtk_combo_box_text_new ();
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "None");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Small");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Large");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Huge");
  gtk_combo_box_set_active (GTK_COMBO_BOX (widget), INITIAL_IMAGE);
  gtk_widget_show (widget);

  gtk_widget_set_tooltip_text (widget, "Use an image to test the container");
  gtk_box_pack_start (GTK_BOX (items_cntl), widget, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (widget), "changed",
                    G_CALLBACK (test_image_changed), paper);


  /* Add horizontal/vertical spacing controls */
  hbox = gtk_hbox_new (FALSE, 2);
  gtk_widget_show (hbox);

  widget = gtk_label_new ("Image index");
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);

  widget = gtk_spin_button_new_with_range (0, 25, 1);
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), INITIAL_IMAGE_INDEX);
  gtk_widget_show (widget);

  gtk_widget_set_tooltip_text (widget, "Set the child list index for the optional test image");
  gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
  gtk_box_pack_start (GTK_BOX (items_cntl), hbox, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (widget), "changed",
                    G_CALLBACK (test_image_index_changed), GINT_TO_POINTER (GTK_ORIENTATION_HORIZONTAL));
  g_signal_connect (G_OBJECT (widget), "value-changed",
                    G_CALLBACK (test_image_index_changed), GINT_TO_POINTER (GTK_ORIENTATION_HORIZONTAL));

  populate_spread_table_wrappy (EGG_SPREAD_TABLE (paper));

  gtk_window_set_default_size (GTK_WINDOW (window), 500, 400);

  return window;
}
コード例 #8
0
static void
anjuta_save_prompt_init(AnjutaSavePrompt *obj)
{
	GtkWidget *vbox;
	GtkWidget *treeview;
	GtkListStore *store;
	GtkTreeViewColumn *col;
	GtkCellRenderer *renderer;
	GtkWidget *label;
	GtkWidget *scrolledwindow;
	
	obj->priv = g_new0(AnjutaSavePromptPrivate, 1);

	gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (obj), "Uninitialized");
	gtk_window_set_resizable (GTK_WINDOW (obj), TRUE);
	gtk_window_set_default_size (GTK_WINDOW (obj), 400, 300);
	
	vbox = gtk_vbox_new (FALSE, 0);
	gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (obj))),
			    vbox, TRUE, TRUE, 0);
	gtk_widget_show (vbox);
	
	label = gtk_label_new (_("Select the items to save:"));
	gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
	gtk_misc_set_padding  (GTK_MISC (label), 10, -1);
	gtk_misc_set_alignment (GTK_MISC (label), 0, -1);
	gtk_widget_show (label);
	
	store = gtk_list_store_new (N_COLS, G_TYPE_BOOLEAN,
								G_TYPE_STRING, G_TYPE_POINTER,
								G_TYPE_POINTER, G_TYPE_POINTER);
	
	scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
									GTK_POLICY_AUTOMATIC,
									GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow),
										 GTK_SHADOW_IN);
	gtk_box_pack_start (GTK_BOX (vbox), scrolledwindow, TRUE, TRUE, 0);
	gtk_container_set_border_width (GTK_CONTAINER (scrolledwindow), 10);
	gtk_widget_show (scrolledwindow);
	
	treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
	g_object_unref (store);
	gtk_container_add (GTK_CONTAINER (scrolledwindow), treeview);
	gtk_widget_show (treeview);
	
	label = gtk_label_new (_("If you do not save, all your changes will be lost."));
	gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
	gtk_misc_set_padding (GTK_MISC (label), 10, -1);
	gtk_misc_set_alignment (GTK_MISC (label), 0, -1);
	gtk_widget_show (label);
	
	renderer = gtk_cell_renderer_toggle_new ();
	col = gtk_tree_view_column_new_with_attributes (_("Save"),
													renderer,
													"active", COL_SAVE_ENABLE,
													NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), col);
	
	renderer = gtk_cell_renderer_text_new ();
	col = gtk_tree_view_column_new_with_attributes (_("Item"),
													renderer,
													"markup", COL_LABEL,
													NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), col);
	
	gtk_dialog_add_buttons (GTK_DIALOG (obj), _("_Discard changes"),
							ANJUTA_SAVE_PROMPT_RESPONSE_DISCARD,
							GTK_STOCK_CANCEL,
							ANJUTA_SAVE_PROMPT_RESPONSE_CANCEL,
							GTK_STOCK_SAVE,
							ANJUTA_SAVE_PROMPT_RESPONSE_SAVE_CLOSE,
							NULL);
	/* TRUE is the default and Gtk warns that this has no effect */
	/* gtk_dialog_set_has_separator (GTK_DIALOG (obj), TRUE); */
	gtk_dialog_set_default_response (GTK_DIALOG (obj),
									 ANJUTA_SAVE_PROMPT_RESPONSE_SAVE_CLOSE);
	g_signal_connect (obj, "response",
					  G_CALLBACK (on_dialog_response),
					  obj);
	obj->priv->treeview = treeview;
}
コード例 #9
0
ファイル: l_xrnngvn_p.c プロジェクト: zaharchuktv/linuxbuh
int l_xrnngvn_p(class l_xrnngvn_rek *rek_poi,GtkWidget *wpredok)
{
class l_xrnngvn_p_data data;
char strsql[512];
data.rk=rek_poi;


data.window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_position( GTK_WINDOW(data.window),ICEB_POS_CENTER);
gtk_window_set_modal(GTK_WINDOW(data.window),TRUE);
sprintf(strsql,"%s %s",name_system,gettext("Поиск"));

gtk_window_set_title(GTK_WINDOW(data.window),strsql);

gtk_signal_connect(GTK_OBJECT(data.window),"delete_event",GTK_SIGNAL_FUNC(gtk_widget_destroy),NULL);
gtk_signal_connect(GTK_OBJECT(data.window),"destroy",GTK_SIGNAL_FUNC(gtk_main_quit),NULL);
gtk_signal_connect_after(GTK_OBJECT(data.window),"key_press_event",GTK_SIGNAL_FUNC(l_xrnngvn_p_key_press),&data);

if(wpredok != NULL)
 {
  gdk_window_set_cursor(wpredok->window,gdk_cursor_new(ICEB_CURSOR_GDITE));
  //Удерживать окно над породившем его окном всегда
  gtk_window_set_transient_for(GTK_WINDOW(data.window),GTK_WINDOW(wpredok));
  //Закрыть окно если окно предок удалено
  gtk_window_set_destroy_with_parent(GTK_WINDOW(data.window),TRUE);
 }



GtkWidget *vbox = gtk_vbox_new (FALSE,1);
GtkWidget *hbox[KOLENTER];
for(int i=0; i < KOLENTER; i++)
 hbox[i] = gtk_hbox_new (FALSE,1);
GtkWidget *hboxknop = gtk_hbox_new (FALSE,1);

gtk_container_add (GTK_CONTAINER (data.window), vbox);
for(int i=0; i < KOLENTER; i++)
 gtk_container_add (GTK_CONTAINER (vbox), hbox[i]);
gtk_container_add (GTK_CONTAINER (vbox), hboxknop);


GtkWidget *label=gtk_label_new(gettext("Код"));
gtk_box_pack_start (GTK_BOX (hbox[E_KOD]), label, FALSE, FALSE,1);

data.entry[E_KOD] = gtk_entry_new_with_max_length (10);
gtk_box_pack_start (GTK_BOX (hbox[E_KOD]), data.entry[E_KOD], TRUE, TRUE,1);
gtk_signal_connect(GTK_OBJECT (data.entry[E_KOD]), "activate",GTK_SIGNAL_FUNC(l_xrnngvn_p_vvod),&data);
gtk_entry_set_text(GTK_ENTRY(data.entry[E_KOD]),data.rk->kod.ravno_toutf());
gtk_object_set_user_data(GTK_OBJECT(data.entry[E_KOD]),(gpointer)E_KOD);


label=gtk_label_new(gettext("Наименование"));
gtk_box_pack_start (GTK_BOX (hbox[E_NAIM]), label, FALSE, FALSE,1);

data.entry[E_NAIM] = gtk_entry_new_with_max_length (80);
gtk_box_pack_start (GTK_BOX (hbox[E_NAIM]), data.entry[E_NAIM], TRUE, TRUE,1);
gtk_signal_connect(GTK_OBJECT (data.entry[E_NAIM]), "activate",GTK_SIGNAL_FUNC(l_xrnngvn_p_vvod),&data);
gtk_entry_set_text(GTK_ENTRY(data.entry[E_NAIM]),data.rk->naim.ravno_toutf());
gtk_object_set_user_data(GTK_OBJECT(data.entry[E_NAIM]),(gpointer)E_NAIM);


GtkTooltips *tooltips[KOL_FK];

sprintf(strsql,"F2 %s",gettext("Поиск"));
data.knopka[FK2]=gtk_button_new_with_label(strsql);
tooltips[FK2]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[FK2],data.knopka[FK2],gettext("Начать поиск нужных записей"),NULL);
gtk_signal_connect(GTK_OBJECT(data.knopka[FK2]),"clicked",GTK_SIGNAL_FUNC(l_xrnngvn_p_knopka),&data);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK2]),(gpointer)FK2);
gtk_box_pack_start(GTK_BOX(hboxknop), data.knopka[FK2], TRUE, TRUE,1);

sprintf(strsql,"F4 %s",gettext("Очистить"));
data.knopka[FK4]=gtk_button_new_with_label(strsql);
tooltips[FK4]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[FK4],data.knopka[FK4],gettext("Очистить меню от введеноой информации"),NULL);
gtk_signal_connect(GTK_OBJECT(data.knopka[FK4]),"clicked",GTK_SIGNAL_FUNC(l_xrnngvn_p_knopka),&data);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK4]),(gpointer)FK4);
gtk_box_pack_start(GTK_BOX(hboxknop), data.knopka[FK4], TRUE, TRUE,1);


sprintf(strsql,"F10 %s",gettext("Выход"));
data.knopka[FK10]=gtk_button_new_with_label(strsql);
tooltips[FK10]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[FK10],data.knopka[FK10],gettext("Поиск не выполнять"),NULL);
gtk_signal_connect(GTK_OBJECT(data.knopka[FK10]),"clicked",GTK_SIGNAL_FUNC(l_xrnngvn_p_knopka),&data);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK10]),(gpointer)FK10);
gtk_box_pack_start(GTK_BOX(hboxknop), data.knopka[FK10], TRUE, TRUE,1);

gtk_widget_grab_focus(data.entry[0]);

gtk_widget_show_all (data.window);

gtk_main();

if(wpredok != NULL)
  gdk_window_set_cursor(wpredok->window,gdk_cursor_new(ICEB_CURSOR));

return(data.voz);

}
コード例 #10
0
int main(int argc, char *argv[]) {
	gtk_init(&argc, &argv);

	GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
	gtk_window_set_title(GTK_WINDOW(window), "Label Demo");

	GtkWidget *hbox = gtk_hbox_new(FALSE, 5);
	gtk_container_add(GTK_CONTAINER(window), hbox);
	gtk_widget_show(hbox);

	GtkWidget *vbox = gtk_vbox_new(FALSE, 5);
	gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
	gtk_widget_show(vbox);

	GtkWidget *frame;
	GtkWidget *label;

	frame = gtk_frame_new("Normal Label");
	label = gtk_label_new("This is a normal label.");
	gtk_container_add(GTK_CONTAINER(frame), label);
	gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
	
	frame = gtk_frame_new("Multi-line Label");
	label = gtk_label_new("This is a Multi-line \n label.");
	gtk_container_add(GTK_CONTAINER(frame), label);
	gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
	
	frame = gtk_frame_new("Left Justed Label");
	label = gtk_label_new("Left?.\nThis is the second line.");
	gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
	gtk_container_add(GTK_CONTAINER(frame), label);
	gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
	
	frame = gtk_frame_new("Right Justed Label");
	label = gtk_label_new("Right?.\nThis is the second line.");
	gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT);
	gtk_container_add(GTK_CONTAINER(frame), label);
	gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
	
	vbox = gtk_vbox_new(FALSE, 5);
	gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);

	frame = gtk_frame_new("Line wrapped label");
	label = gtk_label_new("This is an example of a line-warpped label. It should not be taking up the entire width allocated to it, but automatically wraps the words to fit.");
	gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
	gtk_container_add(GTK_CONTAINER(frame), label);
	gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);

	frame = gtk_frame_new("Filled, wrapped label");
	label = gtk_label_new("This is an example of a line-warpped label. It should not be taking up the entire width allocated to it, but automatically wraps the words to fit.");
	gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_FILL);
	gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
	gtk_container_add(GTK_CONTAINER(frame), label);
	gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);

	frame = gtk_frame_new("Filled, wrapped label");
	label = gtk_label_new("This is an example of a line-warpped \nlabel. It should not be taking up the entire width allocated to it, but automatically wraps the words to fit.");
	gtk_label_set_pattern(GTK_LABEL(label), "_ _ ");
	gtk_container_add(GTK_CONTAINER(frame), label);
	gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);

	gtk_widget_show_all(window);
	gtk_main();
	return 0;
}
コード例 #11
0
ファイル: 2d_table_editor.c プロジェクト: tocheskey/MegaTunix
G_MODULE_EXPORT gboolean create_2d_table_editor_group(GtkWidget *button)
{
	GladeXML *main_xml = NULL;
	GladeXML *xml = NULL;
	GtkWidget *widget = NULL;
	GtkWidget *window = NULL;
	GtkWidget *notebook = NULL;
	GtkWidget *curve = NULL;
	GtkWidget *x_parent = NULL;
	GtkWidget *y_parent = NULL;
	GtkWidget *x_table = NULL;
	GtkWidget *y_table = NULL;
	GtkWidget *label = NULL;
	GtkWidget *entry = NULL;
	GtkWidget *dummy = NULL;
	GtkWidget *gauge = NULL;
	GtkWidget *parent = NULL;
	GtkWidget *curve_parent = NULL;
	CurveData *cdata = NULL;
	GArray *x_entries = NULL;
	GArray *y_entries = NULL;
	GList *widget_list = NULL;
	GList *curve_list = NULL;
	GList *gauge_list = NULL;
	gchar * tmpbuf = NULL;
	gchar * filename = NULL;
	gchar **vector = NULL;
	GList ***ecu_widgets = NULL;
	gint num_tabs = 0;
	gint x_mult = 0;
	gint y_mult = 0;
	gint page = 0;
	gint offset = 0;
	gint i = 0;
	gint j = 0;
	gfloat tmpf = 0.0;
	guint32 id = 0;
	gint rows = 0;
	gint table_num = 0;
	Firmware_Details *firmware = NULL;

	firmware = DATA_GET(global_data,"firmware");
	ecu_widgets = DATA_GET(global_data,"ecu_widgets");

	main_xml = (GladeXML *)DATA_GET(global_data,"main_xml");
	if (!main_xml)
		return FALSE;

	xml = glade_xml_new(main_xml->filename,"table_editor_window",NULL);
	window = glade_xml_get_widget(xml,"table_editor_window");

	glade_xml_signal_autoconnect(xml);

	g_signal_connect(G_OBJECT(window),"destroy_event",
			G_CALLBACK(close_2d_editor),NULL);
	g_signal_connect(G_OBJECT(window),"delete_event",
			G_CALLBACK(close_2d_editor),NULL);
	gtk_window_set_title(GTK_WINDOW(window),_("2D Table Group Editor"));
	gtk_window_resize(GTK_WINDOW(window),800,530);

	widget = glade_xml_get_widget(xml,"2d_close_button");
	g_signal_connect_swapped(G_OBJECT(widget),"clicked",
			G_CALLBACK(close_2d_editor),window);

	widget = glade_xml_get_widget(xml,"get_data_button");
	OBJ_SET(widget,"handler",GINT_TO_POINTER(READ_VE_CONST));
	OBJ_SET_FULL(widget,"bind_to_list",g_strdup("get_data_buttons"),g_free);
	bind_to_lists_f(widget,"get_data_buttons");
	widget_list = g_list_prepend(widget_list,(gpointer)widget);

	widget = glade_xml_get_widget(xml,"burn_data_button");
	OBJ_SET(widget,"handler",GINT_TO_POINTER(BURN_MS_FLASH));
	OBJ_SET_FULL(widget,"bind_to_list",g_strdup("burners"),g_free);
	bind_to_lists_f(widget,"burners");
	widget_list = g_list_prepend(widget_list,(gpointer)widget);

	widget = glade_xml_get_widget(xml,"curve_editor_menuitem");
	gtk_widget_set_sensitive(GTK_WIDGET(widget), FALSE);

	widget = glade_xml_get_widget(xml,"close_menuitem");
	OBJ_SET(widget,"window",(gpointer)window);

	widget = glade_xml_get_widget(xml,"te_layout_hbox1");
	gtk_widget_destroy(widget);

	widget = glade_xml_get_widget(xml,"te_layout_vbox");

	tmpbuf = OBJ_GET(button,"te_tables");
	vector = parse_keys_f(tmpbuf,&num_tabs,",");
	notebook = gtk_notebook_new();
	gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook),GTK_POS_LEFT);
	gtk_box_pack_start(GTK_BOX(widget),notebook,TRUE,TRUE,0);
	for (j = 0;j < num_tabs;j++)
	{
		table_num = (gint)strtod(vector[j],NULL);
		if (table_num >= firmware->total_te_tables)
		{
			warn_user_f("Requested to create 2D table editor window for an undefined (out of range) table ID");
			return FALSE;
		}
		if (!firmware->te_params)
		{
			warn_user_f("No 2D table Editor tables (te_tables) defined in interrogation profile, yet told to create a graph for a table... BUG detected!");
			continue;
		}
		if (!firmware->te_params[table_num])
		{
			warn_user_f("Requested to create a 2D table editor window for an undefined table!");
			continue;
		}
		xml = glade_xml_new(main_xml->filename,"te_layout_hbox1",NULL);
		widget = glade_xml_get_widget(xml,"te_layout_hbox1");
		label = gtk_label_new(firmware->te_params[table_num]->title);
		gtk_misc_set_alignment(GTK_MISC(label),0,0.5);
		if (firmware->te_params[table_num]->bind_to_list)
		{
			OBJ_SET_FULL(widget,"bind_to_list", g_strdup(firmware->te_params[table_num]->bind_to_list),g_free);
			OBJ_SET(widget,"match_type", GINT_TO_POINTER(firmware->te_params[table_num]->match_type));
			bind_to_lists_f(widget,firmware->te_params[table_num]->bind_to_list);
			widget_list = g_list_prepend(widget_list,(gpointer)widget);
			OBJ_SET_FULL(label,"bind_to_list", g_strdup(firmware->te_params[table_num]->bind_to_list),g_free);
			OBJ_SET(label,"match_type", GINT_TO_POINTER(firmware->te_params[table_num]->match_type));
			bind_to_lists_f(label,firmware->te_params[table_num]->bind_to_list);
			widget_list = g_list_prepend(widget_list,(gpointer)label);
		}

		if (firmware->te_params[table_num]->gauge ||
				firmware->te_params[table_num]->c_gauge ||
				firmware->te_params[table_num]->f_gauge)
		{
			parent = glade_xml_get_widget(xml,"te_gaugeframe");
			gauge = mtx_gauge_face_new();
			gauge_list = g_list_prepend(gauge_list,(gpointer)gauge);

			OBJ_SET(window,"gauge",gauge);
			if (firmware->te_params[table_num]->gauge_temp_dep)
			{
				if ((GINT)DATA_GET(global_data,"mtx_temp_units") == CELSIUS)
					tmpbuf = g_strdelimit(firmware->te_params[table_num]->c_gauge,"\\",'/');
				else if ((GINT)DATA_GET(global_data,"mtx_temp_units") == KELVIN)
					tmpbuf = g_strdelimit(firmware->te_params[table_num]->c_gauge,"\\",'/');
				else
					tmpbuf = g_strdelimit(firmware->te_params[table_num]->f_gauge,"\\",'/');
			}
			else
				tmpbuf = g_strdelimit(firmware->te_params[table_num]->gauge,"\\",'/');
			filename = get_file(g_strconcat(GAUGES_DATA_DIR,PSEP,tmpbuf,NULL),NULL);
			mtx_gauge_face_import_xml(MTX_GAUGE_FACE(gauge),filename);
			lookup_current_value_f(firmware->te_params[table_num]->gauge_datasource, &tmpf);
			mtx_gauge_face_set_value(MTX_GAUGE_FACE(gauge),tmpf);
			g_free(filename);
			id = create_value_change_watch_f(firmware->te_params[table_num]->gauge_datasource,FALSE,"update_misc_gauge",(gpointer)gauge);
			OBJ_SET(gauge,"gauge_id",GINT_TO_POINTER(id));
			gtk_container_add(GTK_CONTAINER(parent),gauge);
		}
		gtk_notebook_append_page(GTK_NOTEBOOK(notebook),widget,label);
		curve_parent = glade_xml_get_widget(xml,"te_right_frame");
		curve = mtx_curve_new();
		curve_list = g_list_prepend(curve_list,(gpointer)curve);
		mtx_curve_set_title(MTX_CURVE(curve),_(firmware->te_params[table_num]->title));
		mtx_curve_set_x_axis_label(MTX_CURVE(curve),_(firmware->te_params[table_num]->x_axis_label));
		mtx_curve_set_y_axis_label(MTX_CURVE(curve),_(firmware->te_params[table_num]->y_axis_label));
		cdata = g_new0(CurveData, 1);
		cdata->curve = curve;
		cdata->axis = _X_;
		cdata->source = firmware->te_params[table_num]->x_source;
		id = create_value_change_watch_f(cdata->source,FALSE,"update_curve_marker",(gpointer)cdata);
		mtx_curve_set_show_x_marker(MTX_CURVE(curve),TRUE);
		OBJ_SET(curve,"cdata",(gpointer)cdata);
		OBJ_SET(curve,"marker_id",GINT_TO_POINTER(id));
		mtx_curve_set_auto_hide_vertexes(MTX_CURVE(curve),TRUE);
		g_signal_connect(G_OBJECT(curve),"coords-changed",
				G_CALLBACK(coords_changed), NULL);
		g_signal_connect(G_OBJECT(curve),"vertex-proximity",
				G_CALLBACK(vertex_proximity), NULL);
		g_signal_connect(G_OBJECT(curve),"marker-proximity",
				G_CALLBACK(marker_proximity), NULL);

		label = glade_xml_get_widget(xml,"x_units");
		gtk_label_set_markup(GTK_LABEL(label),firmware->te_params[table_num]->x_units);
		label = glade_xml_get_widget(xml,"y_units");
		gtk_label_set_markup(GTK_LABEL(label),firmware->te_params[table_num]->y_units);
		label = glade_xml_get_widget(xml,"x_title");
		gtk_label_set_markup(GTK_LABEL(label),firmware->te_params[table_num]->x_name);
		label = glade_xml_get_widget(xml,"y_title");
		gtk_label_set_markup(GTK_LABEL(label),firmware->te_params[table_num]->y_name);
		rows = firmware->te_params[table_num]->bincount;
		mtx_curve_set_empty_array(MTX_CURVE(curve),rows);
		x_table = gtk_table_new(rows+1,1,FALSE);
		y_table = gtk_table_new(rows+1,1,FALSE);

		x_parent = glade_xml_get_widget(xml,"te_x_frame");
		y_parent = glade_xml_get_widget(xml,"te_y_frame");
		gtk_container_set_border_width(GTK_CONTAINER(x_table),5);
		gtk_container_set_border_width(GTK_CONTAINER(y_table),5);
		gtk_container_add(GTK_CONTAINER(x_parent),x_table);
		gtk_container_add(GTK_CONTAINER(y_parent),y_table);

		x_mult = get_multiplier_f(firmware->te_params[table_num]->x_size);
		y_mult = get_multiplier_f(firmware->te_params[table_num]->y_size);
		x_entries = g_array_new(FALSE,TRUE,sizeof(GtkWidget *));
		y_entries = g_array_new(FALSE,TRUE,sizeof(GtkWidget *));
		for (i=0;i<rows;i++)
		{
			/* X Column */
			entry = gtk_entry_new();
			gtk_entry_set_width_chars(GTK_ENTRY(entry),7);
			OBJ_SET(entry,"curve_index",GINT_TO_POINTER(i));
			g_array_insert_val(x_entries,i,entry);
			OBJ_SET(entry,"curve_axis",GINT_TO_POINTER(_X_));
			OBJ_SET(entry,"dl_type",GINT_TO_POINTER(IMMEDIATE));
			OBJ_SET(entry,"handler",GINT_TO_POINTER(GENERIC));
			OBJ_SET_FULL(entry,"raw_lower",g_strdup_printf("%i",(firmware->te_params[table_num]->x_raw_lower)),g_free);
			OBJ_SET_FULL(entry,"raw_upper",g_strdup_printf("%i",(firmware->te_params[table_num]->x_raw_upper)),g_free);
			OBJ_SET(entry,"fromecu_mult",firmware->te_params[table_num]->x_fromecu_mult);
			OBJ_SET(entry,"fromecu_add",firmware->te_params[table_num]->x_fromecu_add);
			OBJ_SET(entry,"precision",GINT_TO_POINTER(firmware->te_params[table_num]->x_precision));
			OBJ_SET(entry,"size",GINT_TO_POINTER(firmware->te_params[table_num]->x_size));
			OBJ_SET(entry,"page",GINT_TO_POINTER(firmware->te_params[table_num]->x_page));
			OBJ_SET(entry,"temp_dep",GINT_TO_POINTER(firmware->te_params[table_num]->x_temp_dep));
			OBJ_SET(entry,"use_color",GINT_TO_POINTER(firmware->te_params[table_num]->x_use_color));
			OBJ_SET(entry,"force_color_update",GINT_TO_POINTER(firmware->te_params[table_num]->x_use_color));
			if(firmware->te_params[table_num]->x_temp_dep)
			{
				OBJ_SET(entry,"widget_temp",DATA_GET(global_data,"mtx_temp_units"));
				OBJ_SET_FULL(entry,"bind_to_list", g_strdup("temperature"),g_free);
				bind_to_lists_f(entry,"temperature");
			}

			offset = (i*x_mult) + firmware->te_params[table_num]->x_base;
			OBJ_SET(entry,"offset",GINT_TO_POINTER(offset));

			g_signal_connect(G_OBJECT(entry),"changed",
					G_CALLBACK(update_2d_curve),curve);
			g_signal_connect(G_OBJECT(entry),"changed",
					G_CALLBACK(entry_changed_handler_f),NULL);
			g_signal_connect(G_OBJECT(entry),"key_press_event",
					G_CALLBACK(key_event_f),NULL);
			g_signal_connect(G_OBJECT(entry),"key_release_event",
					G_CALLBACK(key_event_f),NULL);
			g_signal_connect(G_OBJECT(entry),"focus_out_event",
					G_CALLBACK(focus_out_handler_f),NULL);
			g_signal_connect(G_OBJECT(entry),"activate",
					G_CALLBACK(std_entry_handler_f),NULL);

			if (firmware->te_params[table_num]->reversed)
				gtk_table_attach(GTK_TABLE(x_table),entry,
						0,1,rows-i-1,rows-i, GTK_SHRINK,GTK_SHRINK,0,0);
			else
				gtk_table_attach(GTK_TABLE(x_table),entry,
						0,1,i,i+1, GTK_SHRINK,GTK_SHRINK,0,0);
			page = firmware->te_params[table_num]->x_page;
			ecu_widgets[page][offset] = g_list_prepend(ecu_widgets[page][offset],(gpointer)entry);
			widget_list = g_list_prepend(widget_list,(gpointer)entry);
			update_widget(G_OBJECT(entry),NULL);

			/* Y Column */
			entry = gtk_entry_new();
			gtk_entry_set_width_chars(GTK_ENTRY(entry),7);
			OBJ_SET(entry,"curve_index",GINT_TO_POINTER(i));
			g_array_insert_val(y_entries,i,entry);
			OBJ_SET(entry,"curve_axis",GINT_TO_POINTER(_Y_));
			OBJ_SET(entry,"dl_type",GINT_TO_POINTER(IMMEDIATE));
			OBJ_SET(entry,"handler",GINT_TO_POINTER(GENERIC));
			OBJ_SET_FULL(entry,"raw_lower",g_strdup_printf("%i",(firmware->te_params[table_num]->y_raw_lower)),g_free);
			OBJ_SET_FULL(entry,"raw_upper",g_strdup_printf("%i",(firmware->te_params[table_num]->y_raw_upper)),g_free);
			OBJ_SET(entry,"fromecu_mult",firmware->te_params[table_num]->y_fromecu_mult);
			OBJ_SET(entry,"fromecu_add",firmware->te_params[table_num]->y_fromecu_add);
			OBJ_SET(entry,"precision",GINT_TO_POINTER(firmware->te_params[table_num]->y_precision));
			OBJ_SET(entry,"size",GINT_TO_POINTER(firmware->te_params[table_num]->y_size));
			OBJ_SET(entry,"page",GINT_TO_POINTER(firmware->te_params[table_num]->y_page));
			OBJ_SET(entry,"temp_dep",GINT_TO_POINTER(firmware->te_params[table_num]->y_temp_dep));
			OBJ_SET(entry,"use_color",GINT_TO_POINTER(firmware->te_params[table_num]->y_use_color));
			OBJ_SET(entry,"force_color_update",GINT_TO_POINTER(firmware->te_params[table_num]->y_use_color));
			if(firmware->te_params[table_num]->y_temp_dep)
			{
				OBJ_SET(entry,"widget_temp",DATA_GET(global_data,"mtx_temp_units"));
				OBJ_SET_FULL(entry,"bind_to_list", g_strdup("temperature"),g_free);
				bind_to_lists_f(entry,"temperature");
			}
			offset = (i*y_mult) + firmware->te_params[table_num]->y_base;
			OBJ_SET(entry,"offset",GINT_TO_POINTER(offset));

			g_signal_connect(G_OBJECT(entry),"changed",
					G_CALLBACK(update_2d_curve),curve);
			g_signal_connect(G_OBJECT(entry),"changed",
					G_CALLBACK(entry_changed_handler_f),NULL);
			g_signal_connect(G_OBJECT(entry),"key_press_event",
					G_CALLBACK(key_event_f),NULL);
			g_signal_connect(G_OBJECT(entry),"key_release_event",
					G_CALLBACK(key_event_f),NULL);
			g_signal_connect(G_OBJECT(entry),"focus_out_event",
					G_CALLBACK(focus_out_handler_f),NULL);
			g_signal_connect(G_OBJECT(entry),"activate",
					G_CALLBACK(std_entry_handler_f),NULL);

			if (firmware->te_params[table_num]->reversed)
				gtk_table_attach(GTK_TABLE(y_table),entry,
						0,1,rows-i-1,rows-i, GTK_SHRINK,GTK_SHRINK,0,0);
			else
				gtk_table_attach(GTK_TABLE(y_table),entry,
						0,1,i,i+1, GTK_SHRINK,GTK_SHRINK,0,0);
			page = firmware->te_params[table_num]->y_page;
			ecu_widgets[page][offset] = g_list_prepend(ecu_widgets[page][offset],(gpointer)entry);
			widget_list = g_list_prepend(widget_list,(gpointer)entry);
			update_widget(G_OBJECT(entry),NULL);
		}
		/* Create the "LOCK" buttons */
		dummy = gtk_toggle_button_new_with_label("Unlocked");
		OBJ_SET(dummy,"axis",GINT_TO_POINTER(_X_));
		g_signal_connect(G_OBJECT(dummy),"toggled",
				G_CALLBACK(set_axis_locking),curve);
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dummy),firmware->te_params[table_num]->x_lock);
		gtk_table_attach(GTK_TABLE(x_table),dummy,
				0,1,i,i+1, GTK_EXPAND|GTK_FILL,0,0,0);
		dummy = gtk_toggle_button_new_with_label("Unlocked");
		OBJ_SET(dummy,"axis",GINT_TO_POINTER(_Y_));
		g_signal_connect(G_OBJECT(dummy),"toggled",
				G_CALLBACK(set_axis_locking),curve);
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dummy),firmware->te_params[table_num]->y_lock);
		gtk_table_attach(GTK_TABLE(y_table),dummy,
				0,1,i,i+1, GTK_EXPAND|GTK_FILL,0,0,0);

		mtx_curve_set_x_precision(MTX_CURVE(curve),firmware->te_params[table_num]->x_precision);
		mtx_curve_set_y_precision(MTX_CURVE(curve),firmware->te_params[table_num]->y_precision);
		mtx_curve_set_hard_limits(MTX_CURVE(curve),
				(gfloat)firmware->te_params[table_num]->x_raw_lower,
				(gfloat)firmware->te_params[table_num]->x_raw_upper,
				(gfloat)firmware->te_params[table_num]->y_raw_lower,
				(gfloat)firmware->te_params[table_num]->y_raw_upper);
		OBJ_SET(curve,"x_entries",x_entries);
		OBJ_SET(curve,"y_entries",y_entries);
		if (firmware->te_params[table_num]->bind_to_list)
			g_list_foreach(get_list_f(firmware->te_params[table_num]->bind_to_list),alter_widget_state_f,NULL);
		create_value_change_watch_f(cdata->source,TRUE,"update_curve_marker",(gpointer)cdata);
		gtk_container_add(GTK_CONTAINER(curve_parent),curve);
	}
	OBJ_SET(window,"widget_list",widget_list);
	OBJ_SET(window,"curve_list",curve_list);
	OBJ_SET(window,"gauge_list",gauge_list);
	gtk_widget_show_all(window);
	return TRUE;

}
コード例 #12
0
void _camera_import_dialog_new(_camera_import_dialog_t *data)
{
  data->dialog=gtk_dialog_new_with_buttons(_("import images from camera"),NULL,GTK_DIALOG_MODAL,_("cancel"),GTK_RESPONSE_NONE,C_("camera import", "import"),GTK_RESPONSE_ACCEPT,NULL);
  GtkWidget *content = gtk_dialog_get_content_area (GTK_DIALOG (data->dialog));

  // List - setup store
  data->store = gtk_list_store_new (2,GDK_TYPE_PIXBUF,G_TYPE_STRING);

  // IMPORT PAGE
  data->import.page=gtk_vbox_new(FALSE,5);
  gtk_container_set_border_width(GTK_CONTAINER(data->import.page),5);

  // Top info
  data->import.info=gtk_label_new( _("please wait while prefetching thumbnails of images from camera...") );
  gtk_label_set_single_line_mode( GTK_LABEL(data->import.info) , FALSE );
  gtk_misc_set_alignment(GTK_MISC(data->import.info), 0.0, 0.0);
  gtk_box_pack_start(GTK_BOX(data->import.page),data->import.info,FALSE,FALSE,0);

  // jobcode
  data->import.jobname=_camera_import_gconf_widget(data,_("jobcode"),"plugins/capture/camera/import/jobcode");
  gtk_box_pack_start(GTK_BOX(data->import.page),GTK_WIDGET(data->import.jobname->widget),FALSE,FALSE,0);


  // Create the treview with list model data store
  data->import.treeview=gtk_scrolled_window_new(NULL,NULL);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(data->import.treeview),GTK_POLICY_NEVER,GTK_POLICY_ALWAYS);

  gtk_container_add(GTK_CONTAINER(data->import.treeview), gtk_tree_view_new());
  GtkTreeView *treeview=GTK_TREE_VIEW(gtk_bin_get_child(GTK_BIN(data->import.treeview)));

  GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new( );
  GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes( _("thumbnail") , renderer,"pixbuf",0, (char *)NULL);
  gtk_tree_view_append_column( treeview , column);

  renderer = gtk_cell_renderer_text_new( );
  column = gtk_tree_view_column_new_with_attributes( _("storage file"), renderer, "text", 1, (char *)NULL);
  gtk_tree_view_append_column( treeview , column);
  gtk_tree_view_column_set_expand( column, TRUE);


  GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
  gtk_tree_selection_set_mode(selection,GTK_SELECTION_MULTIPLE);

  gtk_tree_view_set_model(treeview,GTK_TREE_MODEL(data->store));
  gtk_tree_view_set_headers_visible(treeview,FALSE);

  gtk_box_pack_start(GTK_BOX(data->import.page),data->import.treeview,TRUE,TRUE,0);


  // SETTINGS PAGE
  data->settings.page=gtk_vbox_new(FALSE,5);
  gtk_container_set_border_width(GTK_CONTAINER(data->settings.page),5);

  // general settings
  gtk_box_pack_start(GTK_BOX(data->settings.page),dtgtk_label_new(_("general"),DARKTABLE_LABEL_TAB|DARKTABLE_LABEL_ALIGN_RIGHT),FALSE,FALSE,0);

  // ignoring of jpegs. hack while we don't handle raw+jpeg in the same directories.
  data->settings.general.ignore_jpeg = gtk_check_button_new_with_label (_("ignore JPEG files"));
  g_object_set(data->settings.general.ignore_jpeg, "tooltip-text", _("do not load files with an extension of .jpg or .jpeg. this can be useful when there are raw+JPEG in a directory."), NULL);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->settings.general.ignore_jpeg), dt_conf_get_bool("ui_last/import_ignore_jpegs"));
  gtk_box_pack_start(GTK_BOX(data->settings.page), data->settings.general.ignore_jpeg, FALSE, FALSE, 0);
  g_signal_connect (G_OBJECT(data->settings.general.ignore_jpeg), "clicked",G_CALLBACK (_check_button_callback),data);

  GtkWidget *hbox=gtk_hbox_new(FALSE,5);
  data->settings.general.date_override=gtk_check_button_new_with_label(_("override today's date"));
  gtk_box_pack_start(GTK_BOX(hbox),data->settings.general.date_override,FALSE,FALSE,0);
  g_object_set(data->settings.general.date_override,"tooltip-text",_("check this, if you want to override the timestamp used when expanding variables:\n$(YEAR), $(MONTH), $(DAY),\n$(HOUR), $(MINUTE), $(SECONDS)"),(char *)NULL);

  data->settings.general.date_entry=gtk_entry_new();
  gtk_widget_set_sensitive( data->settings.general.date_entry, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->settings.general.date_override)));
  gtk_box_pack_start(GTK_BOX(hbox),data->settings.general.date_entry,TRUE,TRUE,0);

  g_signal_connect (G_OBJECT (data->settings.general.date_override), "clicked",G_CALLBACK (_check_button_callback),data);

  gtk_box_pack_start(GTK_BOX(data->settings.page),hbox,FALSE,FALSE,0);


  // THE NOTEBOOK
  data->notebook=gtk_notebook_new();
  gtk_notebook_append_page(GTK_NOTEBOOK(data->notebook),data->import.page,gtk_label_new(_("images")));
  gtk_notebook_append_page(GTK_NOTEBOOK(data->notebook),data->settings.page,gtk_label_new(_("settings")));

  // end
  gtk_box_pack_start(GTK_BOX(content),data->notebook,TRUE,TRUE,0);
  //gtk_widget_set_size_request(content, DT_PIXEL_APPLY_DPI(400), DT_PIXEL_APPLY_DPI(400));
}
コード例 #13
0
ファイル: podzapusl.c プロジェクト: zaharchuktv/linuxbuh
int   podzapusl(short dd,short md,short gd, //Дата документа
int tipz,  //1-приход 2-расход
int podr,  //Склад
const char *nomdok, //Номер документа
int kodzap,
int metka_zap,
int nom_zap,
GtkWidget *wpredok)
{
class podzapusl_data data;

char strsql[512];
SQL_str row;
SQLCURSOR cur;

data.dd=dd;
data.md=md;
data.gd=gd;
data.tipz=tipz;
data.podr=podr;
data.nomdok.plus(nomdok);
data.kodzap=kodzap;
data.metka_zap=metka_zap;
data.nom_zap=nom_zap;

//Читаем нужные реквизиты
sprintf(strsql,"select kolih,cena,ei,shetu from Usldokum1 where \
datd='%04d-%02d-%02d' and podr=%d and tp=%d and nomd='%s' and \
metka=%d and kodzap=%d and nz=%d",
gd,md,dd,podr,tipz,nomdok,metka_zap,kodzap,nom_zap);

if(iceb_sql_readkey(strsql,&row,&cur,wpredok) != 1)
 {
  iceb_menu_soob(gettext("Не найдена запись !"),wpredok);
  return(1);
 }

data.kolih_dok=atof(row[0]);
data.cena=atof(row[1]);
data.ei.new_plus(row[2]);
data.shetu.new_plus(row[3]);

data.kolih_pod=readkoluw(dd,md,gd,podr,nomdok,tipz,metka_zap,kodzap,nom_zap,wpredok);

if(fabs(data.kolih_dok- data.kolih_pod) < 0.00001)
 {
  iceb_menu_soob(gettext("Запись уже подтверждена !"),wpredok);
  return(1);
 }


data.kolih.plus(data.kolih_dok-data.kolih_pod);

if(data.kolih_pod == 0.)
 {
  sprintf(strsql,"%d.%d.%d",dd,md,gd);
  data.datap.plus(strsql);
 }
else
  data.datap.plus("");
 
data.window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_position( GTK_WINDOW(data.window),ICEB_POS_CENTER);
gtk_window_set_modal(GTK_WINDOW(data.window),TRUE);

sprintf(strsql,"%s %s",name_system,gettext("Подтверждение записи"));
gtk_window_set_title (GTK_WINDOW (data.window),strsql);
gtk_container_set_border_width (GTK_CONTAINER (data.window), 5);

gtk_signal_connect(GTK_OBJECT(data.window),"delete_event",GTK_SIGNAL_FUNC(gtk_widget_destroy),NULL);
gtk_signal_connect(GTK_OBJECT(data.window),"destroy",GTK_SIGNAL_FUNC(gtk_main_quit),NULL);

gtk_signal_connect_after(GTK_OBJECT(data.window),"key_press_event",GTK_SIGNAL_FUNC(podzapusl_v_key_press),&data);

if(wpredok != NULL)
 {
  gdk_window_set_cursor(wpredok->window,gdk_cursor_new(ICEB_CURSOR_GDITE));
  //Удерживать окно над породившем его окном всегда
  gtk_window_set_transient_for(GTK_WINDOW(data.window),GTK_WINDOW(wpredok));
  //Закрыть окно если окно предок удалено
  gtk_window_set_destroy_with_parent(GTK_WINDOW(data.window),TRUE);
 }


GtkWidget *label=gtk_label_new(gettext("Подтверждение записи"));

GtkWidget *vbox = gtk_vbox_new (FALSE, 0);
GtkWidget *hbox[KOLENTER];
for(int i=0; i < KOLENTER; i++)
  hbox[i] = gtk_hbox_new (FALSE, 0);

GtkWidget *hboxradio = gtk_hbox_new (FALSE, 0);
GtkWidget *hboxknop = gtk_hbox_new (FALSE, 0);


gtk_container_add (GTK_CONTAINER (data.window), vbox);
gtk_container_add (GTK_CONTAINER (vbox), label);

for(int i=0; i < KOLENTER; i++)
  gtk_container_add (GTK_CONTAINER (vbox), hbox[i]);

gtk_container_add (GTK_CONTAINER (vbox), hboxradio);
gtk_container_add (GTK_CONTAINER (vbox), hboxknop);

sprintf(strsql,"%s",gettext("Дата подтверждения"));
label=gtk_label_new(iceb_u_toutf(strsql));
data.entry[E_DATAP] = gtk_entry_new_with_max_length (10);
gtk_box_pack_start (GTK_BOX (hbox[E_DATAP]), label, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox[E_DATAP]), data.entry[E_DATAP], TRUE, TRUE, 0);
gtk_signal_connect(GTK_OBJECT (data.entry[E_DATAP]), "activate",GTK_SIGNAL_FUNC(podzapusl_v_vvod),&data);
gtk_entry_set_text(GTK_ENTRY(data.entry[E_DATAP]),data.datap.ravno());
gtk_object_set_user_data(GTK_OBJECT(data.entry[E_DATAP]),(gpointer)E_DATAP);

label=gtk_label_new(gettext("Количество"));
data.entry[E_KOLIH] = gtk_entry_new_with_max_length (20);
gtk_box_pack_start (GTK_BOX (hbox[E_KOLIH]), label, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox[E_KOLIH]), data.entry[E_KOLIH], TRUE, TRUE, 0);
gtk_signal_connect(GTK_OBJECT (data.entry[E_KOLIH]), "activate",GTK_SIGNAL_FUNC(podzapusl_v_vvod),&data);
gtk_entry_set_text(GTK_ENTRY(data.entry[E_KOLIH]),data.kolih.ravno());
gtk_object_set_user_data(GTK_OBJECT(data.entry[E_KOLIH]),(gpointer)E_KOLIH);


GtkTooltips *tooltips[KOL_F_KL];

sprintf(strsql,"F2 %s",gettext("Запись"));
data.knopka[FK2]=gtk_button_new_with_label(strsql);
tooltips[FK2]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[FK2],data.knopka[FK2],gettext("Запись введенной в меню информации"),NULL);
gtk_signal_connect(GTK_OBJECT(data.knopka[FK2]),"clicked",GTK_SIGNAL_FUNC(podzapusl_v_knopka),&data);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK2]),(gpointer)FK2);
gtk_box_pack_start(GTK_BOX(hboxknop), data.knopka[FK2], TRUE, TRUE, 0);

sprintf(strsql,"F4 %s",gettext("Очистить"));
data.knopka[FK4]=gtk_button_new_with_label(strsql);
tooltips[FK4]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[FK4],data.knopka[FK4],gettext("Очистить меню от введенной информации"),NULL);
gtk_signal_connect(GTK_OBJECT(data.knopka[FK4]),"clicked",GTK_SIGNAL_FUNC(podzapusl_v_knopka),&data);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK4]),(gpointer)FK4);
gtk_box_pack_start(GTK_BOX(hboxknop), data.knopka[FK4], TRUE, TRUE, 0);


sprintf(strsql,"F10 %s",gettext("Выход"));
data.knopka[FK10]=gtk_button_new_with_label(strsql);
tooltips[FK10]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[FK10],data.knopka[FK10],gettext("Завершение работы в этом окне"),NULL);
gtk_signal_connect(GTK_OBJECT(data.knopka[FK10]),"clicked",GTK_SIGNAL_FUNC(podzapusl_v_knopka),&data);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK10]),(gpointer)FK10);
gtk_box_pack_start(GTK_BOX(hboxknop), data.knopka[FK10], TRUE, TRUE, 0);

gtk_widget_grab_focus(data.entry[0]);

gtk_widget_show_all (data.window);


gtk_main();

if(wpredok != NULL)
  gdk_window_set_cursor(wpredok->window,gdk_cursor_new(ICEB_CURSOR));

return(data.voz);

}
コード例 #14
0
ファイル: typer.c プロジェクト: LibreCrops/CopyBao
GtkWidget *create_input_window()
{
    GtkWidget *window;
    GtkWidget *vbox;
    GtkWidget *hbox1, *hbox2, *hbox3;
    GtkWidget *label, *label2;
    GtkWidget *scrollwin;
    GtkWidget *text_view;
    GtkWidget *button, *button2;
    GtkWidget *progress_bar;

    /* window */
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(window), "Typer");
    gtk_window_set_default_size(GTK_WINDOW(window), 800, 400);
    // gtk_window_set_deletable(GTK_WINDOW(window), FALSE);
    gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG);
    gtk_container_border_width(GTK_CONTAINER(window), 10);
    g_signal_connect(
        GTK_OBJECT(window), "delete_event",
        GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete), NULL);

    vbox = gtk_vbox_new(FALSE, 10);

    hbox1 = gtk_hbox_new(FALSE, 10);
    label = gtk_label_new("Text:");
    gtk_box_pack_start(GTK_BOX(hbox1), label, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), hbox1,
                       FALSE, FALSE, 0);

    /* center text view */
    text_view = gtk_text_view_new();
    gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text_view), GTK_WRAP_CHAR);
    input_text_buffer_origin =
        gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view));
    g_object_ref(input_text_buffer_origin);
    scrollwin = gtk_scrolled_window_new(
      NULL,
      gtk_text_view_get_vadjustment(GTK_TEXT_VIEW(text_view)));
    gtk_scrolled_window_set_policy(
        GTK_SCROLLED_WINDOW(scrollwin),
        GTK_POLICY_NEVER,
        GTK_POLICY_ALWAYS);
    gtk_scrolled_window_set_shadow_type(
        GTK_SCROLLED_WINDOW(scrollwin),
        GTK_SHADOW_IN);
    gtk_container_add(GTK_CONTAINER(scrollwin), text_view);
    gtk_box_pack_start(GTK_BOX(vbox), scrollwin,
                       TRUE, TRUE, 0);

    /* progress bar */
    label2 = gtk_label_new("Progress: ");
    progress_bar = gtk_progress_bar_new();
    hbox3 = gtk_hbox_new(FALSE, 10);
    gtk_box_pack_start(GTK_BOX(hbox3), label2, FALSE, FALSE, 0);
    gtk_box_pack_start(
        GTK_BOX(hbox3), progress_bar,
        FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), hbox3, FALSE, FALSE, 0);

    /* period setting */
    GtkWidget *hbox5 = gtk_hbox_new(FALSE, 10);
    gtk_box_pack_start(
        GTK_BOX(hbox5), gtk_label_new("Period: "),
	FALSE, FALSE, 0);
    btn_prev_period = gtk_button_new_with_label("<<");
    g_signal_connect(
        GTK_OBJECT(btn_prev_period), "clicked",
	GTK_SIGNAL_FUNC(prev_period), NULL);
    gtk_box_pack_start(GTK_BOX(hbox5), btn_prev_period, FALSE, FALSE, 0);
    lbl_period = gtk_label_new(NULL);
    load_current_period();
    gtk_box_pack_start(GTK_BOX(hbox5), lbl_period, FALSE, FALSE, 0);
    btn_next_period = gtk_button_new_with_label(">>");
    g_signal_connect(
        GTK_OBJECT(btn_next_period), "clicked",
	GTK_SIGNAL_FUNC(next_period), NULL);
    gtk_box_pack_start(GTK_BOX(hbox5), btn_next_period, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), hbox5, FALSE, FALSE, 0);

    /* buttons on the BOTTOM */
    hbox2 = gtk_hbox_new(FALSE, 10);
    button = gtk_button_new_with_label("Send");
    gtk_widget_set_size_request(button, 100, 40);
    g_signal_connect(
        GTK_OBJECT(button), "clicked",
        GTK_SIGNAL_FUNC(send_button_clicked), NULL);
    gtk_box_pack_end(GTK_BOX(hbox2), button, FALSE, FALSE, 0);
    button2 = gtk_button_new_with_label("STOP!");
    gtk_widget_set_size_request(button2, 100, 40);
    g_signal_connect(
        GTK_OBJECT(button2), "clicked",
        GTK_SIGNAL_FUNC(stop_button_clicked), NULL);
    gtk_box_pack_end(GTK_BOX(hbox2), button2, FALSE, FALSE, 0);

    gtk_box_pack_start(GTK_BOX(vbox), hbox2, FALSE, FALSE, 0);

    gtk_container_add(GTK_CONTAINER(window), vbox);

    input_send_button = button;
    input_stop_button = button2;
    input_text_view = text_view;
    input_progress_bar = progress_bar;

    gtk_widget_show_all(window);
    gtk_widget_hide(button2);

    return window;
}
コード例 #15
0
ファイル: sc_linux_gtk.c プロジェクト: atoun/xoscope
void
esd_gtk_option_dialog()
{
  GtkWidget *window, *label, *accept, *cancel;
  GtkWidget *on, *off;
  char *option;

  window = gtk_dialog_new();
  accept = gtk_button_new_with_label(" Accept ");
  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->action_area), accept,
		     TRUE, TRUE, 0);
  cancel = gtk_button_new_with_label("  Cancel  ");
  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->action_area), cancel,
		     TRUE, TRUE, 0);

  label = gtk_label_new("  ESD Record Mode:  ");
  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), label,
		     TRUE, TRUE, 5);

  on = gtk_radio_button_new_with_label(NULL, "On");
  off = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(on)), "Off");

  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), on,
		     TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), off,
		     TRUE, TRUE, 0);

  option = datasrc->save_option(1);	/* format will be "esdrecord=%d" */
  if (option) temp_rec = option[10] - '0';

  gtk_toggle_button_set_active
    (GTK_TOGGLE_BUTTON(on), temp_rec == 1);
  gtk_toggle_button_set_active
    (GTK_TOGGLE_BUTTON(off), temp_rec == 0);

  gtk_signal_connect(GTK_OBJECT(on), "clicked",
		     GTK_SIGNAL_FUNC(esdrecord), (gpointer) 1);
  gtk_signal_connect(GTK_OBJECT(off), "clicked",
		     GTK_SIGNAL_FUNC(esdrecord), (gpointer) 0);

  gtk_signal_connect_object(GTK_OBJECT(window), "delete_event",
			    GTK_SIGNAL_FUNC(gtk_widget_destroy),
			    GTK_OBJECT(window));
  gtk_signal_connect(GTK_OBJECT(accept), "clicked",
		     GTK_SIGNAL_FUNC(esd_save_values), NULL);
  gtk_signal_connect_object_after(GTK_OBJECT(accept), "clicked",
				  GTK_SIGNAL_FUNC(gtk_widget_destroy),
				  GTK_OBJECT(window));
  gtk_signal_connect_object(GTK_OBJECT(cancel), "clicked",
			    GTK_SIGNAL_FUNC(gtk_widget_destroy),
			    GTK_OBJECT(window));

  GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT);
  GTK_WIDGET_SET_FLAGS(accept, GTK_CAN_DEFAULT);
  gtk_widget_grab_default(accept);

  gtk_widget_show(on);
  gtk_widget_show(off);
  gtk_widget_show(accept);
  gtk_widget_show(cancel);
  gtk_widget_show(label);
  gtk_widget_show(window);
}
コード例 #16
0
ファイル: dialog-search.c プロジェクト: Ghnuberath/gnumeric
void
dialog_search (WBCGtk *wbcg)
{
	GtkBuilder *gui;
	GtkDialog *dialog;
	DialogState *dd;
	GtkTable *table;
	char *f;

	g_return_if_fail (wbcg != NULL);

#ifdef USE_GURU
	/* Only one guru per workbook. */
	if (wbc_gtk_get_guru (wbcg))
		return;
#endif

	f = g_build_filename (gnm_sys_data_dir (), "ui", "search.ui", NULL);
	gui = go_gtk_builder_new (f, NULL, GO_CMD_CONTEXT (wbcg));
	g_free (f);
        if (gui == NULL)
                return;

	dialog = GTK_DIALOG (gtk_builder_get_object (gui, "search_dialog"));

	dd = g_new (DialogState, 1);
	dd->wbcg = wbcg;
	dd->gui = gui;
	dd->dialog = dialog;
	dd->matches = g_ptr_array_new ();

	dd->prev_button = go_gtk_builder_get_widget (gui, "prev_button");
	dd->next_button = go_gtk_builder_get_widget (gui, "next_button");

	dd->notebook = GTK_NOTEBOOK (gtk_builder_get_object (gui, "notebook"));
	dd->notebook_matches_page =
		gtk_notebook_page_num (dd->notebook,
				       go_gtk_builder_get_widget (gui, "matches_tab"));

	dd->rangetext = gnm_expr_entry_new (wbcg, TRUE);
	gnm_expr_entry_set_flags (dd->rangetext, 0, GNM_EE_MASK);
	table = GTK_TABLE (gtk_builder_get_object (gui, "page1-table"));
	gtk_table_attach (table, GTK_WIDGET (dd->rangetext),
			  1, 2, 6, 7,
			  GTK_EXPAND | GTK_FILL, 0,
			  0, 0);
	{
		char *selection_text =
			selection_to_string (
				wb_control_cur_sheet_view (WORKBOOK_CONTROL (wbcg)),
				TRUE);
		gnm_expr_entry_load_from_text  (dd->rangetext, selection_text);
		g_free (selection_text);
	}

	dd->gentry = GTK_ENTRY (gtk_entry_new ());
	gtk_table_attach (table, GTK_WIDGET (dd->gentry),
			  1, 2, 0, 1,
			  GTK_EXPAND | GTK_FILL, 0,
			  0, 0);
	gtk_widget_grab_focus (GTK_WIDGET (dd->gentry));
	gnumeric_editable_enters (GTK_WINDOW (dialog), GTK_WIDGET (dd->gentry));

	dd->matches_table = make_matches_table (dd);

	{
		GtkWidget *scrolled_window =
			gtk_scrolled_window_new (NULL, NULL);
		gtk_container_add (GTK_CONTAINER (scrolled_window),
				   GTK_WIDGET (dd->matches_table));
		gtk_box_pack_start (GTK_BOX (gtk_builder_get_object (gui, "matches_vbox")),
				    scrolled_window,
				    TRUE, TRUE, 0);
		gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
						GTK_POLICY_NEVER,
						GTK_POLICY_ALWAYS);
	}

	/* Set sensitivity of buttons.  */
	cursor_change (dd->matches_table, dd);

	g_signal_connect (G_OBJECT (dd->matches_table), "cursor_changed",
		G_CALLBACK (cursor_change), dd);
	g_signal_connect (G_OBJECT (dd->matches_table), "select_cursor_row",
		G_CALLBACK (cb_next), dd);
	go_gtk_builder_signal_connect (gui, "search_button", "clicked",
		G_CALLBACK (search_clicked), dd);
	g_signal_connect (G_OBJECT (dd->prev_button), "clicked",
		G_CALLBACK (prev_clicked), dd);
	g_signal_connect (G_OBJECT (dd->next_button), "clicked",
		G_CALLBACK (next_clicked), dd);
	go_gtk_builder_signal_connect_swapped (gui, "close_button", "clicked",
		G_CALLBACK (gtk_widget_destroy), dd->dialog);
	g_signal_connect (G_OBJECT (gnm_expr_entry_get_entry (dd->rangetext)), "focus-in-event",
		G_CALLBACK (range_focused), dd);
	go_gtk_builder_signal_connect (gui, "scope_range", "toggled",
		G_CALLBACK (cb_focus_on_entry), dd->rangetext);

#ifdef USE_GURU
	wbc_gtk_attach_guru_with_unfocused_rs (wbcg, GTK_WIDGET (dialog), dd->rangetext);
#endif
	g_object_set_data_full (G_OBJECT (dialog),
		"state", dd, (GDestroyNotify) free_state);
	gnm_dialog_setup_destroy_handlers (dialog, wbcg,
		GNM_DIALOG_DESTROY_SHEET_REMOVED);
	gnumeric_init_help_button (
		go_gtk_builder_get_widget (gui, "help_button"),
		GNUMERIC_HELP_LINK_SEARCH);
	gnumeric_restore_window_geometry (GTK_WINDOW (dialog), SEARCH_KEY);

	go_gtk_nonmodal_dialog (wbcg_toplevel (wbcg), GTK_WINDOW (dialog));
	gtk_widget_show_all (GTK_WIDGET (dialog));
}
コード例 #17
0
ファイル: EnterNameDlg.c プロジェクト: steelwil/StackPack
/*----------------------------------------------------------------------------*/
void EnterNameDialogCreate(GtkWidget *parent)
{
	if (window != NULL)
	{
		printf("window already created\n");
		
		gtk_entry_set_text(GTK_ENTRY(name_entry), "");
		gtk_entry_set_text(GTK_ENTRY(quote_entry), "");
		gtk_widget_show (window);
		return;
	}
	GtkWidget *label;
	GtkWidget *button;
	GtkWidget *box1;
	GtkWidget *box2;
	
	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title (GTK_WINDOW (window), "Enter Name Dialog");
	gtk_window_set_modal(GTK_WINDOW (window), TRUE);
	gtk_window_set_transient_for(GTK_WINDOW (window), GTK_WINDOW (parent));
	gtk_window_set_type_hint(GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_DIALOG);
	gtk_container_set_border_width (GTK_CONTAINER (window), 6);
	box1 = gtk_vbox_new (FALSE, 12);
	box2 = gtk_hbox_new (FALSE, 12);
	gtk_container_add (GTK_CONTAINER (window), box1);

	label = gtk_label_new("Congradulations you made the StackPack\n"
						  "Hall of fame!");
	gtk_label_set_justify (GTK_LABEL(label), GTK_JUSTIFY_CENTER);
	gtk_box_pack_start (GTK_BOX(box1), label, TRUE, TRUE, 6);
	gtk_widget_show (label);

	label = gtk_label_new("Enter in your name:");
	gtk_box_pack_start (GTK_BOX(box1), label, FALSE, FALSE, 6);
	gtk_widget_show (label);
	
	name_entry = gtk_entry_new ();
	gtk_entry_set_max_length (GTK_ENTRY(name_entry), 31);
	gtk_box_pack_start (GTK_BOX(box1), name_entry, FALSE, FALSE, 6);
	gtk_widget_show (name_entry);
	
	label = gtk_label_new("Enter in your cool quote:");
	gtk_box_pack_start (GTK_BOX(box1), label, FALSE, FALSE, 6);
	gtk_widget_show (label);
	
	quote_entry = gtk_entry_new ();
	gtk_entry_set_max_length (GTK_ENTRY(quote_entry), 31);
	gtk_box_pack_start (GTK_BOX(box1), quote_entry, FALSE, FALSE, 6);
	gtk_widget_show (quote_entry);
	
	button = gtk_button_new_from_stock (GTK_STOCK_OK);
	gtk_box_pack_end (GTK_BOX (box2), button, FALSE, FALSE, 0);
	g_signal_connect (G_OBJECT (button), "clicked",
		  G_CALLBACK (close_dialog), window);
    g_signal_connect (G_OBJECT (window), "delete_event",
		      G_CALLBACK (delete_event), window);

	gtk_widget_show (button);

	gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);

	gtk_widget_show (box2);
	gtk_widget_show (box1);
	gtk_widget_show (window);
}
コード例 #18
0
ファイル: flickr.c プロジェクト: jwagner/darktable
void
gui_init (dt_imageio_module_storage_t *self)
{
  self->gui_data = (dt_storage_flickr_gui_data_t *)g_malloc0(sizeof(dt_storage_flickr_gui_data_t));
  dt_storage_flickr_gui_data_t *ui= self->gui_data;
  self->widget = gtk_vbox_new(FALSE, 0);

  GtkWidget *hbox1=gtk_hbox_new(FALSE,5);
  GtkWidget *hbox0=gtk_hbox_new(FALSE,5);
  GtkWidget *vbox1=gtk_vbox_new(FALSE,0);
  GtkWidget *vbox2=gtk_vbox_new(FALSE,5);

  ui->label1 = GTK_LABEL(  gtk_label_new( _("flickr user") ) );
  ui->label3 = GTK_LABEL(  gtk_label_new( _("photosets") ) );
  ui->labelPerms = GTK_LABEL(  gtk_label_new( _("visible to") ) );
  ui->label4 = GTK_LABEL(  gtk_label_new( NULL ) );

  set_status(ui,_("click login button to start"), "#ffffff");

  ui->label5 = GTK_LABEL(  gtk_label_new( _("title") ) );
  ui->label6 = GTK_LABEL(  gtk_label_new( _("summary") ) );
  gtk_misc_set_alignment(GTK_MISC(ui->label1),      0.0, 0.5);
  gtk_misc_set_alignment(GTK_MISC(ui->labelPerms),  0.0, 0.9);
  gtk_misc_set_alignment(GTK_MISC(ui->label3),      0.0, 0.7);
  gtk_misc_set_alignment(GTK_MISC(ui->label5),      0.0, 0.5);
  gtk_misc_set_alignment(GTK_MISC(ui->label6),      0.0, 0.5);

  ui->entry1 = GTK_ENTRY( gtk_entry_new() );
  ui->entry3 = GTK_ENTRY( gtk_entry_new() );  // Album title
  ui->entry4 = GTK_ENTRY( gtk_entry_new() );  // Album summary

  dt_gui_key_accel_block_on_focus_connect (GTK_WIDGET (ui->entry1));
  dt_gui_key_accel_block_on_focus_connect (GTK_WIDGET (ui->entry3));
  dt_gui_key_accel_block_on_focus_connect (GTK_WIDGET (ui->entry4));

  /*
    gtk_widget_add_events(GTK_WIDGET(ui->entry1), GDK_FOCUS_CHANGE_MASK);
    g_signal_connect (G_OBJECT (ui->entry1), "focus-in-event",  G_CALLBACK(focus_in),  NULL);
    g_signal_connect (G_OBJECT (ui->entry1), "focus-out-event", G_CALLBACK(focus_out), NULL);

    gtk_widget_add_events(GTK_WIDGET(ui->entry2), GDK_FOCUS_CHANGE_MASK);
    g_signal_connect (G_OBJECT (ui->entry2), "focus-in-event",  G_CALLBACK(focus_in),  NULL);
    g_signal_connect (G_OBJECT (ui->entry2), "focus-out-event", G_CALLBACK(focus_out), NULL);
    gtk_widget_add_events(GTK_WIDGET(ui->entry3), GDK_FOCUS_CHANGE_MASK);
    g_signal_connect (G_OBJECT (ui->entry3), "focus-in-event",  G_CALLBACK(focus_in),  NULL);
    g_signal_connect (G_OBJECT (ui->entry3), "focus-out-event", G_CALLBACK(focus_out), NULL);
    gtk_widget_add_events(GTK_WIDGET(ui->entry4), GDK_FOCUS_CHANGE_MASK);
    g_signal_connect (G_OBJECT (ui->entry4), "focus-in-event",  G_CALLBACK(focus_in),  NULL);
    g_signal_connect (G_OBJECT (ui->entry4), "focus-out-event", G_CALLBACK(focus_out), NULL);
  */
  GHashTable* table = dt_pwstorage_get("flickr");
  gchar* _username = g_strdup( g_hash_table_lookup(table, "username"));
  g_hash_table_destroy(table);
  gtk_entry_set_text( ui->entry1,  _username == NULL?"":_username );
  gtk_entry_set_text( ui->entry3, _("my new photoset") );
  gtk_entry_set_text( ui->entry4, _("exported from darktable") );

  GtkWidget *albumlist=gtk_hbox_new(FALSE,0);
  ui->comboBox1 = GTK_COMBO_BOX_TEXT(gtk_combo_box_text_new()); // Available albums

  dt_ellipsize_combo(GTK_COMBO_BOX(ui->comboBox1));

  ui->dtbutton1 = DTGTK_BUTTON( dtgtk_button_new(dtgtk_cairo_paint_refresh,0) );
  g_object_set(G_OBJECT(ui->dtbutton1), "tooltip-text", _("refresh album list"), (char *)NULL);

  ui->button = GTK_BUTTON(gtk_button_new_with_label(_("login")));
  g_object_set(G_OBJECT(ui->button), "tooltip-text", _("flickr login"), (char *)NULL);

  gtk_widget_set_sensitive( GTK_WIDGET(ui->comboBox1), FALSE);
  gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(ui->comboBox1), combobox_separator,ui->comboBox1,NULL);
  gtk_box_pack_start(GTK_BOX(albumlist), GTK_WIDGET(ui->comboBox1), TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(albumlist), GTK_WIDGET(ui->dtbutton1), FALSE, FALSE, 0);

  ui->checkButton2 = GTK_CHECK_BUTTON( gtk_check_button_new_with_label(_("export tags")) );
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON( ui->checkButton2 ),TRUE);

  ui->permsComboBox = GTK_COMBO_BOX_TEXT(gtk_combo_box_text_new());
  gtk_combo_box_text_append_text(ui->permsComboBox, _("you"));
  gtk_combo_box_text_append_text(ui->permsComboBox, _("friends"));
  gtk_combo_box_text_append_text(ui->permsComboBox, _("family"));
  gtk_combo_box_text_append_text(ui->permsComboBox, _("friends + family"));
  gtk_combo_box_text_append_text(ui->permsComboBox, _("everyone"));
  gtk_combo_box_set_active(GTK_COMBO_BOX(ui->permsComboBox), 0); // Set default permission to private

  gtk_box_pack_start(GTK_BOX(self->widget), hbox0, TRUE, FALSE, 5);
  gtk_box_pack_start(GTK_BOX(self->widget), hbox1, TRUE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX( hbox0 ), GTK_WIDGET( ui->label1 ), TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX( hbox0 ), GTK_WIDGET( ui->entry1 ), TRUE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX( hbox0 ), GTK_WIDGET( ui->button ), FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX( hbox1 ), vbox1, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX( hbox1 ), vbox2, TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX( vbox1 ), GTK_WIDGET( gtk_label_new("")), TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX( vbox1 ), GTK_WIDGET( ui->labelPerms ), TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX( vbox1 ), GTK_WIDGET( ui->label3 ), TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX( vbox2 ), GTK_WIDGET( ui->label4 ), TRUE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX( vbox2 ), GTK_WIDGET( ui->checkButton2 ), TRUE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX( vbox2 ), GTK_WIDGET( ui->permsComboBox ), TRUE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX( vbox2 ), GTK_WIDGET( albumlist ), TRUE, FALSE, 0);


  // Create Album
  ui->hbox1=GTK_BOX(gtk_hbox_new(FALSE,5));
  gtk_widget_set_no_show_all(GTK_WIDGET(ui->hbox1), TRUE);
  vbox1=gtk_vbox_new(FALSE,0);
  vbox2=gtk_vbox_new(FALSE,0);

  gtk_box_pack_start(GTK_BOX(ui->hbox1), vbox1, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(ui->hbox1), vbox2, TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(ui->hbox1), TRUE, FALSE, 5);
  gtk_box_pack_start(GTK_BOX( vbox1 ), GTK_WIDGET( ui->label5 ), TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX( vbox1 ), GTK_WIDGET( ui->label6 ), TRUE, TRUE, 0);

  gtk_box_pack_start(GTK_BOX( vbox2 ), GTK_WIDGET( ui->entry3 ), TRUE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX( vbox2 ), GTK_WIDGET( ui->entry4 ), TRUE, FALSE, 0);

  // Setup signals
  // add signal on realize and hide gtk_widget_hide(GTK_WIDGET(ui->hbox1));

  g_signal_connect(G_OBJECT(ui->dtbutton1), "clicked", G_CALLBACK(flickr_button1_clicked), (gpointer)ui);
  g_signal_connect(G_OBJECT(ui->button), "clicked", G_CALLBACK(flickr_button1_clicked), (gpointer)ui);
  g_signal_connect(G_OBJECT(ui->entry1), "changed", G_CALLBACK(flickr_entry_changed), (gpointer)ui);
  g_signal_connect(G_OBJECT(ui->comboBox1), "changed", G_CALLBACK(flickr_album_changed), (gpointer)ui);

  /**
  dont' populate the combo on startup, save 3 second

  // If username and password is stored, let's populate the combo
  if( _username && _password )
  {
    ui->user_token = _password;
    refresh_albums(ui);
  }
  */

  if( _username )
    g_free (_username);
  gtk_combo_box_set_active(GTK_COMBO_BOX(ui->comboBox1), 0);
}
コード例 #19
0
ファイル: find_dialog.c プロジェクト: elijahdorman/Xiphos
static void create_find_dialog(GtkWidget *htmlwidget)
{
	GtkWidget *dialog_vbox29;
	GtkWidget *vbox45;
	GtkWidget *label180;
	GtkWidget *hbox66;
	GtkWidget *dialog_action_area29;
	GtkWidget *hbuttonbox8;
#ifndef HAVE_GTK_310
	GtkWidget *alignment;
#endif
	GtkWidget *hbox5;
	GtkWidget *image;
	GtkWidget *label12;
	//gchar title[80];

	//sprintf(title, "%s - %s", settings.program_title, _("Find"));

	dialog = g_new(FIND_DIALOG, 1); /* must be freed */
	dialog->regular = FALSE;
	dialog->htmlwidget = htmlwidget;

	dialog->dialog = gtk_dialog_new();
	g_object_set_data(G_OBJECT(dialog->dialog),
			  "dialog->dialog", dialog->dialog);
	gtk_window_set_title(GTK_WINDOW(dialog->dialog), _("Find"));
	//GTK_WINDOW(dialog->dialog)->type = GTK_WINDOW_TOPLEVEL;
	/*gtk_window_set_policy(GTK_WINDOW(dialog->dialog), TRUE, TRUE,
	   FALSE); */
	gtk_container_set_border_width(GTK_CONTAINER(dialog->dialog), 6);
	gtk_window_set_resizable(GTK_WINDOW(dialog->dialog), FALSE);
#ifndef USE_GTK_3
	gtk_dialog_set_has_separator(GTK_DIALOG(dialog->dialog), FALSE);
#endif
	dialog_vbox29 =
	    gtk_dialog_get_content_area(GTK_DIALOG(dialog->dialog));
	g_object_set_data(G_OBJECT(dialog->dialog), "dialog_vbox29",
			  dialog_vbox29);
	gtk_widget_show(dialog_vbox29);

	UI_VBOX(vbox45, FALSE, 12);
	gtk_widget_show(vbox45);
	gtk_box_pack_start(GTK_BOX(dialog_vbox29), vbox45, TRUE, TRUE, 0);

	label180 = gtk_label_new(_("Enter Word or Phrase"));
	gtk_widget_show(label180);
	gtk_box_pack_start(GTK_BOX(vbox45), label180, FALSE, FALSE, 0);

	dialog->entry = gtk_entry_new();
	gtk_widget_show(dialog->entry);
	gtk_box_pack_start(GTK_BOX(vbox45), dialog->entry, FALSE, FALSE,
			   0);
	gtk_widget_set_size_request(dialog->entry, 291, -1);

	UI_HBOX(hbox66, FALSE, 0);
	gtk_widget_show(hbox66);
	gtk_box_pack_start(GTK_BOX(vbox45), hbox66, TRUE, TRUE, 0);

	dialog->backward =
	    gtk_check_button_new_with_label(_("Search backwards"));
	gtk_widget_show(dialog->backward);
	gtk_box_pack_start(GTK_BOX(hbox66), dialog->backward, FALSE,
			   FALSE, 0);
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->backward), FALSE);

	dialog_action_area29 =
#ifdef HAVE_GTK_312
	    gtk_dialog_get_content_area(GTK_DIALOG(dialog->dialog));
#else
	    gtk_dialog_get_action_area(GTK_DIALOG(dialog->dialog));
#endif
	g_object_set_data(G_OBJECT(dialog->dialog),
			  "dialog_action_area29", dialog_action_area29);
	gtk_widget_show(dialog_action_area29);
	gtk_container_set_border_width(GTK_CONTAINER(dialog_action_area29), 10);

#ifdef USE_GTK_3
	hbuttonbox8 = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
#else
	hbuttonbox8 = gtk_hbutton_box_new();
#endif
	gtk_widget_show(hbuttonbox8);
	gtk_box_pack_start(GTK_BOX(dialog_action_area29), hbuttonbox8,
			   TRUE, TRUE, 0);

	dialog->find =
#ifdef HAVE_GTK_310
	    gtk_button_new_from_icon_name("edit-find",
					  GTK_ICON_SIZE_BUTTON);
#else
	    gtk_button_new_from_stock(GTK_STOCK_FIND); //gtk_button_new_with_label(_("Find"));
#endif
	gtk_widget_show(dialog->find);
	gtk_container_add(GTK_CONTAINER(hbuttonbox8), dialog->find);

	dialog->next = gtk_button_new();
	gtk_widget_show(dialog->next);
	gtk_container_add(GTK_CONTAINER(hbuttonbox8), dialog->next);
//GTK_WIDGET_SET_FLAGS(dialog->next, GTK_CAN_DEFAULT);

#ifndef HAVE_GTK_310
	alignment = gtk_alignment_new(0.5, 0.5, 0, 0);
	gtk_widget_show(alignment);
	gtk_container_add(GTK_CONTAINER(dialog->next), alignment);

#endif
	UI_HBOX(hbox5, FALSE, 2);
	gtk_widget_show(hbox5);
#ifndef HAVE_GTK_310
	gtk_container_add(GTK_CONTAINER(alignment), hbox5);
#endif

	image =
#ifdef HAVE_GTK_310
	    gtk_image_new_from_icon_name("edit-find",
					 GTK_ICON_SIZE_BUTTON);
#else
	    gtk_image_new_from_stock(GTK_STOCK_FIND, GTK_ICON_SIZE_BUTTON);
#endif
	gtk_widget_show(image);
	gtk_box_pack_start(GTK_BOX(hbox5), image, FALSE, FALSE, 0);

	label12 = gtk_label_new_with_mnemonic(_("Find Next"));
	gtk_widget_show(label12);
	gtk_box_pack_start(GTK_BOX(hbox5), label12, FALSE, FALSE, 0);
	gtk_label_set_justify(GTK_LABEL(label12), GTK_JUSTIFY_LEFT);

	dialog->close =
#ifdef HAVE_GTK_310
	    // Don't use an icon with GTK3
	    gtk_button_new_with_label(_("Close"));
#else
	    gtk_button_new_from_stock(GTK_STOCK_CLOSE);
#endif
	gtk_widget_show(dialog->close);
	gtk_container_add(GTK_CONTAINER(hbuttonbox8), dialog->close);
	//GTK_WIDGET_SET_FLAGS(dialog->close, GTK_CAN_DEFAULT);
	gtk_widget_set_can_default(dialog->find, 1);

	g_signal_connect(G_OBJECT(dialog->dialog), "destroy",
			 G_CALLBACK(dialog_destroy), dialog);
	g_signal_connect(G_OBJECT(dialog->find), "clicked",
			 G_CALLBACK(find_clicked), dialog);
	g_signal_connect(G_OBJECT(dialog->next), "clicked",
			 G_CALLBACK(next_clicked), dialog);
	g_signal_connect(G_OBJECT(dialog->close), "clicked",
			 G_CALLBACK(close_clicked), dialog);
}
コード例 #20
0
ファイル: buhrpzw_m.c プロジェクト: zaharchuktv/linuxbuh
int buhrpzw_m(class buhrpzw_rr *rek_r,
GtkWidget *wpredok)
{
class buhrpzw_m_data data;
char strsql[512];
data.rk=rek_r;

data.window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_position( GTK_WINDOW(data.window),ICEB_POS_CENTER);
gtk_window_set_modal(GTK_WINDOW(data.window),TRUE);
sprintf(strsql,"%s %s",name_system,gettext("Расчёт видов затрат по элементам"));

gtk_window_set_title(GTK_WINDOW(data.window),strsql);

gtk_signal_connect(GTK_OBJECT(data.window),"delete_event",GTK_SIGNAL_FUNC(gtk_widget_destroy),NULL);
gtk_signal_connect(GTK_OBJECT(data.window),"destroy",GTK_SIGNAL_FUNC(gtk_main_quit),NULL);
gtk_signal_connect_after(GTK_OBJECT(data.window),"key_press_event",GTK_SIGNAL_FUNC(buhrpzw_m_key_press),&data);

if(wpredok != NULL)
 {
  gdk_window_set_cursor(wpredok->window,gdk_cursor_new(ICEB_CURSOR_GDITE));
  //Удерживать окно над породившем его окном всегда
  gtk_window_set_transient_for(GTK_WINDOW(data.window),GTK_WINDOW(wpredok));
  //Закрыть окно если окно предок удалено
  gtk_window_set_destroy_with_parent(GTK_WINDOW(data.window),TRUE);
 }



GtkWidget *vbox = gtk_vbox_new (FALSE, 0);

GtkWidget *label=gtk_label_new (gettext("Расчёт видов затрат по элементам"));
gtk_box_pack_start (GTK_BOX (vbox),label,FALSE, FALSE, 0);


GtkWidget *hbox[KOLENTER];
for(int i=0; i < KOLENTER; i++)
 hbox[i] = gtk_hbox_new (FALSE, 0);
GtkWidget *hboxknop = gtk_hbox_new (FALSE, 0);

gtk_container_add (GTK_CONTAINER (data.window), vbox);
for(int i=0; i < KOLENTER; i++)
 gtk_container_add (GTK_CONTAINER (vbox), hbox[i]);
gtk_container_add (GTK_CONTAINER (vbox), hboxknop);



GtkTooltips *tooltips_enter[KOLENTER];

sprintf(strsql,"%s",gettext("Дата начала"));
data.knopka_enter[E_DATAN]=gtk_button_new_with_label(iceb_u_toutf(strsql));
gtk_box_pack_start (GTK_BOX (hbox[E_DATAN]), data.knopka_enter[E_DATAN], FALSE, FALSE, 0);
gtk_signal_connect(GTK_OBJECT(data.knopka_enter[E_DATAN]),"clicked",GTK_SIGNAL_FUNC(buhrpzw_m_e_knopka),&data);
gtk_object_set_user_data(GTK_OBJECT(data.knopka_enter[E_DATAN]),(gpointer)E_DATAN);
tooltips_enter[E_DATAN]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips_enter[E_DATAN],data.knopka_enter[E_DATAN],gettext("Выбор даты начала отчёта"),NULL);


data.entry[E_DATAN] = gtk_entry_new_with_max_length (10);
gtk_box_pack_start (GTK_BOX (hbox[E_DATAN]), data.entry[E_DATAN], TRUE, TRUE, 0);
gtk_signal_connect(GTK_OBJECT (data.entry[E_DATAN]), "activate",GTK_SIGNAL_FUNC(buhrpzw_m_vvod),&data);
gtk_entry_set_text(GTK_ENTRY(data.entry[E_DATAN]),data.rk->datan.ravno_toutf());
gtk_object_set_user_data(GTK_OBJECT(data.entry[E_DATAN]),(gpointer)E_DATAN);

sprintf(strsql,"%s",gettext("Дата конца"));
data.knopka_enter[E_DATAK]=gtk_button_new_with_label(iceb_u_toutf(strsql));
gtk_box_pack_start (GTK_BOX (hbox[E_DATAK]), data.knopka_enter[E_DATAK], FALSE, FALSE, 0);
gtk_signal_connect(GTK_OBJECT(data.knopka_enter[E_DATAK]),"clicked",GTK_SIGNAL_FUNC(buhrpzw_m_e_knopka),&data);
gtk_object_set_user_data(GTK_OBJECT(data.knopka_enter[E_DATAK]),(gpointer)E_DATAK);
tooltips_enter[E_DATAK]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips_enter[E_DATAK],data.knopka_enter[E_DATAK],gettext("Выбор даты конца отчёта"),NULL);

data.entry[E_DATAK] = gtk_entry_new_with_max_length (10);
gtk_box_pack_start (GTK_BOX (hbox[E_DATAK]), data.entry[E_DATAK], TRUE, TRUE, 0);
gtk_signal_connect(GTK_OBJECT (data.entry[E_DATAK]), "activate",GTK_SIGNAL_FUNC(buhrpzw_m_vvod),&data);
gtk_entry_set_text(GTK_ENTRY(data.entry[E_DATAK]),data.rk->datak.ravno_toutf());
gtk_object_set_user_data(GTK_OBJECT(data.entry[E_DATAK]),(gpointer)E_DATAK);


GtkTooltips *tooltips[KOL_FK];

sprintf(strsql,"F2 %s",gettext("Расчёт"));
data.knopka[FK2]=gtk_button_new_with_label(strsql);
tooltips[FK2]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[FK2],data.knopka[FK2],gettext("Начать расчёт"),NULL);
gtk_signal_connect(GTK_OBJECT(data.knopka[FK2]),"clicked",GTK_SIGNAL_FUNC(buhrpzw_m_knopka),&data);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK2]),(gpointer)FK2);
gtk_box_pack_start(GTK_BOX(hboxknop), data.knopka[FK2], TRUE, TRUE, 0);

sprintf(strsql,"F4 %s",gettext("Очистить"));
data.knopka[FK4]=gtk_button_new_with_label(strsql);
tooltips[FK4]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[FK4],data.knopka[FK4],gettext("Очистить меню от введённой информации"),NULL);
gtk_signal_connect(GTK_OBJECT(data.knopka[FK4]),"clicked",GTK_SIGNAL_FUNC(buhrpzw_m_knopka),&data);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK4]),(gpointer)FK4);
gtk_box_pack_start(GTK_BOX(hboxknop), data.knopka[FK4], TRUE, TRUE, 0);

sprintf(strsql,"F5 %s",gettext("Настройка"));
data.knopka[FK5]=gtk_button_new_with_label(strsql);
tooltips[FK5]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[FK5],data.knopka[FK5],gettext("Настройка расчёта"),NULL);
gtk_signal_connect(GTK_OBJECT(data.knopka[FK5]),"clicked",GTK_SIGNAL_FUNC(buhrpzw_m_knopka),&data);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK5]),(gpointer)FK5);
gtk_box_pack_start(GTK_BOX(hboxknop), data.knopka[FK5], TRUE, TRUE, 0);


sprintf(strsql,"F10 %s",gettext("Выход"));
data.knopka[FK10]=gtk_button_new_with_label(strsql);
tooltips[FK10]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[FK10],data.knopka[FK10],gettext("Поиск не выполнять"),NULL);
gtk_signal_connect(GTK_OBJECT(data.knopka[FK10]),"clicked",GTK_SIGNAL_FUNC(buhrpzw_m_knopka),&data);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK10]),(gpointer)FK10);
gtk_box_pack_start(GTK_BOX(hboxknop), data.knopka[FK10], TRUE, TRUE, 0);

gtk_widget_grab_focus(data.entry[0]);

gtk_widget_show_all (data.window);

gtk_main();

if(wpredok != NULL)
  gdk_window_set_cursor(wpredok->window,gdk_cursor_new(ICEB_CURSOR));

return(data.voz);

}
コード例 #21
0
void
dlg_import_from_flickr (FlickrServer *server,
		        GthBrowser   *browser)
{
	DialogData     *data;
	GthThumbLoader *thumb_loader;
	char           *title;

	data = g_new0 (DialogData, 1);
	data->server = server;
	data->browser = browser;
	data->location = gth_file_data_dup (gth_browser_get_location_data (browser));
	data->builder = _gtk_builder_new_from_file ("import-from-flickr.ui", "flicker_utils");
	data->dialog = _gtk_builder_get_widget (data->builder, "import_dialog");
	data->cancellable = g_cancellable_new ();

	{
		GtkCellLayout   *cell_layout;
		GtkCellRenderer *renderer;

		cell_layout = GTK_CELL_LAYOUT (GET_WIDGET ("photoset_combobox"));

		renderer = gtk_cell_renderer_pixbuf_new ();
		gtk_cell_layout_pack_start (cell_layout, renderer, FALSE);
		gtk_cell_layout_set_attributes (cell_layout, renderer,
						"icon-name", PHOTOSET_ICON_COLUMN,
						NULL);

		renderer = gtk_cell_renderer_text_new ();
		gtk_cell_layout_pack_start (cell_layout, renderer, TRUE);
		gtk_cell_layout_set_attributes (cell_layout, renderer,
						"text", PHOTOSET_TITLE_COLUMN,
						NULL);

		renderer = gtk_cell_renderer_text_new ();
		gtk_cell_layout_pack_start (cell_layout, renderer, FALSE);
		gtk_cell_layout_set_attributes (cell_layout, renderer,
						"text", PHOTOSET_N_PHOTOS_COLUMN,
						NULL);
	}

	/* Set the widget data */

	data->file_list = gth_file_list_new (gth_grid_view_new (), GTH_FILE_LIST_MODE_NORMAL, FALSE);
	thumb_loader = gth_file_list_get_thumb_loader (GTH_FILE_LIST (data->file_list));
	gth_thumb_loader_set_use_cache (thumb_loader, FALSE);
	gth_thumb_loader_set_loader_func (thumb_loader, flickr_thumbnail_loader);
	gth_file_list_set_thumb_size (GTH_FILE_LIST (data->file_list), FLICKR_SIZE_THUMBNAIL);
	gth_file_list_enable_thumbs (GTH_FILE_LIST (data->file_list), TRUE);
	gth_file_list_set_ignore_hidden (GTH_FILE_LIST (data->file_list), TRUE);
	gth_file_list_set_caption (GTH_FILE_LIST (data->file_list), "none");
	gth_file_list_set_sort_func (GTH_FILE_LIST (data->file_list), flickr_photo_position_func, FALSE);
	gth_file_list_clear (GTH_FILE_LIST (data->file_list), _("No album selected"));
	gtk_widget_show (data->file_list);
	gtk_box_pack_start (GTK_BOX (GET_WIDGET ("images_box")), data->file_list, TRUE, TRUE, 0);

	gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (GET_WIDGET ("photoset_liststore")), PHOTOSET_TITLE_COLUMN, GTK_SORT_ASCENDING);

	gtk_widget_set_sensitive (GET_WIDGET ("download_button"), FALSE);

	data->preferences_dialog = gth_import_preferences_dialog_new ();
	gtk_window_set_transient_for (GTK_WINDOW (data->preferences_dialog), GTK_WINDOW (data->dialog));

	gtk_box_pack_start (GTK_BOX (GET_WIDGET ("destination_button_box")),
			    gth_import_destination_button_new (GTH_IMPORT_PREFERENCES_DIALOG (data->preferences_dialog)),
			    TRUE,
			    TRUE,
			    0);
	gtk_widget_show_all (GET_WIDGET ("destination_button_box"));

	title = g_strdup_printf (_("Import from %s"), data->server->display_name);
	gtk_window_set_title (GTK_WINDOW (data->dialog), title);
	g_free (title);

	_gtk_window_resize_to_fit_screen_height (data->dialog, 500);

	/* Set the signals handlers. */

	g_signal_connect (data->dialog,
			  "destroy",
			  G_CALLBACK (import_dialog_destroy_cb),
			  data);
	g_signal_connect (data->dialog,
			  "delete-event",
			  G_CALLBACK (gtk_true),
			  NULL);
	g_signal_connect (data->dialog,
			  "response",
			  G_CALLBACK (import_dialog_response_cb),
			  data);
	g_signal_connect (GET_WIDGET ("edit_accounts_button"),
			  "clicked",
			  G_CALLBACK (edit_accounts_button_clicked_cb),
			  data);
	g_signal_connect (GET_WIDGET ("account_combobox"),
			  "changed",
			  G_CALLBACK (account_combobox_changed_cb),
			  data);
	g_signal_connect (GET_WIDGET ("photoset_combobox"),
			  "changed",
			  G_CALLBACK (photoset_combobox_changed_cb),
			  data);
	g_signal_connect (gth_file_list_get_view (GTH_FILE_LIST (data->file_list)),
			  "file-selection-changed",
			  G_CALLBACK (file_list_selection_changed_cb),
			  data);

	update_selection_status (data);
	gth_import_preferences_dialog_set_event (GTH_IMPORT_PREFERENCES_DIALOG (data->preferences_dialog), "");

	data->service = flickr_service_new (server,
					    data->cancellable,
					    GTK_WIDGET (data->browser),
					    data->dialog);
	g_signal_connect (data->service,
			  "account-ready",
			  G_CALLBACK (authentication_ready_cb),
			  data);
	g_signal_connect (data->service,
			  "accounts-changed",
			  G_CALLBACK (authentication_accounts_changed_cb),
			  data);

	data->progress_dialog = gth_progress_dialog_new (GTK_WINDOW (data->browser));
	gth_progress_dialog_add_task (GTH_PROGRESS_DIALOG (data->progress_dialog), GTH_TASK (data->service), GTH_TASK_FLAGS_DEFAULT);

	web_service_autoconnect (WEB_SERVICE (data->service));
}
コード例 #22
0
ファイル: nimf-candidate.c プロジェクト: cogniti/nimf
static gboolean
nimf_candidate_start (NimfService *service)
{
  g_debug (G_STRLOC ": %s", G_STRFUNC);

  NimfCandidate *candidate = NIMF_CANDIDATE (service);

  if (candidate->active)
    return TRUE;

  GtkCellRenderer   *renderer;
  GtkTreeViewColumn *column[N_COLUMNS];
  GtkListStore      *store;
  gint               fixed_height = 32;
  gint               horizontal_space;

  gtk_init (NULL, NULL);

  /* gtk entry */
  candidate->entry = gtk_entry_new ();
  gtk_editable_set_editable (GTK_EDITABLE (candidate->entry), FALSE);
  gtk_widget_set_no_show_all (candidate->entry, TRUE);
  g_signal_connect_after (candidate->entry, "draw",
                          G_CALLBACK (on_entry_draw), NULL);
  /* gtk tree view */
  store = gtk_list_store_new (N_COLUMNS, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING);
  candidate->treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
  g_object_unref (store);
  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (candidate->treeview), FALSE);
  gtk_widget_style_get (candidate->treeview, "horizontal-separator",
                        &horizontal_space, NULL);
  candidate->cell_height = fixed_height + horizontal_space / 2;
  gtk_widget_set_size_request (candidate->treeview,
                               (gint) (candidate->cell_height * 10 / 1.6),
                               candidate->cell_height * 10);
  g_signal_connect (candidate->treeview, "row-activated",
                    (GCallback) on_tree_view_row_activated, candidate);
  /* column */
  renderer = gtk_cell_renderer_text_new ();
  g_object_set (renderer, "height", fixed_height, "font", "Sans 14", NULL);

  column[INDEX_COLUMN] = gtk_tree_view_column_new_with_attributes ("Index",
                                        renderer, "text", INDEX_COLUMN, NULL);
  column[MAIN_COLUMN]  = gtk_tree_view_column_new_with_attributes ("Main",
                                        renderer, "text", MAIN_COLUMN, NULL);
  column[EXTRA_COLUMN] = gtk_tree_view_column_new_with_attributes ("Extra",
                                        renderer, "text", EXTRA_COLUMN, NULL);
  gtk_tree_view_column_set_sizing (column[INDEX_COLUMN], GTK_TREE_VIEW_COLUMN_AUTOSIZE);
  gtk_tree_view_column_set_sizing (column[MAIN_COLUMN],  GTK_TREE_VIEW_COLUMN_AUTOSIZE);
  gtk_tree_view_column_set_sizing (column[EXTRA_COLUMN], GTK_TREE_VIEW_COLUMN_AUTOSIZE);
  gtk_tree_view_append_column (GTK_TREE_VIEW (candidate->treeview),
                               column[INDEX_COLUMN]);
  gtk_tree_view_append_column (GTK_TREE_VIEW (candidate->treeview),
                               column[MAIN_COLUMN]);
  gtk_tree_view_append_column (GTK_TREE_VIEW (candidate->treeview),
                               column[EXTRA_COLUMN]);
  /* scrollbar */
  GtkAdjustment *adjustment = gtk_adjustment_new (1.0, 1.0, 2.0, 1.0, 1.0, 1.0);
  candidate->scrollbar = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, adjustment);
  gtk_range_set_slider_size_fixed (GTK_RANGE (candidate->scrollbar), FALSE);
  g_signal_connect (candidate->scrollbar, "change-value",
                    G_CALLBACK (on_range_change_value), candidate);
  GtkCssProvider  *provider;
  GtkStyleContext *style_context;
  provider = gtk_css_provider_new ();
  gtk_css_provider_load_from_data (GTK_CSS_PROVIDER (provider),
                       ".scrollbar {"
                       "  -GtkScrollbar-has-backward-stepper: true;"
                       "  -GtkScrollbar-has-forward-stepper:  true;"
                       "  -GtkScrollbar-has-secondary-forward-stepper:  true;"
                       "}" , -1, NULL);
  style_context = gtk_widget_get_style_context (candidate->scrollbar);
  gtk_style_context_add_provider (style_context,
                                  GTK_STYLE_PROVIDER (provider),
                                  GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
  g_object_unref (provider);

  /* gtk box */
  GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
  GtkWidget *hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);

  gtk_box_pack_start (GTK_BOX (vbox), candidate->entry, TRUE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);

  gtk_box_pack_start (GTK_BOX (hbox), candidate->treeview,  TRUE,  TRUE, 0);
  gtk_box_pack_end   (GTK_BOX (hbox), candidate->scrollbar, FALSE, TRUE, 0);

  /* gtk window */
  candidate->window = gtk_window_new (GTK_WINDOW_POPUP);
  gtk_window_set_type_hint (GTK_WINDOW (candidate->window),
                            GDK_WINDOW_TYPE_HINT_POPUP_MENU);
  gtk_container_set_border_width (GTK_CONTAINER (candidate->window), 1);
  gtk_container_add (GTK_CONTAINER (candidate->window), vbox);
  gtk_widget_realize (candidate->window);

  candidate->active = TRUE;

  return TRUE;
}
コード例 #23
0
ファイル: picture.c プロジェクト: mat-raynard/easytag
/*
 * Open the window to select and type the picture properties
 */
void Picture_Properties_Button_Clicked (GObject *object)
{
    GtkWidget *ScrollWindowPictureTypes, *PictureTypesWindow;
    GtkWidget *type, *label, *desc;
    GtkCellRenderer *renderer;
    GtkTreeViewColumn *column;
    GtkTreeSelection *selection;
    GtkListStore *store;
    GtkTreeIter type_iter_to_select, iter;
    GtkTreeModel *model;
    GtkWindow *parent_window = NULL;
    GList *selection_list = NULL;
    GList *l;
    gint selection_nbr, selection_i = 1;
    gint response;
    EtPictureType pic_type;

    g_return_if_fail (PictureEntryView != NULL);

    parent_window = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(object)));
    if (!gtk_widget_is_toplevel(GTK_WIDGET(parent_window)))
    {
        g_warning("Could not get parent window\n");
        return;
    }

    model          = gtk_tree_view_get_model(GTK_TREE_VIEW(PictureEntryView));
    selection      = gtk_tree_view_get_selection(GTK_TREE_VIEW(PictureEntryView));
    selection_list = gtk_tree_selection_get_selected_rows(selection, NULL);
    selection_nbr  = gtk_tree_selection_count_selected_rows(GTK_TREE_SELECTION(selection));

    for (l = selection_list; l != NULL; l = g_list_next (l))
    {
        GtkTreePath *path = l->data;
        Picture *pic = NULL;
        GtkTreeSelection *selectiontype;
        gchar *title;
        GtkTreePath *rowPath;
        gboolean valid;

        // Get corresponding picture
        valid = gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path);
        if (valid)
            gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, PICTURE_COLUMN_DATA, &pic, -1);

        title = g_strdup_printf (_("Image Properties %d/%d"), selection_i++,
                                 selection_nbr);
        PictureTypesWindow = gtk_dialog_new_with_buttons(title,
                                                         parent_window,
                                                         GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
                                                         GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
                                                         GTK_STOCK_OK,     GTK_RESPONSE_OK,
                                                         NULL);
        g_free(title);

        gtk_dialog_set_default_response(GTK_DIALOG(PictureTypesWindow), GTK_RESPONSE_OK);

        ScrollWindowPictureTypes = gtk_scrolled_window_new(NULL, NULL);
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(ScrollWindowPictureTypes),
                                       GTK_POLICY_AUTOMATIC,
                                       GTK_POLICY_AUTOMATIC);
        store = gtk_list_store_new(PICTURE_TYPE_COLUMN_COUNT, G_TYPE_STRING, G_TYPE_INT);
        type = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
        g_object_unref (store);
        gtk_container_add(GTK_CONTAINER(ScrollWindowPictureTypes), type);

        renderer = gtk_cell_renderer_text_new();
        column = gtk_tree_view_column_new();
        gtk_tree_view_column_pack_start(column, renderer, FALSE);
        gtk_tree_view_column_set_title (column, _("Image Type"));
        gtk_tree_view_column_set_attributes(column, renderer,
                                            "text", PICTURE_TYPE_COLUMN_TEXT,
                                            NULL);
        gtk_tree_view_append_column(GTK_TREE_VIEW(type), column);
        gtk_widget_set_size_request(type, 256, 256);
        gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(PictureTypesWindow))),ScrollWindowPictureTypes,TRUE,TRUE,0);

        // Behaviour following the tag type...
        switch (ETCore->ETFileDisplayed->ETFileDescription->TagType)
        {
            case MP4_TAG:
            {
                /* Load picture type (only Front Cover!). */
                GtkTreeIter itertype;

                gtk_list_store_insert_with_values (store, &itertype, G_MAXINT,
                                                   PICTURE_TYPE_COLUMN_TEXT,
                                                   _(Picture_Type_String (ET_PICTURE_TYPE_FRONT_COVER)),
                                                   PICTURE_TYPE_COLUMN_TYPE_CODE,
                                                   ET_PICTURE_TYPE_FRONT_COVER,
                                                   -1);
                /* Line to select by default. */
                type_iter_to_select = itertype;
                break;
            }

            // Other tag types
            default:
            {
                // Load pictures types
                for (pic_type = ET_PICTURE_TYPE_OTHER; pic_type < ET_PICTURE_TYPE_UNDEFINED; pic_type++)
                {
                    GtkTreeIter itertype;

                    gtk_list_store_insert_with_values (store, &itertype,
                                                       G_MAXINT,
                                                       PICTURE_TYPE_COLUMN_TEXT,
                                                       _(Picture_Type_String (pic_type)),
                                                       PICTURE_TYPE_COLUMN_TYPE_CODE,
                                                       pic_type, -1);
                    /* Line to select by default. */
                    if (pic->type == pic_type)
                        type_iter_to_select = itertype;
                }
                break;
            }
        }

        // Select the line by default
        selectiontype = gtk_tree_view_get_selection(GTK_TREE_VIEW(type));
        gtk_tree_selection_select_iter(selectiontype, &type_iter_to_select);

        // Set visible the current selected line
        rowPath = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &type_iter_to_select);
        gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(type), rowPath, NULL, FALSE, 0, 0);
        gtk_tree_path_free(rowPath);

        // Description of the picture
        label = gtk_label_new (_("Image Description:"));
        gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(PictureTypesWindow))),label,FALSE,FALSE,4);

        // Entry for the description
        desc = gtk_entry_new();
        gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(PictureTypesWindow))),desc,FALSE,FALSE,0);
        if (pic->description)
        {
            gchar *tmp = Try_To_Validate_Utf8_String(pic->description);
            gtk_entry_set_text(GTK_ENTRY(desc), tmp);
            g_free(tmp);
        }

        // Behaviour following the tag type...
        switch (ETCore->ETFileDisplayed->ETFileDescription->TagType)
        {
            case MP4_TAG:
            {
                gtk_widget_set_sensitive(GTK_WIDGET(label), FALSE);
                gtk_widget_set_sensitive(GTK_WIDGET(desc), FALSE);
                break;
            }

            // Other tag types
            default:
            {
                break;
            }
        }

        gtk_widget_show_all(PictureTypesWindow);

        response = gtk_dialog_run(GTK_DIALOG(PictureTypesWindow));
        if (response == GTK_RESPONSE_OK)
        {
            GtkTreeModel *modeltype;
            GtkTreeIter itertype;

            modeltype     = gtk_tree_view_get_model(GTK_TREE_VIEW(type));
            selectiontype = gtk_tree_view_get_selection(GTK_TREE_VIEW(type));
            if (gtk_tree_selection_get_selected(selectiontype, &modeltype, &itertype))
            {
                gchar *buffer, *pic_info;
                gint t;

                gtk_tree_model_get(modeltype, &itertype,
                                   PICTURE_TYPE_COLUMN_TYPE_CODE, &t, -1);
                pic->type = t;

                buffer = g_strdup(gtk_entry_get_text(GTK_ENTRY(desc)));
                Strip_String(buffer);
                if (pic->description)
                    g_free(pic->description);

                /* If the entry was empty, buffer will be the empty string "".
                 * This can be safely passed to the underlying
                 * FLAC__metadata_object_picture_set_description(). See
                 * https://bugs.launchpad.net/ubuntu/+source/easytag/+bug/558804
                 * and https://bugzilla.redhat.com/show_bug.cgi?id=559828 for
                 * downstream bugs when 0 was passed instead. */
                pic->description = buffer;

                // Update value in the PictureEntryView
                pic_info = Picture_Info(pic);
                gtk_list_store_set(GTK_LIST_STORE(model), &iter,
                                   PICTURE_COLUMN_TEXT, pic_info,
                                   -1);
                g_free(pic_info);
            }
        }
        gtk_widget_destroy(PictureTypesWindow);
    }

    g_list_free_full (selection_list, (GDestroyNotify)gtk_tree_path_free);
}
コード例 #24
0
ファイル: brush.c プロジェクト: jiapei100/gimp
void
create_brushpage (GtkNotebook *notebook)
{
  GtkWidget        *box1, *box2, *box3, *thispage;
  GtkWidget        *view;
  GtkWidget        *tmpw, *grid;
  GtkWidget        *frame;
  GtkWidget        *combo;
  GtkWidget        *label;
  GtkSizeGroup     *group;
  GtkTreeSelection *selection;

  label = gtk_label_new_with_mnemonic (_("_Brush"));

  thispage = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
  gtk_container_set_border_width (GTK_CONTAINER (thispage), 12);
  gtk_widget_show (thispage);

  box1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
  gtk_box_pack_start (GTK_BOX (thispage), box1, TRUE,TRUE,0);
  gtk_widget_show (box1);

  view = create_one_column_list (box1, brush_select_file);
  brush_list = view;
  brush_list_store =
      GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (view)));

  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));

  box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
  gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
  gtk_widget_show (box2);

  frame = gtk_frame_new (NULL);
  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
  gtk_box_pack_start (GTK_BOX (box2), frame, FALSE, FALSE, 0);
  gtk_widget_show (frame);

  brush_preview = tmpw = gimp_preview_area_new ();
  gtk_widget_set_size_request (brush_preview, 100, 100);
  gtk_container_add (GTK_CONTAINER (frame), tmpw);
  gtk_widget_show (tmpw);
  g_signal_connect (brush_preview, "size-allocate",
                    G_CALLBACK (brush_preview_size_allocate), NULL);

  box3 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
  gtk_box_pack_end (GTK_BOX (box2), box3, FALSE, FALSE,0);
  gtk_widget_show (box3);

  tmpw = gtk_label_new (_("Gamma:"));
  gtk_label_set_xalign (GTK_LABEL (tmpw), 0.0);
  gtk_box_pack_start (GTK_BOX (box3), tmpw, FALSE, FALSE,0);
  gtk_widget_show (tmpw);

  brush_gamma_adjust = gtk_adjustment_new (pcvals.brushgamma,
                                           0.5, 3.0, 0.1, 0.1, 1.0);
  tmpw = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, brush_gamma_adjust);
  gtk_widget_set_size_request (GTK_WIDGET (tmpw), 100, 30);
  gtk_scale_set_draw_value (GTK_SCALE (tmpw), FALSE);
  gtk_scale_set_digits (GTK_SCALE (tmpw), 2);
  gtk_box_pack_start (GTK_BOX (box3), tmpw, FALSE, FALSE, 0);
  gtk_widget_show (tmpw);
  g_signal_connect_swapped (brush_gamma_adjust, "value-changed",
                            G_CALLBACK (update_brush_preview),
                            pcvals.selected_brush);

  gimp_help_set_help_data
    (tmpw, _("Changes the gamma (brightness) of the selected brush"), NULL);

  box3 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
  gtk_box_pack_start (GTK_BOX (thispage), box3, FALSE, FALSE,0);
  gtk_widget_show (box3);

  group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);

  tmpw = gtk_label_new (_("Select:"));
  gtk_label_set_xalign (GTK_LABEL (tmpw), 0.0);
  gtk_box_pack_start (GTK_BOX (box3), tmpw, FALSE, FALSE, 0);
  gtk_widget_show (tmpw);

  gtk_size_group_add_widget (group, tmpw);
  g_object_unref (group);

  combo = gimp_drawable_combo_box_new (validdrawable, NULL);
  gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), -1,
                              G_CALLBACK (brushdmenuselect),
                              NULL);

  gtk_box_pack_start (GTK_BOX (box3), combo, TRUE, TRUE, 0);
  gtk_widget_show (combo);

  tmpw = gtk_button_new_with_mnemonic (_("Save _as"));
  gtk_box_pack_start (GTK_BOX (box3),tmpw, FALSE, FALSE, 0);
  g_signal_connect (tmpw, "clicked", G_CALLBACK (savebrush), NULL);
  gtk_widget_show (tmpw);

  grid = gtk_grid_new ();
  gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
  gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
  gtk_box_pack_start (GTK_BOX (thispage), grid, FALSE, FALSE, 0);
  gtk_widget_show (grid);

  brush_aspect_adjust =
    gimp_scale_entry_new (GTK_GRID (grid), 0, 0,
                          _("Aspect ratio:"),
                          150, -1, pcvals.brush_aspect,
                          -1.0, 1.0, 0.1, 0.1, 2,
                          TRUE, 0, 0,
                          _("Specifies the aspect ratio of the brush"),
                          NULL);
  gtk_size_group_add_widget (group,
                             GIMP_SCALE_ENTRY_LABEL (brush_aspect_adjust));
  g_signal_connect (brush_aspect_adjust, "value-changed",
                    G_CALLBACK (brush_asepct_adjust_cb),
                    &pcvals.brush_aspect);

  brush_relief_adjust =
    gimp_scale_entry_new (GTK_GRID (grid), 0, 1,
                          _("Relief:"),
                          150, -1, pcvals.brush_relief,
                          0.0, 100.0, 1.0, 10.0, 1,
                          TRUE, 0, 0,
                          _("Specifies the amount of embossing to apply to the image (in percent)"),
                          NULL);
  gtk_size_group_add_widget (group,
                             GIMP_SCALE_ENTRY_LABEL (brush_relief_adjust));
  g_signal_connect (brush_relief_adjust, "value-changed",
                    G_CALLBACK (gimp_double_adjustment_update),
                    &pcvals.brush_relief);

  brush_select (selection, FALSE);
  readdirintolist ("Brushes", view, pcvals.selected_brush);

  /*
   * This is so the "changed signal won't get sent to the brushes' list
   * and reset the gamma and stuff.
   * */
  gtk_widget_grab_focus (brush_list);

  gtk_notebook_append_page_menu (notebook, thispage, label, NULL);
}
コード例 #25
0
ファイル: translatorchooser.c プロジェクト: dancparkes/iODBC
void
create_translatorchooser (HWND hwnd, TTRANSLATORCHOOSER *choose_t)
{
  GdkPixmap *pixmap;
  GdkBitmap *mask;
  GtkStyle *style;

  GtkWidget *translatorchooser;
  GtkWidget *vbox41;
  GtkWidget *hbox57;
  GtkWidget *frame97;
  GtkWidget *alignment81;
  GtkWidget *pixmap1;
  GtkWidget *frame98;
  GtkWidget *alignment82;
  GtkWidget *scrolledwindow21;
  GtkWidget *clist1;
  GtkWidget *label158;
  GtkWidget *label159;
  GtkWidget *label160;
  GtkWidget *label161;
  GtkWidget *label162;
  GtkWidget *hbuttonbox3;
  GtkWidget *b_finish;
  GtkWidget *b_cancel;

  if (hwnd == NULL || !GTK_IS_WIDGET (hwnd))
    return;

  translatorchooser = gtk_dialog_new ();
  gtk_widget_set_name (translatorchooser, "translatorchooser");
  gtk_widget_set_size_request (translatorchooser, 515, 335);
  gtk_window_set_title (GTK_WINDOW (translatorchooser), _("Choose a Translator"));
  gtk_window_set_position (GTK_WINDOW (translatorchooser), GTK_WIN_POS_CENTER_ON_PARENT);
  gtk_window_set_modal (GTK_WINDOW (translatorchooser), TRUE);
  gtk_window_set_default_size (GTK_WINDOW (translatorchooser), 600, 450);
  gtk_window_set_type_hint (GTK_WINDOW (translatorchooser), GDK_WINDOW_TYPE_HINT_DIALOG);

#if GTK_CHECK_VERSION(2,0,0)
  gtk_widget_show (translatorchooser);
#endif

  vbox41 = GTK_DIALOG (translatorchooser)->vbox;
  gtk_widget_set_name (vbox41, "vbox41");
  gtk_widget_show (vbox41);

  hbox57 = gtk_hbox_new (FALSE, 0);
  gtk_widget_set_name (hbox57, "hbox57");
  gtk_widget_show (hbox57);
  gtk_box_pack_start (GTK_BOX (vbox41), hbox57, TRUE, TRUE, 0);

  frame97 = gtk_frame_new (NULL);
  gtk_widget_set_name (frame97, "frame97");
  gtk_widget_show (frame97);
  gtk_box_pack_start (GTK_BOX (hbox57), frame97, FALSE, TRUE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (frame97), 10);
  gtk_frame_set_shadow_type (GTK_FRAME (frame97), GTK_SHADOW_NONE);

  alignment81 = gtk_alignment_new (0.5, 0.5, 1, 1);
  gtk_widget_set_name (alignment81, "alignment81");
  gtk_widget_show (alignment81);
  gtk_container_add (GTK_CONTAINER (frame97), alignment81);
  gtk_widget_set_size_request (alignment81, 140, -1);

#if GTK_CHECK_VERSION(2,0,0)
  style = gtk_widget_get_style (translatorchooser);
  pixmap =
      gdk_pixmap_create_from_xpm_d (translatorchooser->window, &mask,
      &style->bg[GTK_STATE_NORMAL], (gchar **) img_xpm);
#else
  style = gtk_widget_get_style (GTK_WIDGET (hwnd));
  pixmap =
      gdk_pixmap_create_from_xpm_d (GTK_WIDGET (hwnd)->window, &mask,
      &style->bg[GTK_STATE_NORMAL], (gchar **) img_xpm);
#endif
  pixmap1 = gtk_pixmap_new (pixmap, mask);
  gtk_widget_set_name (pixmap1, "pixmap1");
  gtk_widget_show (pixmap1);
  gtk_container_add (GTK_CONTAINER (alignment81), pixmap1);

  frame98 = gtk_frame_new (NULL);
  gtk_widget_set_name (frame98, "frame98");
  gtk_widget_show (frame98);
  gtk_box_pack_start (GTK_BOX (hbox57), frame98, TRUE, TRUE, 0);
  gtk_frame_set_shadow_type (GTK_FRAME (frame98), GTK_SHADOW_NONE);

  alignment82 = gtk_alignment_new (0.5, 0.5, 1, 1);
  gtk_widget_set_name (alignment82, "alignment82");
  gtk_widget_show (alignment82);
  gtk_container_add (GTK_CONTAINER (frame98), alignment82);
  gtk_alignment_set_padding (GTK_ALIGNMENT (alignment82), 0, 10, 0, 0);

  scrolledwindow21 = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_set_name (scrolledwindow21, "scrolledwindow21");
  gtk_widget_show (scrolledwindow21);
  gtk_container_add (GTK_CONTAINER (alignment82), scrolledwindow21);

  clist1 = gtk_clist_new (4);
  gtk_widget_set_name (clist1, "clist1");
  gtk_widget_show (clist1);
  gtk_container_add (GTK_CONTAINER (scrolledwindow21), clist1);
  gtk_clist_set_column_width (GTK_CLIST (clist1), 0, 165);
  gtk_clist_set_column_width (GTK_CLIST (clist1), 1, 118);
  gtk_clist_set_column_width (GTK_CLIST (clist1), 2, 80);
  gtk_clist_set_column_width (GTK_CLIST (clist1), 3, 80);
  gtk_clist_column_titles_show (GTK_CLIST (clist1));

  label158 = gtk_label_new (_("Name"));
  gtk_widget_set_name (label158, "label158");
  gtk_widget_show (label158);
  gtk_clist_set_column_widget (GTK_CLIST (clist1), 0, label158);
  gtk_widget_set_size_request (label158, 165, -1);

  label159 = gtk_label_new (_("File"));
  gtk_widget_set_name (label159, "label159");
  gtk_widget_show (label159);
  gtk_clist_set_column_widget (GTK_CLIST (clist1), 1, label159);
  gtk_widget_set_size_request (label159, 118, -1);

  label160 = gtk_label_new (_("Date"));
  gtk_widget_set_name (label160, "label160");
  gtk_widget_show (label160);
  gtk_clist_set_column_widget (GTK_CLIST (clist1), 2, label160);
  gtk_widget_set_size_request (label160, 80, -1);

  label161 = gtk_label_new (_("Size"));
  gtk_widget_set_name (label161, "label161");
  gtk_widget_show (label161);
  gtk_clist_set_column_widget (GTK_CLIST (clist1), 3, label161);
  gtk_widget_set_size_request (label161, 80, -1);

  label162 = gtk_label_new (_("Select which ODBC Translator you want to use"));
  gtk_widget_set_name (label162, "label162");
  gtk_widget_show (label162);
  gtk_frame_set_label_widget (GTK_FRAME (frame98), label162);
  gtk_label_set_use_markup (GTK_LABEL (label162), TRUE);

  hbuttonbox3 = GTK_DIALOG (translatorchooser)->action_area;
  gtk_widget_set_name (hbuttonbox3, "hbuttonbox3");
  gtk_widget_show (hbuttonbox3);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox3), GTK_BUTTONBOX_END);

  b_finish = gtk_button_new_from_stock ("gtk-ok");
  gtk_widget_set_name (b_finish, "b_finish");
  gtk_widget_show (b_finish);
  gtk_dialog_add_action_widget (GTK_DIALOG (translatorchooser), b_finish, GTK_RESPONSE_OK);
  GTK_WIDGET_SET_FLAGS (b_finish, GTK_CAN_DEFAULT);

  b_cancel = gtk_button_new_from_stock ("gtk-cancel");
  gtk_widget_set_name (b_cancel, "b_cancel");
  gtk_widget_show (b_cancel);
  gtk_dialog_add_action_widget (GTK_DIALOG (translatorchooser), b_cancel, GTK_RESPONSE_CANCEL);
  GTK_WIDGET_SET_FLAGS (b_cancel, GTK_CAN_DEFAULT);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (translatorchooser, translatorchooser, "translatorchooser");
  GLADE_HOOKUP_OBJECT_NO_REF (translatorchooser, vbox41, "vbox41");
  GLADE_HOOKUP_OBJECT (translatorchooser, hbox57, "hbox57");
  GLADE_HOOKUP_OBJECT (translatorchooser, frame97, "frame97");
  GLADE_HOOKUP_OBJECT (translatorchooser, alignment81, "alignment81");
  GLADE_HOOKUP_OBJECT (translatorchooser, pixmap1, "pixmap1");
  GLADE_HOOKUP_OBJECT (translatorchooser, frame98, "frame98");
  GLADE_HOOKUP_OBJECT (translatorchooser, alignment82, "alignment82");
  GLADE_HOOKUP_OBJECT (translatorchooser, scrolledwindow21, "scrolledwindow21");
  GLADE_HOOKUP_OBJECT (translatorchooser, clist1, "clist1");
  GLADE_HOOKUP_OBJECT (translatorchooser, label158, "label158");
  GLADE_HOOKUP_OBJECT (translatorchooser, label159, "label159");
  GLADE_HOOKUP_OBJECT (translatorchooser, label160, "label160");
  GLADE_HOOKUP_OBJECT (translatorchooser, label161, "label161");
  GLADE_HOOKUP_OBJECT (translatorchooser, label162, "label162");
  GLADE_HOOKUP_OBJECT_NO_REF (translatorchooser, hbuttonbox3, "hbuttonbox3");
  GLADE_HOOKUP_OBJECT (translatorchooser, b_finish, "b_finish");
  GLADE_HOOKUP_OBJECT (translatorchooser, b_cancel, "b_cancel");

  /* Ok button events */
  gtk_signal_connect (GTK_OBJECT (b_finish), "clicked",
      GTK_SIGNAL_FUNC (translatorchooser_ok_clicked), choose_t);
  /* Cancel button events */
  gtk_signal_connect (GTK_OBJECT (b_cancel), "clicked",
      GTK_SIGNAL_FUNC (translatorchooser_cancel_clicked), choose_t);
  /* Close window button events */
  gtk_signal_connect (GTK_OBJECT (translatorchooser), "delete_event",
      GTK_SIGNAL_FUNC (delete_event), choose_t);
  gtk_signal_connect (GTK_OBJECT (translatorchooser), "destroy",
      GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
  /* Translator list events */
  gtk_signal_connect (GTK_OBJECT (clist1), "select_row",
      GTK_SIGNAL_FUNC (translator_list_select), choose_t);

  addtranslators_to_list (clist1, translatorchooser);

  choose_t->translatorlist = clist1;
  choose_t->translator = NULL;
  choose_t->mainwnd = translatorchooser;
  choose_t->b_finish = b_finish;

  gtk_widget_show_all (translatorchooser);
  gtk_main ();
}
コード例 #26
0
void
filter_expression_save_dlg(gpointer data)
{
	GtkWidget   *main_vb, *main_filter_save_hb, *filter_save_frame,
		    *filter_save_type_vb, *filter_save_type_hb, *entry_hb,
		    *bbox, *ok_bt, *cancel_bt, *help_bt, *filter_text_box,
		    *label_text_box;
 
	const char *expr;

	/* The filter requested */
	expr = gtk_entry_get_text(GTK_ENTRY(data));

	if (filter_save_frame_w != NULL) {
		/* There's already a "Filter Save" dialog box; reactivate it. */
		reactivate_window(filter_save_frame_w);
		return;
	}

	filter_save_frame_w = dlg_window_new("Wireshark: Save Filter");

	/* Container for each row of widgets */
	main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
	gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
	gtk_container_add(GTK_CONTAINER(filter_save_frame_w), main_vb);
	gtk_widget_show(main_vb);


	/* */
	main_filter_save_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
	gtk_container_add(GTK_CONTAINER(main_vb), main_filter_save_hb);
	gtk_widget_show(main_filter_save_hb);

	/* Filter Save frame */
	filter_save_frame = gtk_frame_new("Save Filter as...");
	gtk_box_pack_start(GTK_BOX(main_filter_save_hb), filter_save_frame,
	    TRUE, TRUE, 0);
	gtk_widget_show(filter_save_frame);

	filter_save_type_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
	gtk_container_set_border_width(GTK_CONTAINER(filter_save_type_vb), 3);
	gtk_container_add(GTK_CONTAINER(filter_save_frame),
	    filter_save_type_vb);
	gtk_widget_show(filter_save_type_vb);

	/* filter_save type row */
	filter_save_type_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
	gtk_container_add(GTK_CONTAINER(filter_save_type_vb),
	    filter_save_type_hb);
	gtk_widget_show(filter_save_type_hb);

	/* filter_save row */
	entry_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
	gtk_box_pack_start(GTK_BOX(filter_save_type_vb), entry_hb, FALSE,
	    FALSE, 0);
	gtk_widget_show(entry_hb);

	filter_text_box = gtk_entry_new();
	gtk_box_pack_start(GTK_BOX(entry_hb), filter_text_box, TRUE, TRUE, 0);
	g_signal_connect(filter_text_box, "changed", G_CALLBACK(filter_te_syntax_check_cb), NULL);
	g_signal_connect(filter_text_box, "key-press-event", G_CALLBACK (filter_string_te_key_pressed_cb), NULL);
	g_signal_connect(filter_save_frame_w, "key-press-event", G_CALLBACK (filter_parent_dlg_key_pressed_cb), NULL);

	gtk_entry_set_text(GTK_ENTRY(filter_text_box), expr);
	gtk_widget_show(filter_text_box);

	label_text_box = gtk_entry_new();
	gtk_box_pack_start(GTK_BOX(entry_hb), label_text_box, TRUE, TRUE, 0);
	gtk_entry_set_text(GTK_ENTRY(label_text_box), "Filter");
	gtk_widget_show(label_text_box);

	/* Button row */
	bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CANCEL,
	    GTK_STOCK_HELP, NULL);
	gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
	gtk_widget_show(bbox);

	ok_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
	g_signal_connect(ok_bt, "clicked", G_CALLBACK(filter_save_ok_cb),
	filter_save_frame_w);

	cancel_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
	g_signal_connect(cancel_bt, "clicked", G_CALLBACK(filter_save_close_cb),
	filter_save_frame_w);

	help_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
	g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb),
	(gpointer)HELP_FILTER_SAVE_DIALOG);

	g_object_set_data(G_OBJECT(filter_save_frame_w),
	    E_FILTER_SAVE_EXPR_KEY, filter_text_box);
	g_object_set_data(G_OBJECT(filter_save_frame_w),
	    E_FILTER_SAVE_LABEL_KEY, label_text_box);

	dlg_set_activate(label_text_box, ok_bt);

	/* Give the initial focus to the "offset" entry box. */
	gtk_widget_grab_focus(label_text_box);

	g_signal_connect(filter_save_frame_w, "delete_event",
	G_CALLBACK(window_delete_event_cb), NULL);
	g_signal_connect(filter_save_frame_w, "destroy",
	G_CALLBACK(filter_save_frame_destroy_cb), NULL);

	gtk_widget_show(filter_save_frame_w);
	window_present(filter_save_frame_w);
}
コード例 #27
0
ファイル: charpick.c プロジェクト: incandenza21/mate-applets
void
build_table(charpick_data *p_curr_data)
{
  GtkWidget *box, *button_box, **row_box;
  GtkWidget *button, *arrow;
  gint i = 0, len = g_utf8_strlen (p_curr_data->charlist, -1);
  GtkWidget **toggle_button;
  gchar *charlist;
  gint max_width=1, max_height=1;
  gint size_ratio;

  toggle_button = g_new (GtkWidget *, len);
  
  if (p_curr_data->box)
    gtk_widget_destroy(p_curr_data->box);
    
  if (p_curr_data->panel_vertical)
    box = gtk_vbox_new (FALSE, 0);
  else 
    box = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (box);
  p_curr_data->box = box;
  
  button = gtk_button_new ();
  if (g_list_length (p_curr_data->chartable) != 1)
  {
    gtk_widget_set_tooltip_text (button, _("Available palettes"));
  
    switch (mate_panel_applet_get_orient (MATE_PANEL_APPLET (p_curr_data->applet))) {
       	case MATE_PANEL_APPLET_ORIENT_DOWN:
          	arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_OUT);
       		break;
       	case MATE_PANEL_APPLET_ORIENT_UP:
          	arrow = gtk_arrow_new (GTK_ARROW_UP, GTK_SHADOW_OUT);  
       		break;
       	case MATE_PANEL_APPLET_ORIENT_LEFT:
       		arrow = gtk_arrow_new (GTK_ARROW_LEFT, GTK_SHADOW_OUT);  
  		break;
       	case MATE_PANEL_APPLET_ORIENT_RIGHT:
       		arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_OUT);  
  		break;
    default:
  	  g_assert_not_reached ();
    }
    gtk_container_add (GTK_CONTAINER (button), arrow);
    gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
    /* FIXME : evil hack (see force_no_focus_padding) */
    force_no_focus_padding (button);
    gtk_box_pack_start (GTK_BOX (box), button, TRUE, TRUE, 0);
    g_signal_connect (G_OBJECT (button), "clicked",
                              G_CALLBACK (chooser_button_clicked),
			      p_curr_data);
    g_signal_connect (G_OBJECT (button), "button_press_event",
                               G_CALLBACK (button_press_hack),
			       p_curr_data->applet);
  
  }
  
  charlist = g_strdup (p_curr_data->charlist);
  for (i = 0; i < len; i++) {
    gchar label[7];
    GtkRequisition req;
    gchar *atk_desc;
    gchar *name;
    
    g_utf8_strncpy (label, charlist, 1);
    charlist = g_utf8_next_char (charlist);

#ifdef HAVE_MUCHARMAP
    /* TRANSLATOR: This sentance reads something like 'Insert "PILCROW SIGN"'
     *             hopefully, the name of the unicode character has already
     *             been translated.
     */
    name = g_strdup_printf (_("Insert \"%s\""),
		    mucharmap_get_unicode_name (g_utf8_get_char (label)));
#else
    name = g_strdup (_("Insert special character"));
#endif
   
    toggle_button[i] = gtk_toggle_button_new_with_label (label);
    atk_desc =  g_strdup_printf (_("insert special character %s"), label);
    set_atk_name_description (toggle_button[i], NULL, atk_desc);
    g_free (atk_desc);
    gtk_widget_show (toggle_button[i]);
    gtk_button_set_relief(GTK_BUTTON(toggle_button[i]), GTK_RELIEF_NONE);
    /* FIXME : evil hack (see force_no_focus_padding) */
    force_no_focus_padding (toggle_button[i]);
    gtk_widget_set_tooltip_text (toggle_button[i], name);
    g_free (name);
                      
    gtk_widget_size_request (toggle_button[i], &req);
    
    max_width = MAX (max_width, req.width);
    max_height = MAX (max_height, req.height-2);
  
    g_object_set_data (G_OBJECT (toggle_button[i]), "unichar", 
				GINT_TO_POINTER(g_utf8_get_char (label)));
    g_signal_connect (GTK_OBJECT (toggle_button[i]), "toggled",
		      G_CALLBACK (toggle_button_toggled_cb),
                        p_curr_data);
    g_signal_connect (GTK_OBJECT (toggle_button[i]), "button_press_event", 
                      G_CALLBACK (button_press_hack), p_curr_data->applet);
  }
  
  if (p_curr_data->panel_vertical) {
    size_ratio = p_curr_data->panel_size / max_width;
    button_box = gtk_hbox_new (TRUE, 0);
  } else {
    size_ratio = p_curr_data->panel_size / max_height;
    button_box = gtk_vbox_new (TRUE, 0);
  }

  gtk_box_pack_start (GTK_BOX (box), button_box, TRUE, TRUE, 0);
  
  size_ratio = MAX (size_ratio, 1);
  row_box = g_new0 (GtkWidget *, size_ratio);
  for (i=0; i < size_ratio; i++) {
  	if (!p_curr_data->panel_vertical) row_box[i] = gtk_hbox_new (TRUE, 0);
  	else row_box[i] = gtk_vbox_new (TRUE, 0);
  	gtk_box_pack_start (GTK_BOX (button_box), row_box[i], TRUE, TRUE, 0);
  }
  
  for (i = 0; i <len; i++) {  	
  	int delta = len/size_ratio;
  	int index;
  
	if (delta > 0)
	  	index = i / delta;
	else
		index = i;

	index = CLAMP (index, 0, size_ratio-1);	
  	gtk_box_pack_start (GTK_BOX (row_box[index]), toggle_button[i], TRUE, TRUE, 0);
  }
 
  g_free (toggle_button);
  
  gtk_container_add (GTK_CONTAINER(p_curr_data->applet), box);
  gtk_widget_show_all (p_curr_data->box);

  p_curr_data->last_index = NO_LAST_INDEX;
  p_curr_data->last_toggle_button = NULL;
  
}
コード例 #28
0
/**
 * \brief creates a warning dialog widget displaying the errors contained
 *      in the list passed.
 *
 * @param elist the list of errors to display
 * @param from_where flag to tell the warning where it originated from. The
 *      values recognized are defined with called_from_where.
 * @return the warning dialog widget
 * @see called_from_where
 */
GtkWidget *
xvc_create_warning_with_errors (XVC_ErrorListItem * elist, int from_where)
{
#undef DEBUGFUNCTION
#define DEBUGFUNCTION "xvc_create_warning_with_errors()"
    GtkWidget *vbox = NULL, *w = NULL;
    GladeXML *xml = NULL;
    int count_fatal_messages = 0;
    XVC_AppData *app = xvc_appdata_ptr ();

#ifdef DEBUG
    printf ("%s %s: Entering\n", DEBUGFILE, DEBUGFUNCTION);
#endif     // DEBUG

    // save list for cleanup
    warning_elist = elist;
    // save the origin
    called_from_where = from_where;

    // load the interface
    xml = glade_xml_new (XVC_GLADE_FILE, "xvc_warn_main_window", NULL);
    g_assert (xml);

    // connect the signals in the interface
    glade_xml_signal_autoconnect (xml);
    // store the toplevel widget for further reference
    xvc_warn_main_window = glade_xml_get_widget (xml, "xvc_warn_main_window");
    g_assert (xvc_warn_main_window);

    // set the error list
    if (elist != NULL) {
        XVC_ErrorListItem *err = NULL;

        vbox = glade_xml_get_widget (xml, "xvc_warn_errors_vbox");
        g_assert (vbox);

        err = elist;
        for (; err != NULL; err = err->next) {
            GtkWidget *eitem;

            if (err->err->type != XVC_ERR_INFO
                || (app->flags & FLG_RUN_VERBOSE)) {
                if (err->err->type == XVC_ERR_FATAL)
                    count_fatal_messages++;
                eitem = xvc_error_item_new_with_error (err->err);
                gtk_box_pack_start (GTK_BOX (vbox), eitem, FALSE, FALSE, 0);
                gtk_widget_show (eitem);
            }
        }
    } else {
        fprintf (stderr,
                 "%s %s: displaying a warning with a NULL error list\n",
                 DEBUGFILE, DEBUGFUNCTION);
    }

    // depending on where we're called from make different buttons
    // visible/sensitive
    switch (called_from_where) {
    case 0:
        w = NULL;
        w = glade_xml_get_widget (xml, "xvc_warn_pref_button");
        g_assert (w);
        gtk_widget_hide (w);

        w = NULL;
        w = glade_xml_get_widget (xml, "xvc_warn_cancel_button");
        g_assert (w);
        gtk_widget_show (w);
        break;
    case 1:
    case 2:
        w = NULL;
        w = glade_xml_get_widget (xml, "xvc_warn_pref_button");
        g_assert (w);
        gtk_widget_show (w);

        w = NULL;
        w = glade_xml_get_widget (xml, "xvc_warn_cancel_button");
        g_assert (w);
        gtk_widget_hide (w);
        break;
    default:
        break;
    }
#ifdef DEBUG
    printf ("%s %s: called from where %i\n", DEBUGFILE, DEBUGFUNCTION,
            called_from_where);
#endif     // DEBUG

    // auto-resize the dialog ... this is one ugly hack but the only way
    // to do it
    scheduled_warning_resize_id = g_timeout_add ((guint32) 5, (GtkFunction)
                                                 auto_resize_warning_dialog,
                                                 NULL);

#ifdef DEBUG
    printf ("%s %s: Leaving\n", DEBUGFILE, DEBUGFUNCTION);
#endif     // DEBUG

    return xvc_warn_main_window;
}
コード例 #29
0
ファイル: build.cpp プロジェクト: raynorpat/cake
GtkWindow* BuildMenuDialog_construct(ModalDialog& modal, ProjectList& projectList)
{
  GtkWindow* window = create_dialog_window(MainFrame_getWindow(), "Build Menu", G_CALLBACK(dialog_delete_callback), &modal, -1, 400);

  GtkWidget* buildView = 0;

  {
    GtkTable* table1 = create_dialog_table(2, 2, 4, 4, 4);
    gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(table1));
    {
      GtkVBox* vbox = create_dialog_vbox(4);
      gtk_table_attach(table1, GTK_WIDGET(vbox), 1, 2, 0, 1,
                        (GtkAttachOptions) (GTK_FILL),
                        (GtkAttachOptions) (GTK_FILL), 0, 0);
      {
        GtkButton* button = create_dialog_button("OK", G_CALLBACK(dialog_button_ok), &modal);
        gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(button), FALSE, FALSE, 0);
      }
      {
        GtkButton* button = create_dialog_button("Cancel", G_CALLBACK(dialog_button_cancel), &modal);
        gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(button), FALSE, FALSE, 0);
      }
    }
    {
      GtkFrame* frame = create_dialog_frame("Build menu");
      gtk_table_attach(table1, GTK_WIDGET(frame), 0, 1, 0, 1,
                        (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                        (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0);
      {
        GtkScrolledWindow* scr = create_scrolled_window(GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC, 4);
        gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(scr));

        {
          GtkListStore* store = gtk_list_store_new(1, G_TYPE_STRING);

          GtkWidget* view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
          gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);

          GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
          object_set_boolean_property(G_OBJECT(renderer), "editable", TRUE);
          g_signal_connect(renderer, "edited", G_CALLBACK(project_cell_edited), &projectList);
 
          GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("", renderer, "text", 0, 0);
          gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);

          GtkTreeSelection* selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
          gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE);

          gtk_widget_show(view);

          buildView = view;
          projectList.m_store = store;
          gtk_container_add(GTK_CONTAINER (scr), view);
  
          g_signal_connect(G_OBJECT(view), "key_press_event", G_CALLBACK(project_key_press), &projectList);

          g_object_unref(G_OBJECT(store));
        }
      }
    }
    {
      GtkFrame* frame = create_dialog_frame("Commandline");
      gtk_table_attach(table1, GTK_WIDGET(frame), 0, 1, 1, 2,
                        (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                        (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0);
      {
        GtkScrolledWindow* scr = create_scrolled_window(GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC, 4);
        gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(scr));

        {
          GtkListStore* store = gtk_list_store_new(1, G_TYPE_STRING);

          GtkWidget* view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
          gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);

          GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
          object_set_boolean_property(G_OBJECT(renderer), "editable", TRUE);
          g_signal_connect(renderer, "edited", G_CALLBACK(commands_cell_edited), store);
 
          GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("", renderer, "text", 0, 0);
          gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);

          GtkTreeSelection* selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
          gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE);

          gtk_widget_show(view);

          gtk_container_add(GTK_CONTAINER (scr), view);
  
          g_object_unref(G_OBJECT(store));

          g_signal_connect(G_OBJECT(view), "key_press_event", G_CALLBACK(commands_key_press), store);
         
          g_signal_connect(G_OBJECT(gtk_tree_view_get_selection(GTK_TREE_VIEW(buildView))), "changed", G_CALLBACK(project_selection_changed), store);
        }
      }
    }
  }

  BSPCommandList_Construct(projectList.m_store, g_build_project);

  return window;
}
コード例 #30
0
ファイル: gsb_select_icon.c プロジェクト: wazari972/Grisbi
/**
 * crée la boite de dialogue initiale avec le  GtkIconView
 *
 * \param nom de l'icône
 *
 * \return le nouveau nom de l'icône ou NULL
 * */
gchar * gsb_select_icon_create_window ( gchar *name_icon )
{
    GtkWidget *content_area;
    GtkWidget *hbox;
    GtkWidget *chooser_button;
    GtkWidget *scroll;
    GtkWidget *icon_view;
	gint result;

    devel_debug ( name_icon );

    if ( new_icon && strlen ( new_icon ) > 0 )
        g_free ( new_icon );

    new_icon = g_strdup ( name_icon );

    path_icon = g_path_get_dirname ( name_icon );
    dialog = gtk_dialog_new_with_buttons ( _("Browse icons"),
                            GTK_WINDOW ( run.window ),
                            GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
                            GTK_STOCK_CANCEL,
                            GTK_RESPONSE_REJECT,
                            NULL);

    gtk_window_set_position ( GTK_WINDOW ( dialog ), GTK_WIN_POS_CENTER_ON_PARENT );
    gtk_window_set_resizable ( GTK_WINDOW ( dialog ), TRUE );

    bouton_OK = gtk_dialog_add_button (GTK_DIALOG ( dialog ),
                                GTK_STOCK_OK,
                                GTK_RESPONSE_ACCEPT);
    gtk_widget_set_size_request ( dialog, 400, 450 );
    content_area = GTK_DIALOG ( dialog ) -> vbox;

    /* création hbox pour GtkEntry répertoire et bouton sélection des répertoires */
    hbox = gtk_hbox_new ( FALSE, 5);
	gtk_container_set_border_width ( GTK_CONTAINER( hbox ), 6 );
    gtk_box_pack_start ( GTK_BOX ( content_area ), hbox, FALSE, FALSE, 5 );

    /* création du GtkComboBoxEntry pour la saisie du répertoire */
    entry_text = gsb_select_icon_create_entry_text ( name_icon );
    gtk_box_pack_start ( GTK_BOX ( hbox ), entry_text, TRUE, TRUE, 0 );

    /* création du bouton de sélection des répertoires */
    chooser_button = gtk_button_new_with_label ( _("Browse") );
    gtk_box_pack_start ( GTK_BOX ( hbox ), chooser_button, FALSE, FALSE, 0 );

    /* création de la vue pour les icônes */
    scroll = gtk_scrolled_window_new ( NULL, NULL);
    gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW ( scroll ),
                             GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
    gtk_box_pack_start ( GTK_BOX ( content_area ), scroll, TRUE, TRUE, 0 );
    icon_view = gsb_select_icon_create_icon_view ( name_icon );
    gtk_container_set_border_width ( GTK_CONTAINER( scroll ), 6 );
    gtk_container_add ( GTK_CONTAINER ( scroll ), icon_view );

    /* gestion des signaux */
    g_signal_connect ( G_OBJECT ( icon_view ),
                        "selection-changed",
                        G_CALLBACK( gsb_select_icon_selection_changed ),
                        NULL );

    g_signal_connect ( G_OBJECT ( chooser_button ),
                        "clicked",
                        G_CALLBACK(gsb_select_icon_create_file_chooser),
                        NULL );

    g_signal_connect ( G_OBJECT( entry_text ),
                        "changed",
                        G_CALLBACK( gsb_select_icon_entry_text_changed ),
                        NULL );

    gtk_widget_show_all ( dialog );

    result = gtk_dialog_run (GTK_DIALOG (dialog));
    switch (result)
    {
      case GTK_RESPONSE_ACCEPT:
         devel_debug ( "réponse OK" );
         break;
      default:
         devel_debug ( "réponse Non OK" );
         if ( new_icon && strlen ( new_icon ) > 0 )
            g_free ( new_icon );
         new_icon = NULL;
         break;
    }
    gtk_widget_destroy (dialog);

    return new_icon;
}