/* static gboolean browserWindowCanZoomIn(BrowserWindow *window) { gdouble zoomLevel = webkit_web_view_get_zoom_level(window->webView) * zoomStep; return zoomLevel < maximumZoomLevel; } static gboolean browserWindowCanZoomOut(BrowserWindow *window) { gdouble zoomLevel = webkit_web_view_get_zoom_level(window->webView) / zoomStep; return zoomLevel > minimumZoomLevel; } static void browserWindowUpdateZoomActions(BrowserWindow *window) { gtk_widget_set_sensitive(window->zoomInItem, browserWindowCanZoomIn(window)); gtk_widget_set_sensitive(window->zoomOutItem, browserWindowCanZoomOut(window)); } static void webViewZoomLevelChanged(GObject *object, GParamSpec *paramSpec, BrowserWindow *window) { browserWindowUpdateZoomActions(window); } */ static void updateUriEntryIcon(BrowserWindow *window) { GtkEntry *entry = GTK_ENTRY(window->uriEntry); if (window->favicon) gtk_entry_set_icon_from_pixbuf(entry, GTK_ENTRY_ICON_PRIMARY, window->favicon); else gtk_entry_set_icon_from_stock(entry, GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_NEW); }
void clear_entry_validation_error (GtkEntry *entry) { gboolean warning; g_object_get (entry, "caps-lock-warning", &warning, NULL); if (warning) return; g_object_set (entry, "has-tooltip", FALSE, NULL); gtk_entry_set_icon_from_pixbuf (entry, GTK_ENTRY_ICON_SECONDARY, NULL); g_object_set (entry, "caps-lock-warning", TRUE, NULL); }
void nsgtk_entry_set_icon_from_pixbuf(GtkWidget *entry, GtkEntryIconPosition icon_pos, GdkPixbuf *pixbuf) { #if GTK_CHECK_VERSION(2,16,0) gtk_entry_set_icon_from_pixbuf(GTK_ENTRY(entry), icon_pos, pixbuf); #else GtkImage *image = GTK_IMAGE(gtk_image_new_from_pixbuf(pixbuf)); if (image != NULL) { sexy_icon_entry_set_icon(SEXY_ICON_ENTRY(entry), (SexyIconEntryPosition)icon_pos, image); g_object_unref(image); } #endif }
static gboolean gimp_combo_tag_entry_expose (GtkWidget *widget, GdkEventExpose *event) { GimpComboTagEntry *entry = GIMP_COMBO_TAG_ENTRY (widget); if (! entry->arrow_pixbuf) { GtkStyle *style = gtk_widget_get_style (widget); GdkPixmap *pixmap; cairo_t *cr; pixmap = gdk_pixmap_new (gtk_widget_get_window (widget), 8, 8, -1); cr = gdk_cairo_create (pixmap); gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_NORMAL]); cairo_paint (cr); cairo_destroy (cr); gtk_paint_arrow (style, pixmap, GTK_STATE_NORMAL, GTK_SHADOW_NONE, NULL, widget, NULL, GTK_ARROW_DOWN, TRUE, 0, 0, 8, 8); entry->arrow_pixbuf = gdk_pixbuf_get_from_drawable (NULL, pixmap, NULL, 0, 0, 0, 0, 8, 8); g_object_unref (pixmap); gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY, entry->arrow_pixbuf); } return GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); }
GtkWidget * entry_create_widget (GtkWidget * dlg) { GtkWidget *c, *l = NULL, *w = NULL; #if !GTK_CHECK_VERSION(3,0,0) w = gtk_hbox_new (FALSE, 5); #else w = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5); #endif if (options.entry_data.entry_label) { l = gtk_label_new (NULL); if (options.data.no_markup) gtk_label_set_text_with_mnemonic (GTK_LABEL (l), options.entry_data.entry_label); else gtk_label_set_markup_with_mnemonic (GTK_LABEL (l), options.entry_data.entry_label); gtk_widget_set_name (l, "yad-entry-label"); gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 1); } if (options.entry_data.numeric) { gdouble min, max, step, val; guint prec; min = 0.0; max = 65535.0; step = 1.0; prec = 0; if (options.extra_data && options.extra_data[0]) { min = g_ascii_strtod (options.extra_data[0], NULL); if (options.extra_data[1]) max = g_ascii_strtod (options.extra_data[1], NULL); if (options.extra_data[2]) step = g_ascii_strtod (options.extra_data[2], NULL); if (options.extra_data[3]) { prec = (guint) g_ascii_strtoull (options.extra_data[3], NULL, 0); if (prec > 20) prec = 20; } } c = entry = gtk_spin_button_new_with_range (min, max, step); gtk_entry_set_alignment (GTK_ENTRY (c), 1.0); gtk_spin_button_set_digits (GTK_SPIN_BUTTON (c), prec); gtk_widget_set_name (entry, "yad-entry-spin"); if (options.entry_data.entry_text) { val = g_ascii_strtod (options.entry_data.entry_text, NULL); if (min >= max) { g_printerr (_("Maximum value must be greater than minimum value.\n")); min = 0.0; max = 65535.0; } if (val < min) { g_printerr (_("Initial value less than minimal.\n")); val = min; } else if (val > max) { g_printerr (_("Initial value greater than maximum.\n")); val = max; } gtk_spin_button_set_value (GTK_SPIN_BUTTON (c), val); } } else if (!options.entry_data.completion && options.extra_data && *options.extra_data) { gint active, i; if (options.common_data.editable || settings.combo_always_editable) { #if GTK_CHECK_VERSION(2,24,0) c = gtk_combo_box_text_new_with_entry (); #else c = gtk_combo_box_entry_new_text (); #endif gtk_widget_set_name (c, "yad-entry-edit-combo"); entry = gtk_bin_get_child (GTK_BIN (c)); if (options.entry_data.licon) { GdkPixbuf *pb = get_pixbuf (options.entry_data.licon, YAD_SMALL_ICON); if (pb) gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, pb); } if (options.entry_data.ricon) { GdkPixbuf *pb = get_pixbuf (options.entry_data.ricon, YAD_SMALL_ICON); if (pb) gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY, pb); } } else { #if GTK_CHECK_VERSION(2,24,0) c = entry = gtk_combo_box_text_new (); #else c = entry = gtk_combo_box_new_text (); #endif gtk_widget_set_name (c, "yad-entry-combo"); is_combo = TRUE; } i = 0; active = -1; while (options.extra_data[i] != NULL) { if (options.entry_data.entry_text && g_ascii_strcasecmp (options.extra_data[i], options.entry_data.entry_text) == 0) active = i; #if GTK_CHECK_VERSION(2,24,0) gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (c), options.extra_data[i]); #else gtk_combo_box_append_text (GTK_COMBO_BOX (c), options.extra_data[i]); #endif i++; } if (options.entry_data.entry_text && active == -1) { #if GTK_CHECK_VERSION(2,24,0) gtk_combo_box_text_prepend_text (GTK_COMBO_BOX_TEXT (c), options.entry_data.entry_text); #else gtk_combo_box_prepend_text (GTK_COMBO_BOX (c), options.entry_data.entry_text); #endif } /* set first iter active */ if (!options.common_data.editable) gtk_combo_box_set_active (GTK_COMBO_BOX (c), (active != -1 ? active : 0)); } else { c = entry = gtk_entry_new (); gtk_widget_set_name (c, "yad-entry-widget"); gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE); if (options.entry_data.entry_text) gtk_entry_set_text (GTK_ENTRY (entry), options.entry_data.entry_text); if (options.entry_data.hide_text) g_object_set (G_OBJECT (entry), "visibility", FALSE, NULL); if (options.entry_data.completion) { GtkEntryCompletion *completion; GtkTreeModel *completion_model; completion = gtk_entry_completion_new (); gtk_entry_set_completion (GTK_ENTRY (entry), completion); completion_model = create_completion_model (); gtk_entry_completion_set_model (completion, completion_model); g_object_unref (completion_model); gtk_entry_completion_set_text_column (completion, 0); g_object_unref (completion); } if (options.entry_data.licon) { GdkPixbuf *pb = get_pixbuf (options.entry_data.licon, YAD_SMALL_ICON); if (pb) gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, pb); } if (options.entry_data.ricon) { GdkPixbuf *pb = get_pixbuf (options.entry_data.ricon, YAD_SMALL_ICON); if (pb) gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY, pb); } } if (l) gtk_label_set_mnemonic_widget (GTK_LABEL (l), entry); if (!is_combo) g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (entry_activate_cb), dlg); else g_signal_connect (G_OBJECT (entry), "key-press-event", G_CALLBACK (combo_activate_cb), dlg); if (options.entry_data.licon || options.entry_data.ricon) g_signal_connect (G_OBJECT (entry), "icon-press", G_CALLBACK (icon_cb), NULL); gtk_box_pack_start (GTK_BOX (w), c, TRUE, TRUE, 1); return w; }
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 }