Beispiel #1
0
static void facq_plug_dialog_constructed(GObject *self)
{
	FacqPlugDialog *dialog = FACQ_PLUG_DIALOG(self);
	GtkWidget *vbox = NULL, *table = NULL, *widget = NULL;

	dialog->priv->dialog = 
		gtk_dialog_new_with_buttons("Plug preferences",
				GTK_WINDOW(dialog->priv->top_window),
					GTK_DIALOG_MODAL | 
						GTK_DIALOG_DESTROY_WITH_PARENT,
							GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,
								GTK_STOCK_OK,GTK_RESPONSE_OK,NULL);

	vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog->priv->dialog));
	table = gtk_table_new(2,2,FALSE);
	
	widget = gtk_label_new("Address:");
	gtk_label_set_justify(GTK_LABEL(widget),GTK_JUSTIFY_LEFT);
	gtk_table_attach_defaults(GTK_TABLE(table),widget,0,1,0,1);
	
	widget = gtk_entry_new();
	if(dialog->priv->address)
		gtk_entry_set_text(GTK_ENTRY(widget),dialog->priv->address);
	else
		gtk_entry_set_text(GTK_ENTRY(widget),"all");
	gtk_entry_set_icon_from_stock(GTK_ENTRY(widget),GTK_ENTRY_ICON_PRIMARY,GTK_STOCK_CLEAR);
	gtk_entry_set_icon_from_stock(GTK_ENTRY(widget),GTK_ENTRY_ICON_SECONDARY,GTK_STOCK_NETWORK);
	gtk_entry_set_icon_activatable(GTK_ENTRY(widget),GTK_ENTRY_ICON_PRIMARY,TRUE);
	gtk_entry_set_icon_activatable(GTK_ENTRY(widget),GTK_ENTRY_ICON_SECONDARY,TRUE);
	gtk_entry_set_icon_sensitive(GTK_ENTRY(widget),GTK_ENTRY_ICON_PRIMARY,TRUE);
	gtk_entry_set_icon_sensitive(GTK_ENTRY(widget),GTK_ENTRY_ICON_SECONDARY,TRUE);
	g_signal_connect(widget,"icon-press",
				G_CALLBACK(address_icons_callback),dialog);
	dialog->priv->address_entry = widget;
	gtk_table_attach_defaults(GTK_TABLE(table),widget,1,2,0,1);

	widget = gtk_label_new("Port:");
	gtk_label_set_justify(GTK_LABEL(widget),GTK_JUSTIFY_LEFT);
	gtk_table_attach_defaults(GTK_TABLE(table),widget,0,1,1,2);
	
	widget = gtk_spin_button_new_with_range(0,65535,1);
	gtk_entry_set_icon_from_stock(GTK_ENTRY(widget),GTK_ENTRY_ICON_PRIMARY,GTK_STOCK_CLEAR);
	gtk_entry_set_icon_from_stock(GTK_ENTRY(widget),GTK_ENTRY_ICON_SECONDARY,GTK_STOCK_CONNECT);
	gtk_spin_button_set_increments(GTK_SPIN_BUTTON(widget),1,10);
	gtk_spin_button_set_digits(GTK_SPIN_BUTTON(widget),0);
	gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget),dialog->priv->port);
	g_signal_connect(GTK_ENTRY(widget),"icon-press",
				G_CALLBACK(port_icons_callback),dialog);
	dialog->priv->spin_button = widget;
	gtk_table_attach_defaults(GTK_TABLE(table),widget,1,2,1,2);

	gtk_widget_show_all(table);

	gtk_container_add(GTK_CONTAINER(vbox),table);
}
void
set_entry_validation_checkmark (GtkEntry *entry)
{
        g_object_set (entry, "caps-lock-warning", FALSE, NULL);
        gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_SECONDARY, "object-select-symbolic");
        gtk_entry_set_icon_activatable (entry, GTK_ENTRY_ICON_SECONDARY, FALSE);
}
void
set_entry_generation_icon (GtkEntry *entry)
{
        g_object_set (entry, "caps-lock-warning", FALSE, NULL);
        gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_SECONDARY, "system-run-symbolic");
        gtk_entry_set_icon_activatable (entry, GTK_ENTRY_ICON_SECONDARY, TRUE);
}
/**
 * nma_utils_setup_password_storage:
 * @passwd_entry: password #GtkEntry which the icon is attached to
 * @initial_flags: initial secret flags to setup password menu from
 * @setting: #NMSetting containing the password, or NULL
 * @password_flags_name: name of the secret flags (like psk-flags), or NULL
 * @with_not_required: whether to include "Not required" menu item
 * @ask_mode: %TRUE if the entrie is shown in ASK mode. That means,
 *   while prompting for a password, contrary to being inside the
 *   editor mode.
 *   If %TRUE, the entry should be sensivive on selected "always-ask"
 *   icon (this is e.f. for nm-applet asking for password), otherwise
 *   not.
 *   If %TRUE, it shall not be possible to select a different storage,
 *   because we only prompt for a password, we cannot change the password
 *   location.
 *
 * Adds a secondary icon and creates a popup menu for password entry.
 * The active menu item is set up according to initial_flags, or
 * from @setting/@password_flags_name (if they are not NULL).
 * If the @setting/@password_flags_name are not NULL, secret flags will
 * be automatically updated in the setting when menu is changed.
 */
void
nma_utils_setup_password_storage (GtkWidget *passwd_entry,
                                  NMSettingSecretFlags initial_flags,
                                  NMSetting *setting,
                                  const char *password_flags_name,
                                  gboolean with_not_required,
                                  gboolean ask_mode)
{
    GtkWidget *popup_menu;
    GtkWidget *item[4];
    GSList *group;
    MenuItem idx;
    NMSettingSecretFlags secret_flags;

    /* Whether entry should be sensitive if "always-ask" is active " */
    g_object_set_data (G_OBJECT (passwd_entry), ASK_MODE_TAG, GUINT_TO_POINTER (ask_mode));

    popup_menu = gtk_menu_new ();
    g_object_set_data (G_OBJECT (popup_menu), PASSWORD_STORAGE_MENU_TAG, GUINT_TO_POINTER (TRUE));
    g_object_set_data (G_OBJECT (popup_menu), MENU_WITH_NOT_REQUIRED_TAG, GUINT_TO_POINTER (with_not_required));
    group = NULL;
    item[0] = gtk_radio_menu_item_new_with_label (group, gettext (icon_desc_table[0]));
    group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (item[0]));
    item[1] = gtk_radio_menu_item_new_with_label (group, gettext (icon_desc_table[1]));
    item[2] = gtk_radio_menu_item_new_with_label (group, gettext (icon_desc_table[2]));
    if (with_not_required)
        item[3] = gtk_radio_menu_item_new_with_label (group, gettext (icon_desc_table[3]));

    gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), item[0]);
    gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), item[1]);
    gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), item[2]);
    if (with_not_required)
        gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), item[3]);

    popup_menu_item_info_register (item[0], setting, password_flags_name, ITEM_STORAGE_USER, passwd_entry);
    popup_menu_item_info_register (item[1], setting, password_flags_name, ITEM_STORAGE_SYSTEM, passwd_entry);
    popup_menu_item_info_register (item[2], setting, password_flags_name, ITEM_STORAGE_ASK, passwd_entry);
    if (with_not_required)
        popup_menu_item_info_register (item[3], setting, password_flags_name, ITEM_STORAGE_UNUSED, passwd_entry);

    g_signal_connect (passwd_entry, "icon-release", G_CALLBACK (icon_release_cb), popup_menu);
    gtk_entry_set_icon_activatable (GTK_ENTRY (passwd_entry), GTK_ENTRY_ICON_SECONDARY,
                                    !ask_mode);
    gtk_menu_attach_to_widget (GTK_MENU (popup_menu), passwd_entry, NULL);

    /* Initialize active item for password-storage popup menu */
    if (setting && password_flags_name)
        nm_setting_get_secret_flags (setting, password_flags_name, &secret_flags, NULL);
    else
        secret_flags = initial_flags;

    idx = secret_flags_to_menu_item (secret_flags, with_not_required);
    gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item[idx]), TRUE);
    change_password_storage_icon (passwd_entry, idx);
}
Beispiel #5
0
void
_gtk_entry_use_as_password_entry (GtkEntry *entry)
{
	gtk_entry_set_visibility (entry, FALSE);
	gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_SECONDARY, "security-medium-symbolic");
	gtk_entry_set_icon_activatable (entry, GTK_ENTRY_ICON_SECONDARY, TRUE);
	gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_SECONDARY, _("Change password visibility"));

	g_signal_connect (entry,
			  "icon-press",
			  G_CALLBACK (password_entry_icon_press_cb),
			  NULL);
}
void
set_entry_validation_error (GtkEntry    *entry,
                            const gchar *text)
{
        g_object_set (entry, "caps-lock-warning", FALSE, NULL);
        gtk_entry_set_icon_from_icon_name (entry,
                                           GTK_ENTRY_ICON_SECONDARY,
                                           "dialog-warning-symbolic");
        gtk_entry_set_icon_activatable (entry,
                                        GTK_ENTRY_ICON_SECONDARY,
                                        TRUE);
        g_signal_connect (entry, "icon-release",
                          G_CALLBACK (icon_released), FALSE);
        g_signal_connect (entry, "query-tooltip",
                          G_CALLBACK (query_tooltip), NULL);
        g_object_set (entry, "has-tooltip", TRUE, NULL);
        gtk_entry_set_icon_tooltip_text (entry,
                                         GTK_ENTRY_ICON_SECONDARY,
                                         text);
}
Beispiel #7
0
static void
gimp_action_editor_init (GimpActionEditor *editor)
{
  GtkWidget *hbox;
  GtkWidget *label;
  GtkWidget *entry;

  gtk_orientable_set_orientation (GTK_ORIENTABLE (editor),
                                  GTK_ORIENTATION_VERTICAL);

  gtk_box_set_spacing (GTK_BOX (editor), 12);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
  gtk_box_pack_start (GTK_BOX (editor), hbox, FALSE, FALSE, 0);
  gtk_widget_show (hbox);

  label = gtk_label_new_with_mnemonic (_("_Search:"));
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
  gtk_widget_show (label);

  entry = gtk_entry_new ();
  gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
  gtk_widget_show (entry);

  gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);

  gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
                                 GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR);
  gtk_entry_set_icon_activatable (GTK_ENTRY (entry),
                                  GTK_ENTRY_ICON_SECONDARY, TRUE);
  gtk_entry_set_icon_sensitive (GTK_ENTRY (entry),
                                GTK_ENTRY_ICON_SECONDARY, FALSE);

  g_signal_connect (entry, "icon-press",
                    G_CALLBACK (gimp_action_editor_filter_clear),
                    NULL);
  g_signal_connect (entry, "changed",
                    G_CALLBACK (gimp_action_editor_filter_changed),
                    editor);
}
Beispiel #8
0
static void search_entry_changed_cb (GtkEditable *editable, YGtkHelpDialog *dialog)
{
	static GdkColor red = { 0, 255 << 8, 102 << 8, 102 << 8 };
	static GdkColor white = { 0, 0xffff, 0xffff, 0xffff };
	static GdkColor yellow = { 0, 0xf7f7, 0xf7f7, 0xbdbd };
	static GdkColor black = { 0, 0, 0, 0 };

	GtkWidget *widget = GTK_WIDGET (editable);
	GtkEntry *entry = GTK_ENTRY (editable);
	const gchar *text = gtk_entry_get_text (entry);
	gboolean found = ygtk_html_wrap_search (dialog->help_text, text);

	if (found && *text) {
		gtk_widget_modify_base (widget, GTK_STATE_NORMAL, &yellow);
		gtk_widget_modify_text (widget, GTK_STATE_NORMAL, &black);
	}
	else if (found) {  // revert
		gtk_widget_modify_base (widget, GTK_STATE_NORMAL, NULL);
		gtk_widget_modify_text (widget, GTK_STATE_NORMAL, NULL);
	}
	else {
		gtk_widget_modify_base (widget, GTK_STATE_NORMAL, &red);
		gtk_widget_modify_text (widget, GTK_STATE_NORMAL, &white);
		gtk_widget_error_bell (widget);
	}

	gboolean showIcon = *text;  // show clear icon if text
	if (showIcon != gtk_entry_get_icon_activatable (entry, GTK_ENTRY_ICON_SECONDARY)) {
		gtk_entry_set_icon_activatable (entry,
			GTK_ENTRY_ICON_SECONDARY, showIcon);
		gtk_entry_set_icon_from_stock (entry,
			GTK_ENTRY_ICON_SECONDARY, showIcon ? GTK_STOCK_CLEAR : NULL);
		if (showIcon)
			gtk_entry_set_icon_tooltip_text (entry,
				GTK_ENTRY_ICON_SECONDARY, _("Clear"));
	}
}
Beispiel #9
0
static void ygtk_help_dialog_init (YGtkHelpDialog *dialog)
{
	gtk_container_set_border_width (GTK_CONTAINER (dialog), 6);
	gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
	gtk_window_set_title (GTK_WINDOW (dialog), _("Help"));
	GdkPixbuf *icon = gtk_widget_render_icon (
		GTK_WIDGET (dialog), GTK_STOCK_HELP, GTK_ICON_SIZE_MENU, NULL);
	gtk_window_set_icon (GTK_WINDOW (dialog), icon);
	g_object_unref (G_OBJECT (icon));
	gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 450);

	// help text
	dialog->help_box = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy  (GTK_SCROLLED_WINDOW (dialog->help_box),
	                                 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (dialog->help_box),
	                                     GTK_SHADOW_IN);
	dialog->help_text = ygtk_html_wrap_new();
	gtk_container_add (GTK_CONTAINER (dialog->help_box), dialog->help_text);

#if 0  // show a nice background image
	GtkIconTheme *theme = gtk_icon_theme_get_default();
	GtkIconInfo *info = gtk_icon_theme_lookup_icon (theme, HELP_IMG_BG, 192, 0);
	if (info) {
		GdkPixbuf *pixbuf = gtk_icon_info_load_icon (info, NULL);
		if (pixbuf) {
			const gchar *filename = gtk_icon_info_get_filename (info);
			GdkPixbuf *transparent = ygutils_setOpacity (pixbuf, 60, FALSE);
			ygtk_html_wrap_set_background (dialog->help_text, transparent, filename);
			g_object_unref (pixbuf);
			g_object_unref (transparent);
		}
		gtk_icon_info_free (info);
	}
#endif

	// bottom part (search entry + close button)
	dialog->search_entry = gtk_entry_new();
	gtk_widget_set_size_request (dialog->search_entry, 140, -1);
	gtk_entry_set_icon_from_stock (GTK_ENTRY (dialog->search_entry),
		GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_FIND);
	gtk_entry_set_icon_activatable (GTK_ENTRY (dialog->search_entry),
		GTK_ENTRY_ICON_PRIMARY, TRUE);
	g_signal_connect (G_OBJECT (dialog->search_entry), "icon-press",
	                  G_CALLBACK (search_entry_icon_press_cb), dialog);
	g_signal_connect (G_OBJECT (dialog->search_entry), "changed",
	                  G_CALLBACK (search_entry_changed_cb), dialog);
	g_signal_connect (G_OBJECT (dialog->search_entry), "activate",
	                  G_CALLBACK (search_entry_activated_cb), dialog);

	dialog->close_button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
        gtk_widget_set_can_default(dialog->close_button, TRUE);

	GtkWidget *close_box = gtk_hbutton_box_new();
	gtk_container_add (GTK_CONTAINER (close_box), dialog->close_button);

	char *label_str = ygutils_mapKBAccel (_("&Find:"));
	GtkWidget *bottom_box, *label = gtk_label_new_with_mnemonic (label_str);
	g_free (label_str);
	gtk_misc_set_alignment (GTK_MISC (label), 0, .5);
	gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->search_entry);

	bottom_box = gtk_hbox_new (FALSE, 2);
	gtk_box_pack_start (GTK_BOX (bottom_box), label, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (bottom_box), dialog->search_entry, FALSE, FALSE, 0);
	gtk_box_pack_end (GTK_BOX (bottom_box), close_box, FALSE, FALSE, 0);

#ifdef SET_HELP_HISTORY
	dialog->history_combo = gtk_combo_box_new_text();
	GList *cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (dialog->history_combo));
	g_object_set (G_OBJECT (cells->data), "ellipsize", PANGO_ELLIPSIZE_END, NULL);
	g_list_free (cells);
#endif

	// glue it
	dialog->vbox = gtk_vbox_new (FALSE, 6);
#ifdef SET_HELP_HISTORY
	GtkWidget *hbox = gtk_hbox_new (FALSE, 6);
	gtk_box_pack_start (GTK_BOX (hbox), gtk_image_new_from_stock (GTK_STOCK_HELP, GTK_ICON_SIZE_BUTTON), FALSE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (hbox), dialog->history_combo, TRUE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (dialog->vbox), hbox, FALSE, TRUE, 0);
#endif
	gtk_box_pack_start (GTK_BOX (dialog->vbox), dialog->help_box, TRUE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (dialog->vbox), bottom_box, FALSE, TRUE, 0);
	gtk_container_add (GTK_CONTAINER (dialog), dialog->vbox);
	gtk_widget_show_all (dialog->vbox);

	g_signal_connect (G_OBJECT (dialog->close_button), "clicked",
	                  G_CALLBACK (close_button_clicked_cb), dialog);
	g_signal_connect (G_OBJECT (dialog), "delete-event",
	                  G_CALLBACK (gtk_widget_hide_on_delete), NULL);
}
Beispiel #10
0
int
main (int argc, char **argv)
{
  GtkWidget *window;
  GtkWidget *table;
  GtkWidget *label;
  GtkWidget *entry;
  GtkWidget *button;
  GIcon *icon;
  GtkTargetList *tlist;

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "Gtk Entry Icons Test");
  gtk_container_set_border_width (GTK_CONTAINER (window), 12);

  g_signal_connect (G_OBJECT (window), "destroy",
		    G_CALLBACK (gtk_main_quit), NULL);

  table = gtk_table_new (2, 4, FALSE);
  gtk_container_add (GTK_CONTAINER (window), table);
  gtk_table_set_row_spacings (GTK_TABLE (table), 6);
  gtk_table_set_col_spacings (GTK_TABLE (table), 6);

  /*
   * Open File - Sets the icon using a GIcon
   */
  label = gtk_label_new ("Open File:");
  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
		    GTK_FILL, GTK_FILL, 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);

  entry = gtk_entry_new ();
  gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 0, 1,
		    GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);

  icon = g_themed_icon_new ("folder");
  g_themed_icon_append_name (G_THEMED_ICON (icon), "gtk-directory");

  gtk_entry_set_icon_from_gicon (GTK_ENTRY (entry),
				 GTK_ENTRY_ICON_PRIMARY,
				 icon);
  gtk_entry_set_icon_sensitive (GTK_ENTRY (entry),
			        GTK_ENTRY_ICON_PRIMARY,
				FALSE);

  gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
				   GTK_ENTRY_ICON_PRIMARY,
				   "Open a file");

  button = gtk_button_new_with_label ("Properties");
  gtk_table_attach (GTK_TABLE (table), button, 2, 3, 0, 1,
		    GTK_FILL, GTK_FILL, 0, 0);
  g_signal_connect (button, "clicked", 
                    G_CALLBACK (properties_cb), entry);                    

  
  /*
   * Save File - sets the icon using a stock id.
   */
  label = gtk_label_new ("Save File:");
  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
		    GTK_FILL, GTK_FILL, 0, 0);
  gtk_misc_set_alignment (GTK_MISC(label), 0.0, 0.5);

  entry = gtk_entry_new ();
  gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 1, 2,
		    GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
  gtk_entry_set_text (GTK_ENTRY (entry), "‏Right-to-left");
  gtk_widget_set_direction (entry, GTK_TEXT_DIR_RTL);
  
  gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
				 GTK_ENTRY_ICON_PRIMARY,
				 GTK_STOCK_SAVE);
  gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
				   GTK_ENTRY_ICON_PRIMARY,
				   "Save a file");
  tlist = gtk_target_list_new (NULL, 0);
  gtk_target_list_add_text_targets (tlist, 0);
  gtk_entry_set_icon_drag_source (GTK_ENTRY (entry),
                                  GTK_ENTRY_ICON_PRIMARY,
                                  tlist, GDK_ACTION_COPY); 
  g_signal_connect_after (entry, "drag-begin", 
                          G_CALLBACK (drag_begin_cb), NULL);
  g_signal_connect (entry, "drag-data-get", 
                    G_CALLBACK (drag_data_get_cb), NULL);
  gtk_target_list_unref (tlist);

  button = gtk_button_new_with_label ("Properties");
  gtk_table_attach (GTK_TABLE (table), button, 2, 3, 1, 2,
		    GTK_FILL, GTK_FILL, 0, 0);
  g_signal_connect (button, "clicked", 
                    G_CALLBACK (properties_cb), entry);                    

  /*
   * Search - Uses a helper function
   */
  label = gtk_label_new ("Search:");
  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
		    GTK_FILL, GTK_FILL, 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);

  entry = gtk_entry_new ();
  gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 2, 3,
		    GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);

  gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
				 GTK_ENTRY_ICON_PRIMARY,
				 GTK_STOCK_FIND);

  gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
				 GTK_ENTRY_ICON_SECONDARY,
				 GTK_STOCK_CLEAR);

  g_signal_connect (entry, "icon-press", G_CALLBACK (clear_pressed), NULL);

  button = gtk_button_new_with_label ("Properties");
  gtk_table_attach (GTK_TABLE (table), button, 2, 3, 2, 3,
		    GTK_FILL, GTK_FILL, 0, 0);
  g_signal_connect (button, "clicked", 
                    G_CALLBACK (properties_cb), entry);                    

  /*
   * Password - Sets the icon using a stock id
   */
  label = gtk_label_new ("Password:"******"Properties");
  gtk_table_attach (GTK_TABLE (table), button, 2, 3, 3, 4,
		    GTK_FILL, GTK_FILL, 0, 0);
  g_signal_connect (button, "clicked", 
                    G_CALLBACK (properties_cb), entry);                    

  /* Name - Does not set any icons. */
  label = gtk_label_new ("Name:");
  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 4, 5,
		    GTK_FILL, GTK_FILL, 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);

  entry = gtk_entry_new ();
  gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 4, 5,
		    GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);

  button = gtk_button_new_with_label ("Properties");
  gtk_table_attach (GTK_TABLE (table), button, 2, 3, 4, 5,
		    GTK_FILL, GTK_FILL, 0, 0);
  g_signal_connect (button, "clicked", 
                    G_CALLBACK (properties_cb), entry);                    

  gtk_widget_show_all (window);

  gtk_main();

  return 0;
}
Beispiel #11
0
static void
egg_find_bar_init (EggFindBar *find_bar)
{
  EggFindBarPrivate *priv;
  GtkWidget *label;
  GtkWidget *alignment;
  GtkWidget *box;
  GtkToolItem *item;
  GtkWidget *arrow;

  /* Data */
  priv = EGG_FIND_BAR_GET_PRIVATE (find_bar);
  
  find_bar->priv = priv;  
  priv->search_string = NULL;

  gtk_toolbar_set_style (GTK_TOOLBAR (find_bar), GTK_TOOLBAR_BOTH_HORIZ);

  /* Find: |_____| */
  item = gtk_tool_item_new ();
  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
  
  alignment = gtk_alignment_new (0.0, 0.5, 1.0, 0.0);
  gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 2, 2);

  label = gtk_label_new_with_mnemonic (_("Find:"));

  priv->find_entry = gtk_entry_new ();
  gtk_entry_set_width_chars (GTK_ENTRY (priv->find_entry), 32);
  gtk_entry_set_max_length (GTK_ENTRY (priv->find_entry), 512);
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), priv->find_entry);

  /* Find options */
  gtk_entry_set_icon_from_stock (GTK_ENTRY (priv->find_entry),
                                 GTK_ENTRY_ICON_PRIMARY,
                                 GTK_STOCK_FIND);
  gtk_entry_set_icon_activatable (GTK_ENTRY (priv->find_entry),
                                  GTK_ENTRY_ICON_PRIMARY,
                                  TRUE);
  gtk_entry_set_icon_tooltip_text (GTK_ENTRY (priv->find_entry),
                                   GTK_ENTRY_ICON_PRIMARY,
                                   _("Find options"));

  /* Prev */
  arrow = gtk_arrow_new (GTK_ARROW_LEFT, GTK_SHADOW_NONE);
  priv->previous_button = gtk_tool_button_new (arrow, Q_("Find Pre_vious"));
  gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (priv->previous_button), TRUE);
  gtk_tool_item_set_is_important (priv->previous_button, TRUE);
  gtk_widget_set_tooltip_text (GTK_WIDGET (priv->previous_button),
			       _("Find previous occurrence of the search string"));

  /* Next */
  arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
  priv->next_button = gtk_tool_button_new (arrow, Q_("Find Ne_xt"));
  gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (priv->next_button), TRUE);
  gtk_tool_item_set_is_important (priv->next_button, TRUE);
  gtk_widget_set_tooltip_text (GTK_WIDGET (priv->next_button),
			       _("Find next occurrence of the search string"));

  /* Separator*/
  priv->status_separator = gtk_separator_tool_item_new();

  /* Status */
  priv->status_item = gtk_tool_item_new();
  gtk_tool_item_set_expand (priv->status_item, TRUE);
  priv->status_label = gtk_label_new (NULL);
  gtk_label_set_ellipsize (GTK_LABEL (priv->status_label),
                           PANGO_ELLIPSIZE_END);
  gtk_misc_set_alignment (GTK_MISC (priv->status_label), 0.0, 0.5);


  g_signal_connect (priv->find_entry, "changed",
                    G_CALLBACK (entry_changed_callback),
                    find_bar);
  g_signal_connect (priv->find_entry, "activate",
                    G_CALLBACK (entry_activate_callback),
                    find_bar);
  g_signal_connect (priv->find_entry, "icon-release",
                    G_CALLBACK (entry_icon_release_callback),
                    find_bar);
  g_signal_connect (priv->find_entry, "populate-popup",
                    G_CALLBACK (entry_populate_popup_callback),
                    find_bar);
  g_signal_connect (priv->next_button, "clicked",
                    G_CALLBACK (next_clicked_callback),
                    find_bar);
  g_signal_connect (priv->previous_button, "clicked",
                    G_CALLBACK (previous_clicked_callback),
                    find_bar);

  gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
  gtk_box_pack_start (GTK_BOX (box), priv->find_entry, TRUE, TRUE, 0);
  gtk_container_add (GTK_CONTAINER (alignment), box);
  gtk_container_add (GTK_CONTAINER (item), alignment);
  gtk_toolbar_insert (GTK_TOOLBAR (find_bar), item, -1);
  gtk_toolbar_insert (GTK_TOOLBAR (find_bar), priv->previous_button, -1);
  gtk_toolbar_insert (GTK_TOOLBAR (find_bar), priv->next_button, -1);
  gtk_toolbar_insert (GTK_TOOLBAR (find_bar), priv->status_separator, -1);
  gtk_container_add  (GTK_CONTAINER (priv->status_item), priv->status_label);
  gtk_toolbar_insert (GTK_TOOLBAR (find_bar), priv->status_item, -1);

  /* don't show status separator/label until they are set */

  gtk_widget_show_all (GTK_WIDGET (item));
  gtk_widget_show_all (GTK_WIDGET (priv->next_button));
  gtk_widget_show_all (GTK_WIDGET (priv->previous_button));
  gtk_widget_show (priv->status_label);
}
static GtkWidget *cd_build_events_widget (void)
{
	GtkWidget *pMainBox = gtk_box_new (GTK_ORIENTATION_VERTICAL, MARGIN);
	
	// category toolbar.
	GtkWidget *pToolBar = gtk_toolbar_new ();
	///gtk_toolbar_set_orientation (GTK_TOOLBAR (pToolBar), GTK_ORIENTATION_HORIZONTAL);
	gtk_toolbar_set_style (GTK_TOOLBAR (pToolBar), GTK_TOOLBAR_BOTH);  // overwrite system preference (GTK_TOOLBAR_ICONS)

	gtk_style_context_add_class (gtk_widget_get_style_context (pToolBar),
		GTK_STYLE_CLASS_INLINE_TOOLBAR); // style: inline
	GtkCssProvider *css = gtk_css_provider_new (); // but without border
	gtk_css_provider_load_from_data (css, ".inline-toolbar.toolbar { "
		"background: transparent; border-color: transparent; }", -1, NULL);
	GtkStyleContext *ctx = gtk_widget_get_style_context (pToolBar);
	gtk_style_context_add_provider (ctx, GTK_STYLE_PROVIDER (css),
		GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);

	gtk_toolbar_set_show_arrow (GTK_TOOLBAR (pToolBar), FALSE);  // force to display all the entries.
	gtk_box_pack_start (GTK_BOX (pMainBox), pToolBar, TRUE, TRUE, MARGIN);
	
	int i = 0;
	GtkToolItem *group = _add_category_button (pToolBar, D_("All"), "stock_search", i++, NULL);
	_add_category_button (pToolBar, D_("Applications"), "exec", i++, group);
	_add_category_button (pToolBar, D_("Documents"), "document", i++, group);
	///_add_category_button (pToolBar, D_("Folders"), "folder", i++, group);
	_add_category_button (pToolBar, D_("Images"), "image", i++, group);
	_add_category_button (pToolBar, D_("Audio"), "sound", i++, group);
	_add_category_button (pToolBar, D_("Videos"), "video", i++, group);
	_add_category_button (pToolBar, D_("Web"), "text-html", i++, group);
	_add_category_button (pToolBar, D_("Others"), "unknown", i++, group);
	_add_category_button (pToolBar, D_("Top Results"), "gtk-about", i, group);
	
	// search entry.
	GtkWidget *pFilterBox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, CAIRO_DOCK_GUI_MARGIN);
	gtk_box_pack_start (GTK_BOX (pMainBox), pFilterBox, FALSE, FALSE, MARGIN);
	
	GtkWidget *pFilterLabel = gtk_label_new (D_("Look for events"));
	gldi_dialog_set_widget_text_color (GTK_WIDGET (pFilterLabel));
	gtk_box_pack_start (GTK_BOX (pFilterBox), pFilterLabel, FALSE, FALSE, MARGIN);
	
	GtkWidget *pEntry = gtk_entry_new ();
	// press any key:
	g_signal_connect (pEntry, "key-release-event", G_CALLBACK (on_key_press_filter), NULL);
	gtk_box_pack_start (GTK_BOX (pFilterBox), pEntry, TRUE, TRUE, MARGIN);
	gtk_widget_set_tooltip_text (pEntry, D_("The default boolean operator is AND. Thus the query foo bar will be interpreted as foo AND bar. To exclude a term from the result set prepend it with a minus sign - eg foo -bar. Phrase queries can be done by double quoting the string \"foo is a bar\". You can truncate terms by appending a *. "));

	gtk_entry_set_icon_activatable (GTK_ENTRY (pEntry), GTK_ENTRY_ICON_SECONDARY, TRUE);
	gtk_entry_set_icon_from_icon_name (GTK_ENTRY (pEntry), GTK_ENTRY_ICON_SECONDARY, GLDI_ICON_NAME_CLEAR);
	g_signal_connect (pEntry, "icon-press", G_CALLBACK (on_clear_filter), NULL);

	myData.pEntry = pEntry;
	gtk_widget_grab_focus (pEntry);
	
	// model
	GtkListStore *pModel = gtk_list_store_new (CD_MODEL_NB_COLUMNS,
		G_TYPE_STRING,  /* CD_MODEL_NAME */
		G_TYPE_STRING,  /* CD_MODEL_URI */
		G_TYPE_STRING,  /* CD_MODEL_PATH */
		GDK_TYPE_PIXBUF,  /* CD_MODEL_ICON */
		G_TYPE_INT64,  /* CD_MODEL_DATE */
		G_TYPE_UINT);  /* CD_MODEL_ID */
	myData.pModel = pModel;
	
	// tree-view
	GtkWidget *pOneWidget = gtk_tree_view_new ();
	gtk_tree_view_set_model (GTK_TREE_VIEW (pOneWidget), GTK_TREE_MODEL (pModel));
	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (pOneWidget), TRUE);
	gtk_tree_view_set_headers_clickable (GTK_TREE_VIEW (pOneWidget), TRUE);
	GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (pOneWidget));
	gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
	/**gtk_tree_selection_set_select_function (selection,
		(GtkTreeSelectionFunc) _cairo_dock_select_one_item_in_tree,
		NULL,
		NULL);*/
	g_signal_connect (G_OBJECT (pOneWidget), "button-release-event", G_CALLBACK (_on_click_module_tree_view), NULL);  // pour le menu du clic droit
	g_signal_connect (G_OBJECT (pOneWidget), "button-press-event", G_CALLBACK (_on_click_module_tree_view), NULL);  // pour le menu du clic droit
	
	g_object_set (G_OBJECT (pOneWidget), "tooltip-column", CD_MODEL_PATH, NULL);
	
	GtkTreeViewColumn* col;
	GtkCellRenderer *rend;
	// icon
	rend = gtk_cell_renderer_pixbuf_new ();
	gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (pOneWidget), -1, NULL, rend, "pixbuf", CD_MODEL_ICON, NULL);
	// file name
	rend = gtk_cell_renderer_text_new ();
	col = gtk_tree_view_column_new_with_attributes (D_("File name"), rend, "text", CD_MODEL_NAME, NULL);
	gtk_tree_view_column_set_min_width (col, 200);
	gtk_tree_view_column_set_max_width (col, MAX (500, g_desktopGeometry.Xscreen.width / g_desktopGeometry.iNbScreens * .67));  // we don't know on which screen is place the container...
	gtk_tree_view_column_set_sort_column_id (col, CD_MODEL_NAME);
	gtk_tree_view_append_column (GTK_TREE_VIEW (pOneWidget), col);
	// date
	rend = gtk_cell_renderer_text_new ();
	col = gtk_tree_view_column_new_with_attributes (D_("Last access"), rend, "text", CD_MODEL_DATE, NULL);
	gtk_tree_view_column_set_cell_data_func (col, rend, (GtkTreeCellDataFunc)_render_date, NULL, NULL);
	gtk_tree_view_column_set_sort_column_id (col, CD_MODEL_DATE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (pOneWidget), col);
	
	// barres de defilement
	GtkAdjustment *adj = gtk_adjustment_new (0., 0., 100., 1, 10, 10);
	gtk_scrollable_set_vadjustment (GTK_SCROLLABLE (pOneWidget), GTK_ADJUSTMENT (adj));

	GtkWidget *pScrolledWindow = gtk_scrolled_window_new (NULL, NULL);
	g_object_set (pScrolledWindow, "height-request", 300, NULL);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (pScrolledWindow), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
	#if GTK_CHECK_VERSION (3, 8, 0)
	gtk_container_add (GTK_CONTAINER (pScrolledWindow), pOneWidget);
	#else
	gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (pScrolledWindow), pOneWidget);
	#endif
	gtk_box_pack_start (GTK_BOX (pMainBox), pScrolledWindow, FALSE, FALSE, MARGIN);

	return pMainBox;
}
static void
empathy_presence_chooser_init (EmpathyPresenceChooser *chooser)
{
	EmpathyPresenceChooserPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (chooser,
		EMPATHY_TYPE_PRESENCE_CHOOSER, EmpathyPresenceChooserPriv);
	GtkWidget *entry;
	GtkCellRenderer *renderer;

	chooser->priv = priv;

	presence_chooser_create_model (chooser);

	gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (chooser),
					     COL_STATUS_TEXT);
	gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (chooser),
					      combo_row_separator_func,
					      NULL, NULL);

	entry = gtk_bin_get_child (GTK_BIN (chooser));
	gtk_entry_set_icon_activatable (GTK_ENTRY (entry),
					GTK_ENTRY_ICON_PRIMARY,
					FALSE);

	g_signal_connect_swapped (entry, "icon-release",
		G_CALLBACK (presence_chooser_entry_icon_release_cb),
		chooser);
	g_signal_connect_swapped (entry, "activate",
		G_CALLBACK (presence_chooser_entry_activate_cb),
		chooser);
	g_signal_connect_swapped (entry, "key-press-event",
		G_CALLBACK (presence_chooser_entry_key_press_event_cb),
		chooser);
	g_signal_connect_swapped (entry, "button-press-event",
		G_CALLBACK (presence_chooser_entry_button_press_event_cb),
		chooser);

	gtk_cell_layout_clear (GTK_CELL_LAYOUT (chooser));

	renderer = gtk_cell_renderer_pixbuf_new ();
	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (chooser), renderer, FALSE);
	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (chooser), renderer,
					"icon-name", COL_STATE_ICON_NAME,
					NULL);
	g_object_set (renderer, "stock-size", GTK_ICON_SIZE_MENU, NULL);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (chooser), renderer, TRUE);
	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (chooser), renderer,
					"markup", COL_DISPLAY_MARKUP,
					NULL);

	g_signal_connect (chooser, "notify::popup-shown",
			G_CALLBACK (presence_chooser_popup_shown_cb), NULL);
	g_signal_connect (chooser, "changed",
			G_CALLBACK (presence_chooser_changed_cb), NULL);
	g_signal_connect_swapped (entry, "changed",
			G_CALLBACK (presence_chooser_entry_changed_cb),
			chooser);
	g_signal_connect_swapped (entry, "focus-out-event",
			G_CALLBACK (presence_chooser_entry_focus_out_cb),
			chooser);

	priv->idle = empathy_idle_dup_singleton ();
	presence_chooser_presence_changed_cb (chooser);
	g_signal_connect_swapped (priv->idle, "notify",
		G_CALLBACK (presence_chooser_presence_changed_cb),
		chooser);

	/* FIXME: this string sucks */
	gtk_widget_set_tooltip_text (GTK_WIDGET (chooser),
		_("Set your presence and current status"));
}
Beispiel #14
0
static void browser_window_init(BrowserWindow *window)
{
    g_atomic_int_inc(&windowCount);
    
    gchar img_src_dir[BUFSIZE] = {0};
    strcat(img_src_dir, get_cuprum_dir());
    
    gchar img_source_1[BUFSIZE] = {0};
    strcat(img_source_1, img_src_dir);
    strcat(img_source_1, "/resources/img/1.png");
    
    gchar img_source_2[BUFSIZE] = {0};
    strcat(img_source_2, img_src_dir);
    strcat(img_source_2, "/resources/img/2.png");

    gtk_window_set_title(GTK_WINDOW(window), defaultWindowTitle);
    gtk_window_set_default_size(GTK_WINDOW(window), 1000, 750);

    window->uriEntry = gtk_entry_new();
    g_signal_connect_swapped(window->uriEntry, "activate", G_CALLBACK(activateUriEntryCallback), (gpointer)window);
    gtk_entry_set_icon_activatable(GTK_ENTRY(window->uriEntry), GTK_ENTRY_ICON_PRIMARY, FALSE);
    g_signal_connect_swapped (G_OBJECT(window->uriEntry), "icon-press", G_CALLBACK(certificateCallback), window);
    updateUriEntryIcon(window);

    /* Keyboard accelerators */
    window->accelGroup = gtk_accel_group_new();
    gtk_window_add_accel_group(GTK_WINDOW(window), window->accelGroup);

    /* Global accelerators */
    gtk_accel_group_connect(window->accelGroup, GDK_KEY_I, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE,
        g_cclosure_new_swap(G_CALLBACK(toggleWebInspector), window, NULL));
    gtk_accel_group_connect(window->accelGroup, GDK_KEY_F12, 0, GTK_ACCEL_VISIBLE,
        g_cclosure_new_swap(G_CALLBACK(toggleWebInspector), window, NULL));
    gtk_accel_group_connect(window->accelGroup, GDK_KEY_F11, 0, GTK_ACCEL_VISIBLE,
        g_cclosure_new_swap(G_CALLBACK(showFullscreen), window, NULL));

    /* Reload page */ 
    gtk_accel_group_connect(window->accelGroup, GDK_KEY_F5, 0, GTK_ACCEL_VISIBLE,
        g_cclosure_new_swap(G_CALLBACK(reloadPage), window, NULL));
    gtk_accel_group_connect(window->accelGroup, GDK_KEY_R, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE,
        g_cclosure_new_swap(G_CALLBACK(reloadPage), window, NULL));

    /* Reload page ignoring cache */
    gtk_accel_group_connect(window->accelGroup, GDK_KEY_F5, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE,
        g_cclosure_new_swap(G_CALLBACK(reloadPageIgnoringCache), window, NULL));
    gtk_accel_group_connect(window->accelGroup, GDK_KEY_R, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE,
        g_cclosure_new_swap(G_CALLBACK(reloadPageIgnoringCache), window, NULL));
        
    //add by zgh menu
    window->menubar = BROWSER_MENU_BAR(browser_menu_bar_new());
    browser_menu_bar_add_accelerators(BROWSER_MENU_BAR(window->menubar), window->accelGroup);
    g_signal_connect_swapped(G_OBJECT(window->menubar), "menu_find", G_CALLBACK(menuSearchCallback), window);
    g_signal_connect_swapped(G_OBJECT(window->menubar), "menu_zoom_in", G_CALLBACK(zoomInCallback), window);
    g_signal_connect_swapped(G_OBJECT(window->menubar), "menu_zoom_out", G_CALLBACK(zoomOutCallback), window);
    g_signal_connect_swapped(G_OBJECT(window->menubar), "menu_zoom_fit", G_CALLBACK(zoomFitCallback), window);
//    g_signal_connect_swapped(G_OBJECT(window->menubar), "menu_nopagestyle", G_CALLBACK(menuNopagestyleCallback), window);
//    g_signal_connect_swapped(G_OBJECT(window->menubar), "menu_webpagestyle", G_CALLBACK(menuWebpagestyleCallback), window);
    g_signal_connect_swapped(G_OBJECT(window->menubar), "menu_fullscreen", G_CALLBACK(showFullscreen), window);
    g_signal_connect_swapped(G_OBJECT(window->menubar), "menu_bookmarkbar", G_CALLBACK(showBookmarkbar), window);
    g_signal_connect_swapped(G_OBJECT(window->menubar), "menu_history_manager", G_CALLBACK(showHistoryManagerWindow), window);//add by zlf
    g_signal_connect_swapped(G_OBJECT(window->menubar), "menu_history_clear", G_CALLBACK(showHistoryClearWindow), window);//add by zlf
    g_signal_connect(G_OBJECT(window->menubar), "menu_quit", G_CALLBACK(gtk_main_quit), window);
//    gtk_container_set_border_width(GTK_CONTAINER(window->menubar), 0);
    g_signal_connect(G_OBJECT(window->menubar), "button-press-event", G_CALLBACK(buttonmenuCallback), window);

    GtkWidget *toolbar = gtk_toolbar_new();
    window->toolbar = toolbar;
    gtk_orientable_set_orientation(GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL);
    gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);
//    gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH_HORIZ);
    gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar), GTK_ICON_SIZE_SMALL_TOOLBAR);
    gtk_container_set_border_width(GTK_CONTAINER(window->toolbar), 0);
    g_signal_connect(G_OBJECT(toolbar), "button-press-event", G_CALLBACK(buttonmenuCallback), window);

    GtkToolItem *item = gtk_menu_tool_button_new_from_stock(GTK_STOCK_GO_BACK);
    window->backItem = GTK_WIDGET(item);
    gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(item), 0);
    g_signal_connect_swapped(item, "clicked", G_CALLBACK(goBackCallback), (gpointer)window);
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1);
    gtk_widget_show(GTK_WIDGET(item));

    item = gtk_menu_tool_button_new_from_stock(GTK_STOCK_GO_FORWARD);
    window->forwardItem = GTK_WIDGET(item);
    gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(item), 0);
    g_signal_connect_swapped(G_OBJECT(item), "clicked", G_CALLBACK(goForwardCallback), (gpointer)window);
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1);
    gtk_widget_show(GTK_WIDGET(item));

    item = gtk_tool_button_new_from_stock(GTK_STOCK_REFRESH);
    window->reloadOrStopButton = GTK_WIDGET(item);
    g_signal_connect_swapped(item, "clicked", G_CALLBACK(reloadOrStopCallback), window);
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1);
    gtk_widget_add_accelerator(window->reloadOrStopButton, "clicked", window->accelGroup, GDK_KEY_F5, 0, GTK_ACCEL_VISIBLE);
    gtk_widget_show(window->reloadOrStopButton);
    
    item = gtk_tool_button_new_from_stock(GTK_STOCK_HOME);
    window->homeButton = GTK_WIDGET(item);
    g_signal_connect_swapped(item, "clicked", G_CALLBACK(homeButtonCallback), window);
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1);
    gtk_widget_show(window->homeButton);
    
    gtk_entry_set_icon_from_pixbuf(GTK_ENTRY(window->uriEntry), GTK_ENTRY_ICON_SECONDARY, create_pixbuf(img_source_1));
    gtk_entry_set_icon_activatable(GTK_ENTRY(window->uriEntry), GTK_ENTRY_ICON_PRIMARY, TRUE);
    gtk_entry_set_icon_tooltip_markup(GTK_ENTRY(window->uriEntry), GTK_ENTRY_ICON_SECONDARY, "将此页加为书签");
    g_signal_connect_swapped (G_OBJECT(window->uriEntry), "icon-press", G_CALLBACK(collecturiCallback), window);
    
        //by sunh  
		item = gtk_tool_button_new_from_stock(GTK_STOCK_GOTO_BOTTOM);
		g_signal_connect_swapped(G_OBJECT(item), "clicked", G_CALLBACK(downloadCallback), window);
		gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1);
		gtk_widget_show(GTK_WIDGET(item));
		//by sunh end

    item = gtk_tool_item_new();
    gtk_tool_item_set_expand(item, TRUE);
    gtk_container_add(GTK_CONTAINER(item), window->uriEntry);
    gtk_widget_show(window->uriEntry);
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1);
    gtk_widget_show(GTK_WIDGET(item));

    //setting
    item = gtk_tool_button_new_from_stock(GTK_STOCK_PREFERENCES);
    g_signal_connect_swapped(G_OBJECT(item), "clicked", G_CALLBACK(settingsCallback), window);
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1);
    gtk_widget_show(GTK_WIDGET(item));
    // -setting


    GtkWidget *vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
    window->mainBox = vbox;
    
    gtk_widget_show_all(GTK_WIDGET(window->menubar));
    gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(window->menubar), FALSE, FALSE, 0);

     //<wangc add tab mamager
    TabMng* tbmng=(TabMng*)malloc(sizeof(TabMng));
    initTabMng(tbmng);
    window->tabmng=tbmng;

    GtkWidget *boxtab = gtk_box_new (FALSE, 0);
    window->boxtab=boxtab;

    GtkWidget * btab = gtk_button_new_with_label ("Add");
    g_signal_connect (G_OBJECT (btab), "clicked",
            G_CALLBACK (cbAddTab), window);
    gtk_box_pack_start (GTK_BOX(boxtab), btab, FALSE, FALSE, 0);
    gtk_widget_show (btab);

    gtk_box_pack_start(GTK_BOX(vbox),boxtab,FALSE, FALSE, 0);
    gtk_widget_show(boxtab);
    //>

    gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
    gtk_widget_show(toolbar);
    
    //书签栏
    GtkWidget *bookmarkbar = gtk_toolbar_new();
    window->bookmarkbar = bookmarkbar;
    /*
    item =gtk_tool_item_new();
    gtk_tool_item_set_expand(item, TRUE);
    GtkWidget *bookmarkBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_container_add(GTK_CONTAINER(item), bookmarkBox);
    window->bookmarkbox = bookmarkBox;
    gtk_toolbar_insert(GTK_TOOLBAR(bookmarkbar), item, 0);
    gtk_widget_show(bookmarkBox);
    gtk_widget_show(GTK_WIDGET(item));
    */
    gtk_toolbar_set_icon_size (GTK_TOOLBAR (window->bookmarkbar),
                               GTK_ICON_SIZE_MENU);
    gtk_toolbar_set_style (GTK_TOOLBAR (window->bookmarkbar),
                           GTK_TOOLBAR_BOTH);//GTK_TOOLBAR_BOTH_HORIZ
    g_signal_connect(G_OBJECT(bookmarkbar), "button-press-event", G_CALLBACK(buttonmenuCallback), window);
    
    gtk_box_pack_start(GTK_BOX(vbox), bookmarkbar, FALSE, FALSE, 0);
//    gtk_widget_show(bookmarkbar);

/*
    GtkWidget *status_bar = gtk_label_new("");
    gtk_label_set_width_chars(GTK_LABEL(status_bar), 50);
    gtk_misc_set_alignment(GTK_MISC(status_bar), 0, 0);
    gtk_box_pack_end(GTK_BOX(vbox), status_bar, FALSE, FALSE, 0);
//    gtk_widget_show(status_bar);
*/
    gtk_container_add(GTK_CONTAINER(window), vbox);
    gtk_widget_show(vbox);
    HS_init(window);// add by zlf
}