void meta_draw_window_decoration (decor_t *d) { Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); cairo_surface_t *surface; Picture src; MetaButtonState button_states [META_BUTTON_TYPE_LAST]; MetaButtonLayout button_layout; MetaFrameGeometry fgeom; MetaFrameFlags flags; MetaFrameType frame_type; MetaTheme *theme; GtkStyleContext *context; cairo_t *cr; gint i; GdkRectangle clip; Region top_region = NULL; Region bottom_region = NULL; Region left_region = NULL; Region right_region = NULL; gdouble meta_active_opacity, meta_inactive_opacity; gboolean meta_active_shade_opacity, meta_inactive_shade_opacity; g_object_get (settings, "metacity-active-opacity", &meta_active_opacity, NULL); g_object_get (settings, "metacity-inactive-opacity", &meta_inactive_opacity, NULL); g_object_get (settings, "metacity-active-shade-opacity", &meta_active_shade_opacity, NULL); g_object_get (settings, "metacity-inactive-shade-opacity", &meta_inactive_shade_opacity, NULL); double alpha = (d->active) ? meta_active_opacity : meta_inactive_opacity; gboolean shade_alpha = (d->active) ? meta_active_shade_opacity : meta_inactive_shade_opacity; MetaFrameStyle *frame_style; GtkWidget *style_window; GdkRGBA bg_rgba; if (!d->surface || !d->picture) return; if (decoration_alpha == 1.0) alpha = 1.0; if (cairo_xlib_surface_get_depth (d->surface) == 32) { context = gtk_widget_get_style_context (d->frame->style_window_rgba); style_window = d->frame->style_window_rgba; } else { context = gtk_widget_get_style_context (d->frame->style_window_rgb); style_window = d->frame->style_window_rgb; } cr = cairo_create (d->buffer_surface ? d->buffer_surface : d->surface); cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); theme = meta_theme_get_current (); frame_type = meta_frame_type_from_string (d->frame->type); if (frame_type == META_FRAME_TYPE_LAST) frame_type = META_FRAME_TYPE_NORMAL; meta_get_decoration_geometry (d, theme, &flags, &fgeom, &button_layout, frame_type, &clip); if ((d->prop_xid || !d->buffer_surface) && !d->frame_window) draw_shadow_background (d, cr, d->shadow, d->context); for (i = 0; i < META_BUTTON_TYPE_LAST; ++i) button_states[i] = meta_button_state_for_button_type (d, i); frame_style = meta_theme_get_frame_style (theme, frame_type, flags); gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &bg_rgba); bg_rgba.alpha = 1.0; if (frame_style->window_background_color) { meta_color_spec_render (frame_style->window_background_color, gtk_widget_get_style_context (style_window), &bg_rgba); bg_rgba.alpha = frame_style->window_background_alpha / 255.0; } /* Draw something that will be almost invisible to user. This is hacky way * to fix invisible decorations. */ cairo_set_source_rgba (cr, 0, 0, 0, 0.01); cairo_rectangle (cr, 0, 0, 1, 1); cairo_fill (cr); /* ------------ */ cairo_destroy (cr); if (d->frame_window) surface = create_surface (clip.width, clip.height, d->frame->style_window_rgb); else surface = create_surface (clip.width, clip.height, d->frame->style_window_rgba); cr = cairo_create (surface); gdk_cairo_set_source_rgba (cr, &bg_rgba); cairo_set_operator (cr, CAIRO_OPERATOR_OVER); src = XRenderCreatePicture (xdisplay, cairo_xlib_surface_get_drawable (surface), get_format_for_surface (d, surface), 0, NULL); cairo_paint (cr); meta_theme_draw_frame (theme, style_window, cr, frame_type, flags, clip.width - fgeom.left_width - fgeom.right_width, clip.height - fgeom.top_height - fgeom.bottom_height, d->layout, d->frame->text_height, &button_layout, button_states, d->icon_pixbuf, NULL); if (fgeom.top_height) { top_region = meta_get_top_border_region (&fgeom, clip.width); decor_blend_border_picture (xdisplay, d->context, src, 0, 0, d->picture, &d->border_layout, BORDER_TOP, top_region, alpha * 0xffff, shade_alpha, 0); } if (fgeom.bottom_height) { bottom_region = meta_get_bottom_border_region (&fgeom, clip.width); decor_blend_border_picture (xdisplay, d->context, src, 0, clip.height - fgeom.bottom_height, d->picture, &d->border_layout, BORDER_BOTTOM, bottom_region, alpha * 0xffff, shade_alpha, 0); } if (fgeom.left_width) { left_region = meta_get_left_border_region (&fgeom, clip.height); decor_blend_border_picture (xdisplay, d->context, src, 0, fgeom.top_height, d->picture, &d->border_layout, BORDER_LEFT, left_region, alpha * 0xffff, shade_alpha, 0); } if (fgeom.right_width) { right_region = meta_get_right_border_region (&fgeom, clip.height); decor_blend_border_picture (xdisplay, d->context, src, clip.width - fgeom.right_width, fgeom.top_height, d->picture, &d->border_layout, BORDER_RIGHT, right_region, alpha * 0xffff, shade_alpha, 0); } cairo_destroy (cr); cairo_surface_destroy (surface); XRenderFreePicture (xdisplay, src); copy_to_front_buffer (d); if (d->frame_window) { GdkWindow *gdk_frame_window = gtk_widget_get_window (d->decor_window); GdkPixbuf *pixbuf = gdk_pixbuf_get_from_surface (d->surface, 0, 0, d->width, d->height); gtk_image_set_from_pixbuf (GTK_IMAGE (d->decor_image), pixbuf); g_object_unref (pixbuf); gtk_window_resize (GTK_WINDOW (d->decor_window), d->width, d->height); gdk_window_move (gdk_frame_window, d->context->left_corner_space - 1, d->context->top_corner_space - 1); gdk_window_lower (gdk_frame_window); } if (d->prop_xid) { /* translate from frame to client window space */ if (top_region) XOffsetRegion (top_region, -fgeom.left_width, -fgeom.top_height); if (bottom_region) XOffsetRegion (bottom_region, -fgeom.left_width, 0); if (left_region) XOffsetRegion (left_region, -fgeom.left_width, 0); decor_update_meta_window_property (d, theme, flags, top_region, bottom_region, left_region, right_region); d->prop_xid = 0; } if (top_region) XDestroyRegion (top_region); if (bottom_region) XDestroyRegion (bottom_region); if (left_region) XDestroyRegion (left_region); if (right_region) XDestroyRegion (right_region); }
/** * \brief Get a widget showing one icon with another overlaid on top of it. * * The base icon is always centralised, the other icon can be positioned. * The overlay icon is ignored if pos=OVERLAY_NONE is used * * \param window top-level window widget * \param icon the base icon * \param overlay the icon to overlay * \param pos how to align the overlay widget, or OVERLAY_NONE for no overlay * \param border_x size of the border around the base icon (left and right) * \param border_y size of the border around the base icon (top and bottom) */ GtkWidget *stock_pixmap_widget_with_overlay(GtkWidget *window, StockPixmap icon, StockPixmap overlay, OverlayPosition pos, gint border_x, gint border_y) { cairo_surface_t *stock_pixmap = NULL; GdkPixbuf *stock_pixbuf = NULL; GtkWidget *widget = NULL; GtkWidget *stock_wid = NULL; GtkRequisition requisition; OverlayData *data = NULL; data = g_new0(OverlayData, 1); stock_wid = stock_pixmap_widget(window, icon); gtk_widget_get_requisition(stock_wid, &requisition); #if !GTK_CHECK_VERSION(3, 0, 0) if (gtk_image_get_storage_type(GTK_IMAGE(stock_wid)) == GTK_IMAGE_PIXMAP) data->is_pixmap = TRUE; else #endif data->is_pixmap = FALSE; if (data->is_pixmap) { cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(stock_wid)); stock_pixmap = cairo_get_target(cr); cairo_surface_reference(stock_pixmap); cairo_destroy(cr); data->base_pixmap = stock_pixmap; data->base_height = requisition.height; data->base_width = requisition.width; gtk_widget_destroy(stock_wid); if (pos == OVERLAY_NONE) { data->overlay_pixmap = NULL; } else { stock_wid = stock_pixmap_widget(window, overlay); cr = gdk_cairo_create(gtk_widget_get_window(stock_wid)); stock_pixmap = cairo_get_target(cr); cairo_surface_reference(stock_pixmap); cairo_destroy(cr); data->overlay_pixmap = stock_pixmap; data->overlay_height = requisition.height; data->overlay_width = requisition.width; gtk_widget_destroy(stock_wid); } } else { data->is_pixmap = FALSE; stock_pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(stock_wid)); g_object_ref(stock_pixbuf); data->base_pixbuf = stock_pixbuf; data->base_height = requisition.height; data->base_width = requisition.width; gtk_widget_destroy(stock_wid); if (pos == OVERLAY_NONE) { data->overlay_pixmap = NULL; } else { stock_wid = stock_pixmap_widget(window, overlay); stock_pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(stock_wid)); g_object_ref(stock_pixbuf); data->overlay_pixbuf = stock_pixbuf; data->overlay_height = requisition.height; data->overlay_width = requisition.width; gtk_widget_destroy(stock_wid); } } data->position = pos; data->border_x = border_x; data->border_y = border_y; data->highlight = FALSE; widget = gtk_drawing_area_new(); gtk_widget_set_size_request(widget, data->base_width + border_x * 2, data->base_height + border_y * 2); #if !GTK_CHECK_VERSION(3, 0, 0) g_signal_connect(G_OBJECT(widget), "expose_event", G_CALLBACK(pixmap_with_overlay_expose_event_cb), data); #else g_signal_connect(G_OBJECT(widget), "draw", G_CALLBACK(pixmap_with_overlay_expose_event_cb), data); #endif g_signal_connect(G_OBJECT(widget), "destroy", G_CALLBACK(pixmap_with_overlay_destroy_cb), data); g_object_set_data(G_OBJECT(widget), "highlight", &(data->highlight)); return widget; }
static GtkWidget* create_test2_window (void) { GtkWidget *window; GtkImage *imageClient, *imageWellth, *imageTest, *imageBG; // GtkWidget *timer_label; GError** error = NULL; /* Load UI from file */ /* Auto-connect signal handlers */ gtk_builder_connect_signals (Test2Builder, NULL); /* Get the window object from the ui file */ window = GTK_WIDGET (gtk_builder_get_object (Test2Builder, TEST2_WINDOW)); if (!window) { g_critical ("Widget \"%s\" is missing in file %s.", TEST2_WINDOW, TEST2_UI_FILE); } GdkPixbufAnimation * pixbufclntanm = gdk_pixbuf_animation_new_from_file(CLIENT_LOGO, error); GdkPixbufAnimation * pixbufwlthanm = gdk_pixbuf_animation_new_from_file(WELLTH_LOGO, error); imageClient = (GtkImage *) GTK_WIDGET (gtk_builder_get_object (Test2Builder, "clnt_logo")); imageWellth = (GtkImage *) GTK_WIDGET (gtk_builder_get_object (Test2Builder, "wellth_logo")); gtk_image_set_from_animation(GTK_IMAGE(imageClient), pixbufclntanm); gtk_image_set_from_animation (GTK_IMAGE(imageWellth), pixbufwlthanm); //GdkPixbufAnimation * pixbufBGanm = gdk_pixbuf_animation_new_from_file(BG, error); imageBG = (GtkImage *) GTK_WIDGET (gtk_builder_get_object (Test2Builder, "image1")); gtk_image_set_from_animation(GTK_IMAGE(imageBG), pixbufBGanm); GdkPixbufAnimation * pixbufTestanm = gdk_pixbuf_animation_new_from_file(TEST2, error); imageTest = (GtkImage *) GTK_WIDGET (gtk_builder_get_object (Test2Builder, "image2")); gtk_image_set_from_animation(GTK_IMAGE(imageTest), pixbufTestanm); GdkPixbufAnimation * pixbufaddanm = gdk_pixbuf_animation_new_from_file(ADDS2, error); GtkImage *adds = (GtkImage *) GTK_WIDGET (gtk_builder_get_object (Test2Builder, "adds")); gtk_image_set_from_animation(GTK_IMAGE(adds), pixbufaddanm); //GdkPixbufAnimation * pixbuf1 = gdk_pixbuf_animation_new_from_file(GRAPH, error); //GtkImage * grf = (GtkImage *) GTK_WIDGET (gtk_builder_get_object (Test2Builder, "graph")); //gtk_image_set_from_animation(GTK_IMAGE(grf), pixbuf1); t2_button1 = GTK_WIDGET (gtk_builder_get_object (Test2Builder, "exit")); g_signal_connect (G_OBJECT (t2_button1), "clicked", G_CALLBACK (test_exit_btnclicked), NULL); profileBtnClickedFrom = test2_pro_btn; t2_button2 = GTK_WIDGET (gtk_builder_get_object (Test2Builder, "profile")); g_signal_connect (G_OBJECT (t2_button2), "clicked", G_CALLBACK (test_profile_btnclicked), profileBtnClickedFrom); bodyFatLabel = GTK_WIDGET (gtk_builder_get_object (Test2Builder, "label5")); //test2_msg = GTK_WIDGET (gtk_builder_get_object (Test2Builder, "label7")); t2_button3 = GTK_WIDGET (gtk_builder_get_object (Test2Builder, "click_to_measure")); t2_button4 = GTK_WIDGET (gtk_builder_get_object (Test2Builder, "repeate")); g_signal_connect (G_OBJECT (t2_button4), "clicked", G_CALLBACK (test2_click_to_measure_btnclicked), NULL); test2_timer_label = GTK_WIDGET (gtk_builder_get_object (Test2Builder, "timer_label")); g_signal_connect (G_OBJECT (t2_button3), "clicked", G_CALLBACK (test2_click_to_measure_btnclicked), NULL); //g_object_set_property (G_OBJECT(t2_button3), "label", "Repeate"); continue_timer = TRUE; start_timer = TRUE; //g_signal_connect(G_OBJECT(t2_button3), "clicked", G_CALLBACK(_start_timer), timer_label); //g_signal_connect(G_OBJECT(t2_button31), "clicked", G_CALLBACK(_start_timer), timer_label); /* t2_button4 = GTK_WIDGET (gtk_builder_get_object (Test2Builder, "set")); g_signal_connect (G_OBJECT (t2_button4), "clicked", G_CALLBACK (test2_set_btnclicked), NULL); */ t2_button5 = GTK_WIDGET (gtk_builder_get_object (Test2Builder, "next")); g_signal_connect (G_OBJECT (t2_button5), "clicked", G_CALLBACK (test2_next_btnclicked), NULL); priv = g_malloc (sizeof (struct _Private)); /* ANJUTA: Widgets initialization for WindowMain.ui - DO NOT REMOVE */ //g_object_unref (InitialBuilder); return window; }
static gboolean _on_show_dlg(gpointer user_data) { FmProgressDisplay* data = (FmProgressDisplay*)user_data; GtkBuilder* builder; GtkLabel* to; GtkWidget *to_label; FmPath* dest; const char* title = NULL; GtkTextTagTable* tag_table; builder = gtk_builder_new(); tag_table = gtk_text_tag_table_new(); gtk_builder_set_translation_domain(builder, GETTEXT_PACKAGE); gtk_builder_add_from_file(builder, PACKAGE_UI_DIR "/progress.ui", NULL); data->dlg = GTK_DIALOG(gtk_builder_get_object(builder, "dlg")); g_object_weak_ref(G_OBJECT(data->dlg), on_progress_dialog_destroy, data); g_signal_connect(data->dlg, "response", G_CALLBACK(on_response), data); /* FIXME: connect to "close" signal */ to_label = (GtkWidget*)gtk_builder_get_object(builder, "to_label"); to = GTK_LABEL(gtk_builder_get_object(builder, "dest")); data->icon = GTK_IMAGE(gtk_builder_get_object(builder, "icon")); data->msg = GTK_LABEL(gtk_builder_get_object(builder, "msg")); data->act = GTK_LABEL(gtk_builder_get_object(builder, "action")); data->src = GTK_LABEL(gtk_builder_get_object(builder, "src")); data->dest = (GtkWidget*)gtk_builder_get_object(builder, "dest"); data->current = GTK_LABEL(gtk_builder_get_object(builder, "current")); data->progress = GTK_PROGRESS_BAR(gtk_builder_get_object(builder, "progress")); data->error_pane = (GtkWidget*)gtk_builder_get_object(builder, "error_pane"); data->error_msg = GTK_TEXT_VIEW(gtk_builder_get_object(builder, "error_msg")); data->data_transferred = GTK_LABEL(gtk_builder_get_object(builder, "data_transferred")); data->data_transferred_label = GTK_LABEL(gtk_builder_get_object(builder, "data_transferred_label")); data->remaining_time = GTK_LABEL(gtk_builder_get_object(builder, "remaining_time")); data->remaining_time_label = GTK_LABEL(gtk_builder_get_object(builder, "remaining_time_label")); data->cancel = GTK_BUTTON(gtk_builder_get_object(builder, "cancel")); data->suspend = GTK_BUTTON(gtk_dialog_add_button(data->dlg, _("_Pause"), 1)); gtk_button_set_use_stock(data->suspend, FALSE); gtk_button_set_use_underline(data->suspend, TRUE); gtk_button_set_image(data->suspend, gtk_image_new_from_stock(GTK_STOCK_MEDIA_PAUSE, GTK_ICON_SIZE_BUTTON)); gtk_dialog_set_alternative_button_order(data->dlg, 1, GTK_RESPONSE_CANCEL, -1); data->bold_tag = gtk_text_tag_new("bold"); g_object_set(data->bold_tag, "weight", PANGO_WEIGHT_BOLD, NULL); gtk_text_tag_table_add(tag_table, data->bold_tag); data->error_buf = gtk_text_buffer_new(tag_table); g_object_unref(tag_table); gtk_text_view_set_buffer(data->error_msg, data->error_buf); gtk_widget_hide(GTK_WIDGET(data->icon)); g_object_unref(builder); /* set the src label */ /* FIXME: direct access to job struct! */ if(data->job->srcs) { GList* l = fm_path_list_peek_head_link(data->job->srcs); int i; char* disp; FmPath* path; GString* str = g_string_sized_new(512); path = FM_PATH(l->data); disp = fm_path_display_basename(path); g_string_assign(str, disp); g_free(disp); for( i =1, l=l->next; i < 10 && l; l=l->next, ++i) { path = FM_PATH(l->data); g_string_append(str, _(", ")); disp = fm_path_display_basename(path); g_string_append(str, disp); g_free(disp); } if(l) g_string_append(str, "..."); gtk_label_set_text(data->src, str->str); gtk_widget_set_tooltip_text(GTK_WIDGET(data->src), str->str); g_string_free(str, TRUE); } /* FIXME: use accessor functions instead */ /* FIXME: direct access to job struct! */ switch(data->job->type) { /* we set title here if text is complex so may be different from the op_text when is translated to other languages */ case FM_FILE_OP_MOVE: /* translators: it is part of "Moving files:" or "Moving xxx.txt" */ data->op_text = _("Moving"); break; case FM_FILE_OP_COPY: /* translators: it is part of "Copying files:" or "Copying xxx.txt" */ data->op_text = _("Copying"); break; case FM_FILE_OP_TRASH: /* translators: it is part of "Trashing files:" or "Trashing xxx.txt" */ data->op_text = _("Trashing"); break; case FM_FILE_OP_DELETE: /* translators: it is part of "Deleting files:" or "Deleting xxx.txt" */ data->op_text = _("Deleting"); break; case FM_FILE_OP_LINK: /* translators: it is part of "Creating link /path/xxx.txt" */ data->op_text = _("Creating link"); /* translators: 'In:' string is followed by destination folder path */ gtk_label_set_markup(GTK_LABEL(to_label), _("<b>In:</b>")); title = _("Creating links to files"); /* NOTE: on creating single symlink or shortcut all operation is done in single I/O therefore it should fit into 0.5s timeout and progress window will never be shown */ break; case FM_FILE_OP_CHANGE_ATTR: /* translators: it is part of "Changing attributes of xxx.txt" */ data->op_text = _("Changing attributes of"); title = _("Changing attributes of files"); /* NOTE: the same about single symlink is appliable here so there is no need to add never used string for translation */ break; case FM_FILE_OP_UNTRASH: /* translators: it is part of "Restoring files:" or "Restoring xxx.txt" */ data->op_text = _("Restoring"); break; case FM_FILE_OP_NONE: ; } data->str = g_string_sized_new(64); if (title) gtk_window_set_title(GTK_WINDOW(data->dlg), title); else { /* note to translators: resulting string is such as "Deleting files" */ g_string_printf(data->str, _("%s files"), data->op_text); gtk_window_set_title(GTK_WINDOW(data->dlg), data->str->str); } gtk_label_set_markup(data->msg, _("<b>File operation is in progress...</b>")); gtk_widget_show(GTK_WIDGET(data->msg)); if (title) /* we already know the exact string */ g_string_printf(data->str, "<b>%s:</b>", title); else if (fm_path_list_get_length(data->job->srcs) == 1) /* note to translators: resulting string is such as "Deleting file" */ g_string_printf(data->str, _("<b>%s file:</b>"), data->op_text); else /* note to translators: resulting string is such as "Deleting files" */ g_string_printf(data->str, _("<b>%s files:</b>"), data->op_text); gtk_label_set_markup(data->act, data->str->str); dest = fm_file_ops_job_get_dest(data->job); if(dest) { char* dest_str = fm_path_display_name(dest, TRUE); gtk_label_set_text(to, dest_str); gtk_widget_set_tooltip_text(GTK_WIDGET(data->dest), dest_str); g_free(dest_str); } else { gtk_widget_destroy(data->dest); gtk_widget_destroy(to_label); } gtk_window_set_transient_for(GTK_WINDOW(data->dlg), data->parent); gtk_window_present(GTK_WINDOW(data->dlg)); data->delay_timeout = 0; return FALSE; }
static void ocvThread(void){ //if(cvDefined==FALSE){ ttModels theModels; ttInit(&theModels); static GdkPixbuf *pixbuf; IplImage *theFrame, *segmented; static char theStr[12]; thePixel=cvPoint(0,0); //globalFrame=cvCreateImage(size,IPL_DEPTH_8U,3); //char theChar; #if use_webcam==1 CvCapture* theCamera; CvSize size=cvSize(justWidth,justHeight); theCamera=cvCaptureFromCAM(-1); cvSetCaptureProperty( theCamera,CV_CAP_PROP_FRAME_WIDTH,justWidth ); cvSetCaptureProperty( theCamera,CV_CAP_PROP_FRAME_HEIGHT,justHeight ); theFrame=cvCreateImage(size,IPL_DEPTH_8U,3); #else theFrame=cvLoadImage("images/image02.jpg",1); assert(theFrame!=NULL); justWidth=theFrame->width; justHeight=theFrame->height; CvSize size=cvSize(justWidth,justHeight); cvConvertImage(theFrame,theFrame,CV_CVTIMG_SWAP_RB); #endif segmented=cvCreateImage(size,IPL_DEPTH_8U,3); while (1){ #if use_webcam==1 theFrame=cvQueryFrame(theCamera); assert(theFrame!=NULL); cvConvertImage(theFrame,theFrame,CV_CVTIMG_SWAP_RB); #endif if(changeFlag==1){ theRanger.hue=-1; theH=ttCalibration(theFrame,&thePixel,&theRanger,NULL); theRanger.hue=theH; changeFlag=0; //getIndex(); //printf("%d\n",theIndex); //updateLimits(); } ttCalibration(theFrame,&thePixel,&theRanger,segmented); sprintf(theStr,"Hue=%d",theH); getIndex(); //cvShowImage("window",theImage); //theFrame=theImage; //cvWaitKey(5000); gdk_threads_enter(); pixbuf = gdk_pixbuf_new_from_data ((guchar*) theFrame->imageData, GDK_COLORSPACE_RGB, FALSE, theFrame->depth, theFrame->width, theFrame->height, (theFrame->widthStep), NULL, NULL); //printf("\n\nchingadamadre!\n");CV_CVTIMG_SWAP_RB gtk_image_set_from_pixbuf(GTK_IMAGE(image), pixbuf); pixbuf = gdk_pixbuf_new_from_data ((guchar*) segmented->imageData, GDK_COLORSPACE_RGB, FALSE, theFrame->depth, theFrame->width, theFrame->height, (theFrame->widthStep), NULL, NULL); gtk_image_set_from_pixbuf(GTK_IMAGE(gseg), pixbuf); gtk_label_set_text((GtkLabel *)hval,theStr); gdk_threads_leave(); //cvWaitKey(); #if use_webcam==0 g_usleep(50000); #endif } }
int main(int argc, char ** argv) { GtkWidget * vbox; GtkWidget * hpaned; GtkWidget * sc_win, * sc_buffer; GtkWidget * menu_bar; GtkWidget * file_menu, * file_item; GtkWidget * generate_menu, * generate_item; GtkWidget * settings_menu, * settings_item; GtkWidget * zoom_box, * zoom_button; int i; //init general colors = (color_t *)malloc(NUM_COLORS * sizeof(color_t)); oldcolors = (color_t *)malloc(OLD_NUM_COLORS * sizeof(color_t)); memset(mdata, 0, BUFFER_COUNT * sizeof(unsigned char *)); memset(icons, 0, BUFFER_COUNT * sizeof(GtkWidget *)); memset(icon_event_boxes, 0, BUFFER_COUNT * sizeof(GtkWidget *)); mdata[current_buffer] = (unsigned char *)malloc(128 * 128); load_colors_plain(colors, "colors"); load_colors_plain(oldcolors, "oldcolors"); newcolors = colors; //save_colors(colors, "colors.bin"); //load_colors(colors, "colors.bin"); srand(time(NULL)); config = config_new(); //init gtk gtk_init(&argc, &argv); //window window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "ImageToMap X v" VERSION_NUMBER); g_signal_connect(window, "delete_event", G_CALLBACK(kill_window), NULL); //vbox #ifdef GTK2 vbox = gtk_vbox_new(FALSE, 0); #else vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); #endif gtk_frame_set_shadow_type(GTK_FRAME(vbox), GTK_SHADOW_IN); gtk_container_add(GTK_CONTAINER (window), vbox); gtk_widget_show(vbox); //////menu_bar menu_bar = gtk_menu_bar_new(); gtk_box_pack_start(GTK_BOX(vbox), menu_bar, FALSE, TRUE, 0); gtk_widget_show(menu_bar); ////////file_menu file_menu = gtk_menu_new(); //////////file_menu items construct_tool_bar_add(file_menu, "Open", ITEM_SIGNAL_OPEN); construct_tool_bar_add(file_menu, "Open Grid Image", ITEM_SIGNAL_OPEN_GRID_IMAGE); construct_tool_bar_add(file_menu, "Save", ITEM_SIGNAL_SAVE); construct_tool_bar_add(file_menu, "Save Increment", ITEM_SIGNAL_SAVE_INCREMENT); construct_tool_bar_add(file_menu, "Save All", ITEM_SIGNAL_SAVE_ALL); construct_tool_bar_add(file_menu, "Save Raw Map", ITEM_SIGNAL_SAVE_RM); construct_tool_bar_add(file_menu, "Export Image", ITEM_SIGNAL_EXPORT_IMAGE); /* construct_tool_bar_add_deactivate(file_menu, "Render World", ITEM_SIGNAL_WORLD_RENDER_ITEM); */ construct_tool_bar_add(file_menu, "Render World", ITEM_SIGNAL_WORLD_RENDER_ITEM); construct_tool_bar_add(file_menu, "Clean Buffer List", ITEM_SIGNAL_CLEAN); construct_tool_bar_add(file_menu, "Quit", ITEM_SIGNAL_QUIT); /////////file_item file_item = gtk_menu_item_new_with_label("File"); gtk_widget_show(file_item); gtk_menu_item_set_submenu(GTK_MENU_ITEM(file_item), file_menu); gtk_menu_shell_append((GtkMenuShell *)menu_bar, file_item); ////////generate_menu generate_menu = gtk_menu_new(); //////////generate_menu items construct_tool_bar_add(generate_menu, "Mandelbrot", ITEM_SIGNAL_GENERATE_MANDELBROT); construct_tool_bar_add(generate_menu, "Julia", ITEM_SIGNAL_GENERATE_JULIA); construct_tool_bar_add(generate_menu, "Palette", ITEM_SIGNAL_GENERATE_PALETTE); construct_tool_bar_add(generate_menu, "Random Noise", ITEM_SIGNAL_GENERATE_RANDOM_NOISE); construct_tool_bar_add(generate_menu, "From Clipboard", ITEM_SIGNAL_GENERATE_FROM_CLIPBOARD); /////////generate_item generate_item = gtk_menu_item_new_with_label("Generate"); gtk_widget_show(generate_item); gtk_menu_item_set_submenu(GTK_MENU_ITEM(generate_item), generate_menu); gtk_menu_shell_append((GtkMenuShell *)menu_bar, generate_item); ////////settings_menu settings_menu = gtk_menu_new(); ////////settings_item settings_item = gtk_menu_item_new_with_label("Settings"); gtk_widget_show(settings_item); gtk_menu_item_set_submenu(GTK_MENU_ITEM(settings_item), settings_menu); gtk_menu_shell_append((GtkMenuShell *)menu_bar, settings_item); //////////FSD_checkbox FSD_checkbox = gtk_check_menu_item_new_with_label("Floyd–Steinberg dithering"); gtk_menu_shell_append(GTK_MENU_SHELL(settings_menu), FSD_checkbox); gtk_widget_show(FSD_checkbox); //////////YUV_checkbox YUV_checkbox = gtk_check_menu_item_new_with_label("YUV color conversion"); gtk_menu_shell_append(GTK_MENU_SHELL(settings_menu), YUV_checkbox); gtk_widget_show(YUV_checkbox); //////////old_colors_checkbox old_colors_checkbox = gtk_check_menu_item_new_with_label("Old Colors"); gtk_menu_shell_append(GTK_MENU_SHELL(settings_menu), old_colors_checkbox); gtk_widget_show(old_colors_checkbox); g_signal_connect_swapped(old_colors_checkbox, "toggled", G_CALLBACK(old_colors_checkbox_toggle), 0); //drop_down_menu init_drop_down_menu(); //hpaned #ifdef GTK2 hpaned = gtk_hpaned_new(); #else hpaned = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL); #endif gtk_widget_set_size_request (hpaned, 220, -1); gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 0); gtk_widget_show(hpaned); ////sc_buffer sc_buffer = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sc_buffer), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); #ifdef GTK2 gtk_widget_set_size_request(sc_buffer, 128 + 32, 512); #else gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(sc_buffer), 128 + 32); gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(sc_buffer), 512); #endif gtk_paned_pack2(GTK_PANED(hpaned), sc_buffer, FALSE, FALSE); gtk_widget_show(sc_buffer); //////list_vbox #ifdef GTK2 list_vbox = gtk_vbox_new(FALSE, 0); #else list_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); #endif #ifdef GTK2 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sc_buffer), list_vbox); #else gtk_container_add(GTK_CONTAINER(sc_buffer), list_vbox); #endif gtk_widget_show(list_vbox); ////sc_win sc_win = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sc_win), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); #ifdef GTK2 gtk_widget_set_size_request(sc_win, 128 * 4, 128 * 4); gtk_window_resize(GTK_WINDOW(window), 128 * 4 + 200, 128 * 4 + 70); #else gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(sc_win), 128 * 4); gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(sc_win), 128 * 4); #endif gtk_paned_pack1(GTK_PANED(hpaned), sc_win, TRUE, FALSE); gtk_widget_show(sc_win); //////image dimage = gdk_pixbuf_new_from_file("start.png", NULL); image = gtk_image_new(); gtk_image_set_from_pixbuf(GTK_IMAGE(image), dimage); #ifdef GTK2 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sc_win), image); #else gtk_container_add(GTK_CONTAINER(sc_win), image); #endif gtk_widget_show(image); ////zoom_box #ifdef GTK2 zoom_box = gtk_hbox_new(FALSE, 0); #else zoom_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); #endif gtk_box_pack_start(GTK_BOX(vbox), zoom_box, FALSE, FALSE, 0); gtk_widget_show(zoom_box); //////zoom_button (+) zoom_button = gtk_button_new_with_label("+"); gtk_box_pack_start(GTK_BOX(zoom_box), zoom_button, TRUE, TRUE, 2); g_signal_connect(zoom_button, "clicked", G_CALLBACK(button_click2), "button.zoomp"); gtk_widget_show(zoom_button); //////zoom_button (|) zoom_button = gtk_button_new_with_label("|"); gtk_box_pack_start(GTK_BOX(zoom_box), zoom_button, TRUE, TRUE, 2); g_signal_connect(zoom_button, "clicked", G_CALLBACK(button_click2), "button.zoome"); gtk_widget_show(zoom_button); //////zoom_button (-) zoom_button = gtk_button_new_with_label("-"); gtk_box_pack_start(GTK_BOX(zoom_box), zoom_button, TRUE, TRUE, 2); g_signal_connect(zoom_button, "clicked", G_CALLBACK(button_click2), "button.zoomm"); gtk_widget_show(zoom_button); //icon gtk_window_set_icon(GTK_WINDOW(window), create_pixbuf("imagetomap.ico")); //Drag and drop gtk_drag_dest_set(window, GTK_DEST_DEFAULT_ALL, targets, sizeof(targets)/sizeof(*targets), GDK_ACTION_COPY); gtk_drag_dest_add_uri_targets(window); g_signal_connect(window, "drag-drop", G_CALLBACK(drag_drop), NULL); g_signal_connect(window, "drag-motion", G_CALLBACK(drag_motion), NULL); g_signal_connect(window, "drag-data-received", G_CALLBACK(drag_received), NULL); g_signal_connect(window, "drag-leave", G_CALLBACK(drag_leave), NULL); //display window gtk_widget_show (window); gtk_main(); //clean up free(colors); for(i = 0; i < BUFFER_COUNT; i++) free(mdata[i]); config_free(config); return 0; }
static gboolean avatar_image_button_press_event (GtkWidget *widget, GdkEventButton *event) { EmpathyAvatarImagePriv *priv; GtkWidget *popup; GtkWidget *frame; GtkWidget *image; gint x, y; gint popup_width, popup_height; gint width, height; GdkPixbuf *pixbuf; priv = GET_PRIV (widget); if (priv->popup) { gtk_widget_destroy (priv->popup); priv->popup = NULL; } if (event->button != 1 || event->type != GDK_BUTTON_PRESS || !priv->pixbuf) { return FALSE; } popup_width = gdk_pixbuf_get_width (priv->pixbuf); popup_height = gdk_pixbuf_get_height (priv->pixbuf); width = priv->image->allocation.width; height = priv->image->allocation.height; /* Don't show a popup if the popup is smaller then the currently avatar * image. */ if (popup_height <= height && popup_width <= width) { return TRUE; } pixbuf = empathy_pixbuf_scale_down_if_necessary (priv->pixbuf, MAX_LARGE); popup_width = gdk_pixbuf_get_width (pixbuf); popup_height = gdk_pixbuf_get_height (pixbuf); popup = gtk_window_new (GTK_WINDOW_POPUP); frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT); gtk_container_add (GTK_CONTAINER (popup), frame); image = gtk_image_new (); gtk_container_add (GTK_CONTAINER (frame), image); gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf); g_object_unref (pixbuf); gdk_window_get_origin (gtk_widget_get_window (priv->image), &x, &y); x = x - (popup_width - width) / 2; y = y - (popup_height - height) / 2; gtk_window_move (GTK_WINDOW (popup), x, y); priv->popup = popup; gtk_widget_show_all (popup); return TRUE; }
EMessageBoxReturn gtk_MessageBox (GtkWidget *parent, const char* text, const char* title, EMessageBoxType type, EMessageBoxIcon icon) { ModalDialog dialog; ModalDialogButton ok_button(dialog, eIDOK); ModalDialogButton cancel_button(dialog, eIDCANCEL); ModalDialogButton yes_button(dialog, eIDYES); ModalDialogButton no_button(dialog, eIDNO); GtkWindow* parentWindow = parent != 0 ? GTK_WINDOW(parent) : 0; GtkWindow* window = create_fixedsize_modal_dialog_window(parentWindow, title, dialog, 400, 100); if(parentWindow != 0) { //g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(floating_window_delete_present), parent); gtk_window_deiconify(parentWindow); } GtkAccelGroup* accel = gtk_accel_group_new(); gtk_window_add_accel_group(window, accel); GtkVBox* vbox = create_dialog_vbox(8, 8); gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(vbox)); GtkHBox* hboxDummy = create_dialog_hbox(0, 0); gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(hboxDummy), FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hboxDummy), create_padding(0, 50), FALSE, FALSE, 0); // HACK to force minimum height GtkHBox* iconBox = create_dialog_hbox(16, 0); gtk_box_pack_start(GTK_BOX(hboxDummy), GTK_WIDGET(iconBox), FALSE, FALSE, 0); GtkImage* image = GTK_IMAGE(gtk_image_new_from_stock(messagebox_stock_icon(icon), GTK_ICON_SIZE_DIALOG)); gtk_widget_show(GTK_WIDGET(image)); gtk_box_pack_start(GTK_BOX(iconBox), GTK_WIDGET(image), FALSE, FALSE, 0); GtkLabel* label = GTK_LABEL(gtk_label_new(text)); gtk_widget_show(GTK_WIDGET(label)); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); gtk_label_set_justify(label, GTK_JUSTIFY_LEFT); gtk_label_set_line_wrap(label, TRUE); gtk_box_pack_start(GTK_BOX(iconBox), GTK_WIDGET(label), TRUE, TRUE, 0); GtkVBox* vboxDummy = create_dialog_vbox(0, 0); gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(vboxDummy), FALSE, FALSE, 0); GtkAlignment* alignment = GTK_ALIGNMENT(gtk_alignment_new(0.5, 0.0, 0.0, 0.0)); gtk_widget_show(GTK_WIDGET(alignment)); gtk_box_pack_start(GTK_BOX(vboxDummy), GTK_WIDGET(alignment), FALSE, FALSE, 0); GtkHBox* hbox = create_dialog_hbox(8, 0); gtk_container_add(GTK_CONTAINER(alignment), GTK_WIDGET(hbox)); gtk_box_pack_start(GTK_BOX(vboxDummy), create_padding(400, 0), FALSE, FALSE, 0); // HACK to force minimum width if (type == eMB_OK) { GtkButton* button = create_modal_dialog_button("OK", ok_button); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(button), TRUE, FALSE, 0); gtk_widget_add_accelerator(GTK_WIDGET(button), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0); gtk_widget_add_accelerator(GTK_WIDGET(button), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0); widget_make_default(GTK_WIDGET(button)); gtk_widget_show(GTK_WIDGET(button)); dialog.ret = eIDOK; } else if (type == eMB_OKCANCEL) { { GtkButton* button = create_modal_dialog_button("OK", ok_button); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(button), TRUE, FALSE, 0); gtk_widget_add_accelerator(GTK_WIDGET(button), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0); widget_make_default(GTK_WIDGET(button)); gtk_widget_show(GTK_WIDGET(button)); } { GtkButton* button = create_modal_dialog_button("OK", cancel_button); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(button), TRUE, FALSE, 0); gtk_widget_add_accelerator(GTK_WIDGET(button), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0); gtk_widget_show(GTK_WIDGET(button)); } dialog.ret = eIDCANCEL; } else if (type == eMB_YESNOCANCEL) { { GtkButton* button = create_modal_dialog_button("Yes", yes_button); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(button), TRUE, FALSE, 0); widget_make_default(GTK_WIDGET(button)); gtk_widget_show(GTK_WIDGET(button)); } { GtkButton* button = create_modal_dialog_button("No", no_button); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(button), TRUE, FALSE, 0); gtk_widget_show(GTK_WIDGET(button)); } { GtkButton* button = create_modal_dialog_button("Cancel", cancel_button); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(button), TRUE, FALSE, 0); gtk_widget_show(GTK_WIDGET(button)); } dialog.ret = eIDCANCEL; } else if (type == eMB_NOYES) { { GtkButton* button = create_modal_dialog_button("No", no_button); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(button), TRUE, FALSE, 0); widget_make_default(GTK_WIDGET(button)); gtk_widget_show(GTK_WIDGET(button)); } { GtkButton* button = create_modal_dialog_button("Yes", yes_button); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(button), TRUE, FALSE, 0); gtk_widget_show(GTK_WIDGET(button)); } dialog.ret = eIDNO; } else /* if (type == eMB_YESNO) */ { { GtkButton* button = create_modal_dialog_button("Yes", yes_button); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(button), TRUE, FALSE, 0); widget_make_default(GTK_WIDGET(button)); gtk_widget_show(GTK_WIDGET(button)); } { GtkButton* button = create_modal_dialog_button("No", no_button); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(button), TRUE, FALSE, 0); gtk_widget_show(GTK_WIDGET(button)); } dialog.ret = eIDNO; } modal_dialog_show(window, dialog); gtk_widget_destroy(GTK_WIDGET(window)); return dialog.ret; }
static void anjuta_docman_update_page_label (AnjutaDocman *docman, IAnjutaDocument *doc) { AnjutaDocmanPage *page; gchar *basename; GFile* file; const gchar* doc_filename; gchar* dirty_char; gchar* read_only; gchar* label; if (doc == NULL) return; page = anjuta_docman_get_page_for_document (docman, doc); if (!page || page->label == NULL || page->menu_label == NULL) return; if (!ianjuta_file_savable_is_dirty(IANJUTA_FILE_SAVABLE (doc), NULL)) { dirty_char = ""; } else { dirty_char = "*"; } if (ianjuta_file_savable_is_read_only (IANJUTA_FILE_SAVABLE (doc), NULL)) { read_only = _("[read-only]"); } else { read_only = ""; } file = ianjuta_file_get_file (IANJUTA_FILE (doc), NULL); if (file) { basename = g_file_get_basename (file); label = g_strconcat(dirty_char, basename, read_only, NULL); gtk_label_set_text (GTK_LABEL (page->label), label); gtk_label_set_text (GTK_LABEL (page->menu_label), label); g_free (label); g_free (basename); if (ianjuta_file_savable_is_conflict (IANJUTA_FILE_SAVABLE (doc), NULL)) { gtk_image_set_from_stock (GTK_IMAGE (page->menu_icon), GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_MENU); gtk_image_set_from_stock (GTK_IMAGE (page->mime_icon), GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_MENU); } else { GdkPixbuf* pixbuf = anjuta_docman_get_pixbuf_for_file (file); if (pixbuf) { gtk_image_set_from_pixbuf (GTK_IMAGE(page->menu_icon), pixbuf); gtk_image_set_from_pixbuf (GTK_IMAGE(page->mime_icon), pixbuf); g_object_unref (pixbuf); } } g_object_unref (file); } else if ((doc_filename = ianjuta_document_get_filename (doc, NULL)) != NULL) { label = g_strconcat (dirty_char, doc_filename, read_only, NULL); gtk_label_set_text (GTK_LABEL (page->label), label); gtk_label_set_text (GTK_LABEL (page->menu_label), label); g_free (label); } }
/* Do the actual applet initialization */ static void init_wtapplet (PanelApplet *applet) { WTApplet *wtapplet = g_new0 (WTApplet, 1); wtapplet->applet = applet; wtapplet->settings = panel_applet_settings_new (applet, WINDOWTITLE_GSCHEMA); wtapplet->prefs = loadPreferences(wtapplet); wtapplet->activescreen = wnck_screen_get_default(); wnck_screen_force_update(wtapplet->activescreen); wtapplet->activeworkspace = wnck_screen_get_active_workspace(wtapplet->activescreen); wtapplet->activewindow = wnck_screen_get_active_window(wtapplet->activescreen); wtapplet->umaxedwindow = getUpperMaximized(wtapplet); wtapplet->rootwindow = getRootWindow(wtapplet->activescreen); wtapplet->prefbuilder = gtk_builder_new(); wtapplet->box = GTK_BOX(gtk_hbox_new(FALSE, 0)); wtapplet->icon = GTK_IMAGE(gtk_image_new()); wtapplet->title = GTK_LABEL(gtk_label_new(NULL)); wtapplet->eb_icon = GTK_EVENT_BOX(gtk_event_box_new()); wtapplet->eb_title = GTK_EVENT_BOX(gtk_event_box_new()); wtapplet->orient = panel_applet_get_orient(wtapplet->applet); wtapplet->size_hints = g_new(gint,2); // Widgets to eventboxes, eventboxes to box gtk_widget_set_can_focus(GTK_WIDGET(wtapplet->icon), TRUE); gtk_widget_set_can_focus(GTK_WIDGET(wtapplet->title), TRUE); gtk_container_add (GTK_CONTAINER (wtapplet->eb_icon), GTK_WIDGET(wtapplet->icon)); gtk_container_add (GTK_CONTAINER (wtapplet->eb_title), GTK_WIDGET(wtapplet->title)); gtk_event_box_set_visible_window (wtapplet->eb_icon, FALSE); gtk_event_box_set_visible_window (wtapplet->eb_title, FALSE); // Rotate & place elements setAlignment(wtapplet, (gdouble)wtapplet->prefs->alignment); placeWidgets(wtapplet); // Add box to applet gtk_container_add (GTK_CONTAINER(wtapplet->applet), GTK_WIDGET(wtapplet->box)); // Set event handling (icon & title clicks) g_signal_connect(G_OBJECT (wtapplet->eb_icon), "button-press-event", G_CALLBACK (icon_clicked), wtapplet); g_signal_connect(G_OBJECT (wtapplet->eb_title), "button-press-event", G_CALLBACK (title_clicked), wtapplet); // Global window tracking g_signal_connect(wtapplet->activescreen, "active-window-changed", G_CALLBACK (active_window_changed), wtapplet); // <-- this thing is crashing with compiz !!! g_signal_connect(wtapplet->activescreen, "viewports-changed", G_CALLBACK (viewports_changed), wtapplet); g_signal_connect(wtapplet->activescreen, "active-workspace-changed", G_CALLBACK (active_workspace_changed), wtapplet); g_signal_connect(wtapplet->activescreen, "window-closed", G_CALLBACK (window_closed), wtapplet); g_signal_connect(wtapplet->activescreen, "window-opened", G_CALLBACK (window_opened), wtapplet); // g_signal_connect(G_OBJECT (wtapplet->title), "size-request", G_CALLBACK (applet_title_size_request), wtapplet); g_signal_connect(G_OBJECT (wtapplet->applet), "size-allocate", G_CALLBACK (applet_size_allocate), wtapplet); g_signal_connect(G_OBJECT (wtapplet->applet), "change-background", G_CALLBACK (applet_change_background), wtapplet); g_signal_connect(G_OBJECT (wtapplet->applet), "change-orient", G_CALLBACK (applet_change_orient), wtapplet); g_signal_connect(G_OBJECT (wtapplet->applet), "change-size", G_CALLBACK (applet_change_pixel_size), wtapplet); // Track active window changes wtapplet->active_handler_state = g_signal_connect(G_OBJECT (wtapplet->activewindow), "state-changed", G_CALLBACK (active_window_state_changed), wtapplet); wtapplet->active_handler_name = g_signal_connect(G_OBJECT (wtapplet->activewindow), "name-changed", G_CALLBACK (active_window_nameicon_changed), wtapplet); wtapplet->active_handler_icon = g_signal_connect(G_OBJECT (wtapplet->activewindow), "icon-changed", G_CALLBACK (active_window_nameicon_changed), wtapplet); // Setup applet right-click menu GSimpleActionGroup *action_group = g_simple_action_group_new (); g_action_map_add_action_entries (G_ACTION_MAP (action_group), windowtitle_menu_actions, G_N_ELEMENTS (windowtitle_menu_actions), wtapplet); panel_applet_setup_menu (applet, windowtitle_menu_items, action_group, GETTEXT_PACKAGE); gtk_widget_insert_action_group (GTK_WIDGET (wtapplet->applet), "windowtitle", G_ACTION_GROUP (action_group)); toggleExpand (wtapplet); toggleHidden (wtapplet); // Properly hide or show stuff updateTitle (wtapplet); }
static void add_data_tab (const gchar *demoname) { gchar *resource_dir, *resource_name; gchar **resources; GtkWidget *widget, *label; guint i; resource_dir = g_strconcat ("/", demoname, NULL); resources = g_resources_enumerate_children (resource_dir, 0, NULL); if (resources == NULL) { g_free (resource_dir); return; } for (i = 0; resources[i]; i++) { resource_name = g_strconcat (resource_dir, "/", resources[i], NULL); widget = gtk_image_new_from_resource (resource_name); if (gtk_image_get_pixbuf (GTK_IMAGE (widget)) == NULL && gtk_image_get_animation (GTK_IMAGE (widget)) == NULL) { GBytes *bytes; /* So we've used the best API available to figure out it's * not an image. Let's try something else then. */ g_object_ref_sink (widget); g_object_unref (widget); bytes = g_resources_lookup_data (resource_name, 0, NULL); g_assert (bytes); if (g_utf8_validate (g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes), NULL)) { /* Looks like it parses as text. Dump it into a textview then! */ GtkTextBuffer *buffer; GtkWidget *textview; widget = create_text (&textview, FALSE); buffer = gtk_text_buffer_new (NULL); gtk_text_buffer_set_text (buffer, g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes)); gtk_text_view_set_buffer (GTK_TEXT_VIEW (textview), buffer); } else { g_warning ("Don't know how to display resource '%s'\n", resource_name); widget = NULL; } g_bytes_unref (bytes); } gtk_widget_show_all (widget); label = gtk_label_new (resources[i]); gtk_widget_show (label); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), widget, label); gtk_container_child_set (GTK_CONTAINER (notebook), GTK_WIDGET (widget), "tab-expand", TRUE, NULL); g_free (resource_name); } g_strfreev (resources); g_free (resource_dir); }
static gboolean _tristatebutton_expose(GtkWidget *widget, GdkEventExpose *event) { g_return_val_if_fail(widget != NULL, FALSE); g_return_val_if_fail(DTGTK_IS_TRISTATEBUTTON(widget), FALSE); g_return_val_if_fail(event != NULL, FALSE); GtkStyle *style = gtk_widget_get_style(widget); int state = gtk_widget_get_state(widget); /* fix text style */ for(int i = 0; i < 5; i++) style->text[i] = style->fg[i]; /* fetch flags */ int flags = DTGTK_TRISTATEBUTTON(widget)->icon_flags; /* set inner border */ int border = DT_PIXEL_APPLY_DPI((flags & CPF_DO_NOT_USE_BORDER) ? 2 : 6); /* update active state paint flag */ gboolean active = DTGTK_TRISTATEBUTTON(widget)->state > 0; if(active) flags |= CPF_ACTIVE; else flags &= ~(CPF_ACTIVE); /* begin cairo drawing */ cairo_t *cr; cr = gdk_cairo_create(gtk_widget_get_window(widget)); GtkAllocation allocation; gtk_widget_get_allocation(widget, &allocation); int x = allocation.x; int y = allocation.y; int width = allocation.width; int height = allocation.height; /* draw standard button background if not transparent nor flat styled */ if((flags & CPF_STYLE_FLAT)) { if(state != GTK_STATE_NORMAL) { cairo_rectangle(cr, x, y, width, height); cairo_set_source_rgba(cr, style->bg[state].red / 65535.0, style->bg[state].green / 65535.0, style->bg[state].blue / 65535.0, 0.5); cairo_fill(cr); } } else if(!(flags & CPF_BG_TRANSPARENT)) { cairo_rectangle(cr, x, y, width, height); float rs = 1.0, gs = 1.0, bs = 1.0; if(DTGTK_TRISTATEBUTTON(widget)->state == 1) rs = gs = bs = 3.0; else if(DTGTK_TRISTATEBUTTON(widget)->state == 2) rs = 3.0; cairo_set_source_rgba(cr, (style->bg[state].red / 65535.0) * rs, (style->bg[state].green / 65535.0) * gs, (style->bg[state].blue / 65535.0) * bs, 0.5); cairo_fill(cr); } /* create pango text settings if label exists */ PangoLayout *layout = NULL; int pw = 0, ph = 0; const gchar *text = gtk_button_get_label(GTK_BUTTON(widget)); if(text) { layout = pango_cairo_create_layout(cr); pango_layout_set_font_description(layout, darktable.bauhaus->pango_font_desc); pango_cairo_context_set_resolution(pango_layout_get_context(layout), darktable.gui->dpi); pango_layout_set_text(layout, text, -1); pango_layout_get_pixel_size(layout, &pw, &ph); } cairo_set_source_rgb(cr, style->fg[state].red / 65535.0, style->fg[state].green / 65535.0, style->fg[state].blue / 65535.0); /* draw button image if any */ GtkWidget *image = gtk_button_get_image(GTK_BUTTON(widget)); if(image) { GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(image)); if(pixbuf) { /* Draw the pixbuf */ gint pbw = gdk_pixbuf_get_width(pixbuf); gint pbh = gdk_pixbuf_get_height(pixbuf); gdk_cairo_set_source_pixbuf(cr, pixbuf, allocation.x + ((allocation.width / 2) - (pbw / 2)), allocation.y + ((allocation.height / 2) - (pbh / 2))); cairo_paint(cr); } } /* draw icon */ if(DTGTK_TRISTATEBUTTON(widget)->icon) { // if (flags & CPF_IGNORE_FG_STATE) // state = GTK_STATE_NORMAL; if(text) DTGTK_TRISTATEBUTTON(widget) ->icon(cr, x + border, y + border, height - (border * 2), height - (border * 2), flags); else DTGTK_TRISTATEBUTTON(widget) ->icon(cr, x + border, y + border, width - (border * 2), height - (border * 2), flags); } /* draw label */ if(text) { int lx = x + DT_PIXEL_APPLY_DPI(2), ly = y + ((height / 2.0) - (ph / 2.0)); cairo_translate(cr, lx, ly); pango_cairo_show_layout(cr, layout); g_object_unref(layout); } cairo_destroy(cr); return FALSE; }
static void button_clicked(GtkWidget * button, ScreenshotData * sd) { GdkPixbuf * screenshot; GdkPixbuf * thumbnail; GdkWindow * window; GdkNativeWindow nwindow; gint delay; gint width; gint height; gchar * filename = NULL; gchar * basename = NULL; gchar * curdir = NULL; if (sd->whole_screen) { window = gdk_get_default_root_window(); } else { if (delay = sd->window_delay) { g_timeout_add(1000, delay_callback, &delay); gtk_main(); } nwindow = select_window(gdk_screen_get_default()); if (nwindow) { window = gdk_window_foreign_new(nwindow); } else { window = gdk_get_default_root_window(); } } gdk_drawable_get_size(window, &width, &height); if (delay = sd->screenshot_delay) { g_timeout_add(1000, delay_callback, &delay); gtk_main(); } screenshot = gdk_pixbuf_get_from_drawable (NULL, window, NULL, 0, 0, 0, 0, width, height); thumbnail = gdk_pixbuf_scale_simple (screenshot, width/5, height/5, GDK_INTERP_BILINEAR); gtk_image_set_from_pixbuf (GTK_IMAGE (sd->preview), thumbnail); g_object_unref (thumbnail); filename = generate_filename_for_uri (xfce_file_chooser_get_current_folder(XFCE_FILE_CHOOSER (sd->chooser))); if (sd->ask_for_file && filename) { gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (sd->chooser), filename); if (gtk_dialog_run (GTK_DIALOG (sd->chooser)) == GTK_RESPONSE_ACCEPT) { filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(sd->chooser)); } gtk_widget_hide (GTK_WIDGET (sd->chooser)); } else { /* sd->counter++; basename = g_strdup_printf ("Screenshot-%d.png", sd->counter); filename = g_build_filename (sd->screenshots_dir, basename, NULL); curdir = g_get_current_dir(); filename = g_build_filename (curdir, basename, NULL); g_free(basename); */ } if (filename) { gdk_pixbuf_save (screenshot, filename, "png", NULL, NULL); g_free (filename); } }
void pp_cms_refresh(pp_CMS *ob) { Debug[TRACE] << "In pp_cms_refresh" << endl; int pa=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ob->printeractive)); int ga=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ob->greyactive)); int ra=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ob->rgbactive)); int ca=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ob->cmykactive)); int ma=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ob->monitoractive)); gtk_widget_set_sensitive(ob->printerprof,pa); gtk_widget_set_sensitive(ob->intent,pa); gtk_widget_set_sensitive(ob->displaymode,ma); gtk_widget_set_sensitive(ob->colourspace,!pa); gtk_widget_set_sensitive(ob->greyprof,ga); gtk_widget_set_sensitive(ob->rgbprof,ra); gtk_widget_set_sensitive(ob->cmykprof,ca); gtk_widget_set_sensitive(ob->monitorprof,ma); IS_TYPE colourspace=simplecombo_get_index(SIMPLECOMBO(ob->colourspace)) ? IS_TYPE_CMYK : IS_TYPE_RGB; IS_TYPE dlcolourspace=colourspace; bool isdevicelink=false; Debug[TRACE] << "Getting profiles from widgets..." << endl; // Get colourspace from printer profile, if set. if(pa) { Debug[TRACE] << "Getting printer profile..." << endl; CMSProfile *p=ob->pm->GetProfile(profileselector_get_filename(PROFILESELECTOR(ob->printerprof))); if(p) { Debug[TRACE] << "Got printer profile..." << endl; colourspace=p->GetColourSpace(); if((isdevicelink=p->IsDeviceLink())) { dlcolourspace=colourspace; colourspace=p->GetDeviceLinkOutputSpace(); } delete p; } else { Debug[TRACE] << "Couldn't get printer profile..." << endl; pa=false; } } // Check RGB profile... if(ga) { CMSProfile *p=ob->pm->GetProfile(profileselector_get_filename(PROFILESELECTOR(ob->greyprof))); if(p) delete p; else ga=false; } // Check RGB profile... if(ra) { CMSProfile *p=ob->pm->GetProfile(profileselector_get_filename(PROFILESELECTOR(ob->rgbprof))); if(p) delete p; else ra=false; } // Check CMYK profile... if(ra) { CMSProfile *p=ob->pm->GetProfile(profileselector_get_filename(PROFILESELECTOR(ob->cmykprof))); if(p) delete p; else ca=false; } // Check Monitor profile... if(ra) { CMSProfile *p=ob->pm->GetProfile(profileselector_get_filename(PROFILESELECTOR(ob->monitorprof))); if(p) delete p; else ma=false; } Debug[TRACE] << "Got colourspace: " << colourspace << endl; const gchar *rgbok=GTK_STOCK_NO; const char *rgbstatus=""; // Work out implications of current settings for RGB images if(isdevicelink) // implies printer active... { if(dlcolourspace==IS_TYPE_CMYK) { if(ca && ra) // do we have both RGB and CMYK default profiles { // Devicelink with CMYK input, CMYK profile available rgbok=GTK_STOCK_DIALOG_WARNING; rgbstatus=_("Printer profile is a devicelink with CMYK input - RGB images\nwill first be converted to the default CMYK profile"); } else if(ra) { // Devicelink with CMYK input, no CMYK profile available rgbok=GTK_STOCK_NO; rgbstatus=_("Printer profile is a devicelink with CMYK input - RGB images\ncannot be printed without a default CMYK profile."); } else { // Devicelink with CMYK input, no RGB or CMYK profile available rgbok=GTK_STOCK_NO; rgbstatus=_("Printer profile is a devicelink with CMYK input - RGB images\ncannot be printed without a default RGB and CMYK profile."); // Exception: input RGB files with embedded profiles - but explaining that would be complicated. } } else if(ra) { // Devicelink with RGB input rgbok=GTK_STOCK_DIALOG_WARNING; rgbstatus=_("Printer profile is a devicelink - RGB images with embedded profiles\nwill first be converted to the default RGB profile."); } else { // Devicelink with RGB input rgbok=GTK_STOCK_DIALOG_WARNING; rgbstatus=_("Printer profile is a devicelink - RGB images with embedded profiles will not\nprint correctly, since there is no default RGB profile."); } } else if(pa && ra) { rgbok=GTK_STOCK_YES; rgbstatus=_("RGB images will print correctly"); } else if(pa && colourspace==IS_TYPE_RGB) { rgbok=GTK_STOCK_DIALOG_WARNING; rgbstatus=_("RGB images can be printed but colours depend on the driver\n(Colours will be accurate for images that contain an embedded profile)"); } else if(colourspace==IS_TYPE_RGB) { rgbok=GTK_STOCK_DIALOG_WARNING; rgbstatus=_("RGB images can be printed but colours depend on the driver"); } else if(pa && colourspace==IS_TYPE_CMYK) { rgbok=GTK_STOCK_DIALOG_WARNING; rgbstatus=_("RGB images can only be printed if they have an embedded profile\n(Workflow is CMYK and there is no default RGB profile)"); } else if(colourspace==IS_TYPE_CMYK) { rgbok=GTK_STOCK_NO; rgbstatus=_("RGB images cannot be printed\n(Workflow is CMYK and there is no printer profile)"); } const gchar *cmykok=GTK_STOCK_NO; const char *cmykstatus=""; // Work out implications of current settings for CMYK images... if(isdevicelink) { if(dlcolourspace==IS_TYPE_RGB) { if(ra && ca) { // Devicelink with RGB input, CMYK profile available cmykok=GTK_STOCK_DIALOG_WARNING; cmykstatus=_("Printer profile is a devicelink with RGB input - CMYK images\nwill first be converted to the default RGB profile"); } else if(ca) { // Devicelink with RGB input, no CMYK profile available cmykok=GTK_STOCK_NO; cmykstatus=_("Printer profile is a devicelink with RGB input - CMYK images\ncannot be printed without a default RGB profile."); } else { // Devicelink with RGB input, no RGB or CMYK profile available cmykok=GTK_STOCK_NO; cmykstatus=_("Printer profile is a devicelink with RGB input - CMYK images\ncannot be printed without a default RGB and CMYK profile."); } } else if(ca) { // Devicelink with CMYK input cmykok=GTK_STOCK_DIALOG_WARNING; cmykstatus=_("Printer profile is a devicelink - CMYK images with embedded profiles\nwill first be converted to the default CMYK profile."); } else { // Devicelink with CMYK input cmykok=GTK_STOCK_DIALOG_WARNING; cmykstatus=_("Printer profile is a devicelink - CMYK images with embedded profiles will not\nprint correctly since there is no default CMYK profile."); } } else if(pa && ca) { cmykok=GTK_STOCK_YES; cmykstatus=_("CMYK images will print correctly"); } else if(pa && colourspace==IS_TYPE_CMYK) { cmykok=GTK_STOCK_DIALOG_WARNING; cmykstatus=_("CMYK images can be printed but colours depend on the driver\n(Colours will be accurate for images that contain an embedded profile)"); } else if(colourspace==IS_TYPE_CMYK) { cmykok=GTK_STOCK_DIALOG_WARNING; cmykstatus=_("CMYK images can be printed but colours depend on the driver"); } else if(pa && colourspace==IS_TYPE_RGB) { cmykok=GTK_STOCK_DIALOG_WARNING; cmykstatus=_("CMYK images can only be printed if they have an embedded profile\n(Workflow is RGB and there is no default CMYK profile)"); } else if(colourspace==IS_TYPE_RGB) { cmykok=GTK_STOCK_NO; cmykstatus=_("CMYK images cannot be printed\n(Workflow is RGB and there is no printer profile)"); } const gchar *monok=GTK_STOCK_NO; const char *monstatus=""; if(ma && ra) { monok=GTK_STOCK_YES; monstatus=_("Images will be displayed correctly"); } else if(ma) { monok=GTK_STOCK_DIALOG_WARNING; monstatus=_("Images will only be displayed correctly if they have an embedded profile"); } else { monok=GTK_STOCK_NO; monstatus=_("Images will not be displayed correctly"); } gtk_label_set_text(GTK_LABEL(ob->statusline[0]),rgbstatus); gtk_image_set_from_stock(GTK_IMAGE(ob->indicator[0]),rgbok, GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_label_set_text(GTK_LABEL(ob->statusline[1]),cmykstatus); gtk_image_set_from_stock(GTK_IMAGE(ob->indicator[1]),cmykok, GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_label_set_text(GTK_LABEL(ob->statusline[2]),monstatus); gtk_image_set_from_stock(GTK_IMAGE(ob->indicator[2]),monok, GTK_ICON_SIZE_SMALL_TOOLBAR); }
static void _setup_ui (OlPlayerChooser *window) { OlPlayerChooserPrivate *priv = OL_PLAYER_CHOOSER_GET_PRIVATE (window); /* Setup info widgets */ priv->info_label = GTK_LABEL (gtk_label_new (NULL)); gtk_label_set_line_wrap (priv->info_label, TRUE); gtk_misc_set_alignment (GTK_MISC (priv->info_label), 0.0, 0.0); priv->info_icon = GTK_IMAGE (gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG)); GtkWidget *info_box = gtk_hbox_new (FALSE, 10); gtk_box_pack_start (GTK_BOX (info_box), GTK_WIDGET (priv->info_icon), FALSE, /* expand */ FALSE, /* fill */ 0); gtk_box_pack_start (GTK_BOX (info_box), GTK_WIDGET (priv->info_label), TRUE, /* expand */ TRUE, /* fill */ 0); /* Setup app choosers */ priv->page_button_panel = GTK_BOX (gtk_hbox_new (FALSE, 0)); priv->chooser_panel = GTK_BOX (gtk_hbox_new (FALSE, 0)); _new_page (window, _("Supported players")); _new_page (window, _("All players")); _set_apps_to_page (window, ALL_CHOOSER_INDEX, g_app_info_get_all_for_type ("audio/mp3")); GtkWidget *apps_frame = gtk_frame_new (_("Choose a player to launch")); GtkBox *page_vbox = GTK_BOX (gtk_vbox_new (FALSE, 0)); gtk_widget_show (GTK_WIDGET (page_vbox)); gtk_box_pack_start (page_vbox, GTK_WIDGET (priv->page_button_panel), FALSE, /* expand */ FALSE, /* fill */ 0); /* padding */ gtk_box_pack_end (page_vbox, GTK_WIDGET (priv->chooser_panel), FALSE, /* expand */ FALSE, /* fill */ 0); /* padding */ gtk_container_add (GTK_CONTAINER (apps_frame), GTK_WIDGET (page_vbox)); /* Setup custom command */ priv->custom_cmd_panel = GTK_BOX (gtk_hbox_new (FALSE, 5)); GtkWidget *cmd_label = gtk_label_new (_("Use command:")); GtkWidget *cmd_entry = gtk_entry_new (); priv->cmd_entry = GTK_ENTRY (cmd_entry); gtk_entry_set_activates_default (priv->cmd_entry, TRUE); gtk_entry_set_completion (priv->cmd_entry, _new_bin_completion ()); GtkWidget *launch_button = gtk_button_new_with_label (_("Launch")); gtk_widget_set_can_default (launch_button, TRUE); gtk_window_set_default (GTK_WINDOW (window), launch_button); priv->launch_button = launch_button; g_signal_connect (launch_button, "clicked", G_CALLBACK (_launch_button_clicked_cb), window); gtk_box_pack_start (priv->custom_cmd_panel, cmd_label, FALSE, TRUE, 0); gtk_box_pack_start (priv->custom_cmd_panel, cmd_entry, TRUE, TRUE, 0); gtk_box_pack_start (priv->custom_cmd_panel, launch_button, FALSE, TRUE, 0); GtkWidget *final_hbox = gtk_hbox_new (FALSE, 0); GtkWidget *remember_button = gtk_check_button_new_with_label (_("Remember my choice")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (remember_button), TRUE); priv->remember_button = remember_button; gtk_box_pack_start (GTK_BOX (final_hbox), remember_button, FALSE, TRUE, 0); /* Setup the whole dialog */ GtkWidget *vbox = gtk_dialog_get_content_area (GTK_DIALOG (window)); gtk_box_set_spacing (GTK_BOX (vbox), 10); gtk_box_pack_start (GTK_BOX (vbox), info_box, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), apps_frame, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (priv->custom_cmd_panel), FALSE, TRUE, 0); gtk_box_pack_end (GTK_BOX (vbox), final_hbox, FALSE, TRUE, 0); gtk_widget_show (vbox); gtk_widget_show_all (info_box); gtk_widget_show (apps_frame); gtk_widget_show_all (GTK_WIDGET (priv->page_button_panel)); gtk_widget_show (GTK_WIDGET (priv->chooser_panel)); gtk_widget_show_all (GTK_WIDGET (priv->custom_cmd_panel)); gtk_widget_show_all (GTK_WIDGET (final_hbox)); gtk_dialog_add_button (GTK_DIALOG (window), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); gtk_window_set_title (GTK_WINDOW (window), _("Choose a player to launch")); gtk_window_set_resizable (GTK_WINDOW (window), FALSE); gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER); }
static void anjuta_docman_page_init (AnjutaDocman *docman, IAnjutaDocument *doc, GFile* file, AnjutaDocmanPage *page) { GtkWidget *close_button; GtkWidget *close_pixmap; GtkWidget *label, *menu_label; GtkWidget *box, *menu_box; GtkWidget *event_hbox; GtkWidget *event_box; gint h, w; GdkColor color; const gchar *filename; gchar *ruri; g_return_if_fail (IANJUTA_IS_DOCUMENT (doc)); gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h); close_pixmap = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); gtk_widget_show (close_pixmap); /* setup close button, zero out {x,y} thickness to get smallest possible size */ close_button = gtk_button_new(); gtk_button_set_focus_on_click (GTK_BUTTON (close_button), FALSE); gtk_container_add(GTK_CONTAINER(close_button), close_pixmap); gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE); gtk_widget_set_name (close_button, "anjuta-tab-close-button"); gtk_widget_set_size_request (close_button, w, h); gtk_widget_set_tooltip_text (close_button, _("Close file")); filename = ianjuta_document_get_filename (doc, NULL); label = gtk_label_new (filename); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_widget_show (label); menu_label = gtk_label_new (filename); gtk_misc_set_alignment (GTK_MISC (menu_label), 0.0, 0.5); gtk_widget_show (menu_label); menu_box = gtk_hbox_new(FALSE, 2); color.red = 0; color.green = 0; color.blue = 0; gtk_widget_modify_fg (close_button, GTK_STATE_NORMAL, &color); gtk_widget_modify_fg (close_button, GTK_STATE_INSENSITIVE, &color); gtk_widget_modify_fg (close_button, GTK_STATE_ACTIVE, &color); gtk_widget_modify_fg (close_button, GTK_STATE_PRELIGHT, &color); gtk_widget_modify_fg (close_button, GTK_STATE_SELECTED, &color); gtk_widget_show(close_button); box = gtk_hbox_new (FALSE, 2); /* create our layout/event boxes */ event_box = gtk_event_box_new(); gtk_event_box_set_visible_window (GTK_EVENT_BOX (event_box), FALSE); event_hbox = gtk_hbox_new (FALSE, 2); page->menu_icon = gtk_image_new(); page->mime_icon = gtk_image_new(); gtk_box_pack_start (GTK_BOX (event_hbox), page->mime_icon, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (menu_box), page->menu_icon, FALSE, FALSE, 0); if (file != NULL) { GdkPixbuf* pixbuf = anjuta_docman_get_pixbuf_for_file (file); if (pixbuf != NULL) { gtk_image_set_from_pixbuf (GTK_IMAGE (page->menu_icon), pixbuf); gtk_image_set_from_pixbuf (GTK_IMAGE (page->mime_icon), pixbuf); g_object_unref (pixbuf); } ruri = g_file_get_parse_name (file); if (ruri != NULL) { /* set the tab-tooltip */ gchar *tip; tip = g_markup_printf_escaped ("<b>%s</b> %s", _("Path:"), ruri); gtk_widget_set_tooltip_markup (event_box, tip); g_free (ruri); g_free (tip); } } gtk_box_pack_start (GTK_BOX (event_hbox), label, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (event_hbox), close_button, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (event_box), event_hbox); /* setup the data hierarchy */ g_object_set_data (G_OBJECT (box), "event_box", event_box); /* pack our top-level layout box */ gtk_box_pack_start (GTK_BOX (box), event_box, TRUE, TRUE, 0); /* show the widgets of the tab */ gtk_widget_show_all(box); /* menu box */ gtk_box_pack_start (GTK_BOX (menu_box), menu_label, TRUE, TRUE, 0); gtk_widget_show_all (menu_box); /* main box */ g_signal_connect (G_OBJECT (close_button), "clicked", G_CALLBACK (on_notebook_page_close_button_click), docman); g_signal_connect (G_OBJECT (close_button), "enter", G_CALLBACK (on_notebook_page_close_button_enter), page); g_signal_connect (G_OBJECT (close_button), "leave", G_CALLBACK (on_notebook_page_close_button_leave), page); g_signal_connect (G_OBJECT (box), "button-press-event", G_CALLBACK (on_notebook_tab_btnpress), docman); g_signal_connect (G_OBJECT (box), "button-release-event", G_CALLBACK (on_notebook_tab_btnrelease), docman); page->widget = GTK_WIDGET (doc); /* this is the notebook-page child widget */ page->doc = doc; page->box = box; page->close_image = close_pixmap; page->close_button = close_button; page->label = label; page->menu_box = menu_box; page->menu_label = menu_label; gtk_widget_show_all (page->widget); }
static void update_icon(ShowDesktopData* sdd) { GtkStyleContext *context; GtkStateFlags state; GtkBorder padding; int width, height; cairo_surface_t* icon; cairo_surface_t* scaled; int icon_size, icon_scale; GError* error; int thickness = 0; if (!sdd->icon_theme) return; state = gtk_widget_get_state_flags (sdd->button); context = gtk_widget_get_style_context (sdd->button); gtk_style_context_get_padding (context, state, &padding); switch (sdd->orient) { case GTK_ORIENTATION_HORIZONTAL: thickness = padding.top + padding.bottom; break; case GTK_ORIENTATION_VERTICAL: thickness = padding.left + padding.right; break; } icon_scale = gtk_widget_get_scale_factor (sdd->button); icon_size = sdd->size * icon_scale - thickness; if (icon_size < 22) icon_size = 16; else if (icon_size < 24) icon_size = 22; else if (icon_size < 32) icon_size = 24; else if (icon_size < 48) icon_size = 32; else if (icon_size < 64) icon_size = 48; else if (icon_size < 128) icon_size = 64; error = NULL; icon = gtk_icon_theme_load_surface (sdd->icon_theme, SHOW_DESKTOP_ICON, icon_size, icon_scale, NULL, 0, &error); if (icon == NULL) { g_printerr(_("Failed to load %s: %s\n"), SHOW_DESKTOP_ICON, error ? error->message : _("Icon not found")); if (error) { g_error_free(error); error = NULL; } gtk_image_set_from_icon_name (GTK_IMAGE (sdd->image), "image-missing", GTK_ICON_SIZE_SMALL_TOOLBAR); return; } width = cairo_image_surface_get_width (icon); height = cairo_image_surface_get_height (icon); scaled = NULL; /* Make it fit on the given panel */ switch (sdd->orient) { case GTK_ORIENTATION_HORIZONTAL: width = (icon_size / icon_scale * width) / height; height = icon_size / icon_scale; break; case GTK_ORIENTATION_VERTICAL: height = (icon_size / icon_scale * height) / width; width = icon_size / icon_scale; break; } scaled = cairo_surface_create_similar (icon, cairo_surface_get_content (icon), width, height); if (scaled != NULL) { cairo_t *cr; cr = cairo_create (scaled); cairo_scale (cr, (double) width / icon_size, (double) height / icon_size); cairo_set_source_surface (cr, icon, 0, 0); cairo_paint (cr); gtk_image_set_from_surface (GTK_IMAGE(sdd->image), scaled); cairo_surface_destroy (scaled); } else { gtk_image_set_from_surface (GTK_IMAGE (sdd->image), icon); } cairo_surface_destroy (icon); }
gboolean anjuta_docman_save_document_as (AnjutaDocman *docman, IAnjutaDocument *doc, GtkWidget *parent_window) { gchar* uri; GFile* file; const gchar* filename; GtkWidget *parent; GtkWidget *dialog; gint response; gboolean file_saved = TRUE; g_return_val_if_fail (ANJUTA_IS_DOCMAN (docman), FALSE); g_return_val_if_fail (IANJUTA_IS_DOCUMENT (doc), FALSE); if (parent_window) { parent = parent_window; } else { parent = gtk_widget_get_toplevel (GTK_WIDGET (docman)); } dialog = create_file_save_dialog_gui (GTK_WINDOW (parent), docman); if ((file = ianjuta_file_get_file (IANJUTA_FILE (doc), NULL)) != NULL) { gchar* file_uri = g_file_get_uri (file); gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (dialog), file_uri); g_free (file_uri); g_object_unref (file); } else if ((filename = ianjuta_document_get_filename (doc, NULL)) != NULL) gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), filename); else gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), ""); response = gtk_dialog_run (GTK_DIALOG (dialog)); if (response != GTK_RESPONSE_ACCEPT) { gtk_widget_destroy (dialog); return FALSE; } uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog)); file = g_file_new_for_uri (uri); if (g_file_query_exists (file, NULL)) { GtkWidget *msg_dialog; gchar* parse_uri = g_file_get_parse_name (file); msg_dialog = gtk_message_dialog_new (GTK_WINDOW (dialog), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, _("The file '%s' already exists.\n" "Do you want to replace it with the" " one you are saving?"), parse_uri); g_free (parse_uri); gtk_dialog_add_button (GTK_DIALOG (msg_dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); anjuta_util_dialog_add_button (GTK_DIALOG (msg_dialog), _("_Replace"), GTK_STOCK_REFRESH, GTK_RESPONSE_YES); if (gtk_dialog_run (GTK_DIALOG (msg_dialog)) == GTK_RESPONSE_YES) ianjuta_file_savable_save_as (IANJUTA_FILE_SAVABLE (doc), file, NULL); else file_saved = FALSE; gtk_widget_destroy (msg_dialog); } else { ianjuta_file_savable_save_as (IANJUTA_FILE_SAVABLE (doc), file, NULL); } if (anjuta_preferences_get_bool (ANJUTA_PREFERENCES (docman->priv->preferences), EDITOR_TABS_ORDERING)) anjuta_docman_order_tabs (docman); gtk_widget_destroy (dialog); g_free (uri); if (file_saved) { /* Update mime icons */ AnjutaDocmanPage* page = anjuta_docman_get_page_for_document (docman, doc); GdkPixbuf* pixbuf = anjuta_docman_get_pixbuf_for_file (file); if (pixbuf) { gtk_image_set_from_pixbuf (GTK_IMAGE(page->menu_icon), pixbuf); gtk_image_set_from_pixbuf (GTK_IMAGE(page->mime_icon), pixbuf); g_object_unref (pixbuf); } } g_object_unref (file); return file_saved; }
void update_sidepanel() { int i; for(i = 0; i < BUFFER_COUNT; i++) { if(icons[i] != NULL) { gtk_widget_hide(icons[i]); gtk_widget_destroy(icons[i]); gtk_widget_hide(icon_event_boxes[i]); gtk_widget_destroy(icon_event_boxes[i]); icons[i] = NULL; icon_event_boxes[i] = NULL; } } for(i = 0; i < BUFFER_COUNT; i++) { if(mdata[i] != NULL) { if(i == current_buffer) { if(selected_buffer_frame != NULL) gtk_widget_destroy(selected_buffer_frame); selected_buffer_frame = gtk_frame_new(NULL); #ifdef GTK2 GdkColor color; gdk_color_parse("red", &color); gtk_widget_modify_bg(selected_buffer_frame, GTK_STATE_NORMAL, &color); #else GdkRGBA color; gdk_rgba_parse(&color, "red"); gtk_widget_override_background_color(selected_buffer_frame, GTK_STATE_NORMAL, &color); #endif gtk_box_pack_start(GTK_BOX(list_vbox), selected_buffer_frame, FALSE, TRUE, 1); icons[i] = gtk_image_new(); icon_event_boxes[i] = gtk_event_box_new(); gtk_image_set_from_pixbuf(GTK_IMAGE(icons[i]), get_pixbuf_from_data(mdata[i], 0)); gtk_container_add(GTK_CONTAINER(selected_buffer_frame), icon_event_boxes[i]); gtk_container_add(GTK_CONTAINER(icon_event_boxes[i]), icons[i]); gtk_widget_show(icons[i]); gtk_widget_show(icon_event_boxes[i]); gtk_widget_show(selected_buffer_frame); g_signal_connect(G_OBJECT(icon_event_boxes[i]), "button_press_event", G_CALLBACK(buffer_callback), (gpointer *)(size_t)i); } else { icons[i] = gtk_image_new(); icon_event_boxes[i] = gtk_event_box_new(); gtk_image_set_from_pixbuf(GTK_IMAGE(icons[i]), get_pixbuf_from_data(mdata[i], 0)); gtk_box_pack_start(GTK_BOX(list_vbox), icon_event_boxes[i], FALSE, TRUE, 2); gtk_container_add(GTK_CONTAINER(icon_event_boxes[i]), icons[i]); gtk_widget_show(icons[i]); gtk_widget_show(icon_event_boxes[i]); g_signal_connect(G_OBJECT(icon_event_boxes[i]), "button_press_event", G_CALLBACK(buffer_callback), (gpointer *)(size_t)i); } } } }
int _makePinpad (GtkWidget *window) { GtkWidget *grid; GtkWidget *button; gtk_init_check (0, NULL); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "Grid"); g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); gtk_container_set_border_width (GTK_CONTAINER (window), 10); grid = gtk_grid_new (); gtk_container_add (GTK_CONTAINER (window), grid); GtkSettings *default_settings = gtk_settings_get_default(); g_object_set(default_settings, "gtk-button-images", TRUE, NULL); GtkWidget *buttonImage0; GtkWidget *buttonImage1; GtkWidget *buttonImage2; GtkWidget *buttonImage3; GtkWidget *buttonImage4; GtkWidget *buttonImage5; GtkWidget *buttonImage6; GtkWidget *buttonImage7; GtkWidget *buttonImage8; GtkWidget *buttonImage9; buttonImage0 = gtk_image_new(); buttonImage1 = gtk_image_new(); buttonImage2 = gtk_image_new(); buttonImage3 = gtk_image_new(); buttonImage4 = gtk_image_new(); buttonImage5 = gtk_image_new(); buttonImage6 = gtk_image_new(); buttonImage7 = gtk_image_new(); buttonImage8 = gtk_image_new(); buttonImage9 = gtk_image_new(); gtk_image_set_from_file(GTK_IMAGE(buttonImage0),"pinpad/0.jpg"); gtk_image_set_from_file(GTK_IMAGE(buttonImage1),"pinpad/1.jpg"); gtk_image_set_from_file(GTK_IMAGE(buttonImage2),"pinpad/2.jpg"); gtk_image_set_from_file(GTK_IMAGE(buttonImage3),"pinpad/3.jpg"); gtk_image_set_from_file(GTK_IMAGE(buttonImage4),"pinpad/4.jpg"); gtk_image_set_from_file(GTK_IMAGE(buttonImage5),"pinpad/5.jpg"); gtk_image_set_from_file(GTK_IMAGE(buttonImage6),"pinpad/6.jpg"); gtk_image_set_from_file(GTK_IMAGE(buttonImage7),"pinpad/7.jpg"); gtk_image_set_from_file(GTK_IMAGE(buttonImage8),"pinpad/8.jpg"); gtk_image_set_from_file(GTK_IMAGE(buttonImage9),"pinpad/9.jpg"); button = gtk_button_new_with_label ("1"); gtk_button_set_image((GtkButton *)button, buttonImage0); g_signal_connect (button, "clicked", G_CALLBACK (handleClick), GINT_TO_POINTER('1')); gtk_grid_attach (GTK_GRID (grid), button, 0, 0, 1, 1); button = gtk_button_new_with_label ("2"); gtk_button_set_image((GtkButton *)button, buttonImage1); g_signal_connect (button, "clicked", G_CALLBACK (handleClick), GINT_TO_POINTER('2')); gtk_grid_attach (GTK_GRID (grid), button, 1, 0, 1, 1); button = gtk_button_new_with_label ("3"); gtk_button_set_image((GtkButton *)button, buttonImage2); g_signal_connect (button, "clicked", G_CALLBACK (handleClick), GINT_TO_POINTER('3')); gtk_grid_attach (GTK_GRID (grid), button, 2, 0, 1, 1); button = gtk_button_new_with_label ("4"); gtk_button_set_image((GtkButton *)button, buttonImage3); g_signal_connect (button, "clicked", G_CALLBACK (handleClick), GINT_TO_POINTER('4')); gtk_grid_attach (GTK_GRID (grid), button, 0, 1, 1, 1); button = gtk_button_new_with_label ("5"); gtk_button_set_image((GtkButton *)button, buttonImage4); g_signal_connect (button, "clicked", G_CALLBACK (handleClick), GINT_TO_POINTER('5')); gtk_grid_attach (GTK_GRID (grid), button, 1, 1, 1, 1); button = gtk_button_new_with_label ("6"); gtk_button_set_image((GtkButton *)button, buttonImage5); g_signal_connect (button, "clicked", G_CALLBACK (handleClick), GINT_TO_POINTER('6')); gtk_grid_attach (GTK_GRID (grid), button, 2, 1, 1, 1); button = gtk_button_new_with_label ("7"); gtk_button_set_image((GtkButton *)button, buttonImage6); g_signal_connect (button, "clicked", G_CALLBACK (handleClick), GINT_TO_POINTER('7')); gtk_grid_attach (GTK_GRID (grid), button, 0, 2, 1, 1); button = gtk_button_new_with_label ("8"); gtk_button_set_image((GtkButton *)button, buttonImage7); g_signal_connect (button, "clicked", G_CALLBACK (handleClick), GINT_TO_POINTER('8')); gtk_grid_attach (GTK_GRID (grid), button, 1, 2, 1, 1); button = gtk_button_new_with_label ("9"); gtk_button_set_image((GtkButton *)button, buttonImage8); g_signal_connect (button, "clicked", G_CALLBACK (handleClick), GINT_TO_POINTER('9')); gtk_grid_attach (GTK_GRID (grid), button, 2, 2, 1, 1); button = gtk_button_new_with_label ("0"); gtk_button_set_image((GtkButton *)button, buttonImage9); g_signal_connect (button, "clicked", G_CALLBACK (handleClick), GINT_TO_POINTER('0')); gtk_grid_attach (GTK_GRID (grid), button, 1, 3, 1, 1); button = gtk_button_new_with_label ("OK"); g_signal_connect (button, "clicked", G_CALLBACK (click_ok), (gpointer)window); gtk_grid_attach (GTK_GRID (grid), button, 0, 4, 3, 2); gtk_widget_show_all (window); gtk_main(); return 0; }
static gint on_ask_rename(FmFileOpsJob* job, FmFileInfo* src, FmFileInfo* dest, char** new_name, FmProgressDisplay* data) { int res; GtkBuilder* builder; GtkDialog *dlg; GtkImage *src_icon, *dest_icon; GtkLabel *src_fi, *dest_fi; GtkEntry *filename; GtkToggleButton *apply_all; char* tmp; const char* disp_size; FmPath* path; FmIcon* icon; FmFileOpOption options; gboolean no_valid_dest; /* return default operation if the user has set it */ if(data->default_opt) return data->default_opt; no_valid_dest = (fm_file_info_get_desc(dest) == NULL); builder = gtk_builder_new(); path = fm_file_info_get_path(dest); icon = fm_file_info_get_icon(src); if(data->timer) g_timer_stop(data->timer); gtk_builder_set_translation_domain(builder, GETTEXT_PACKAGE); ensure_dlg(data); gtk_builder_add_from_file(builder, PACKAGE_UI_DIR "/ask-rename.ui", NULL); dlg = GTK_DIALOG(gtk_builder_get_object(builder, "dlg")); src_icon = GTK_IMAGE(gtk_builder_get_object(builder, "src_icon")); src_fi = GTK_LABEL(gtk_builder_get_object(builder, "src_fi")); dest_icon = GTK_IMAGE(gtk_builder_get_object(builder, "dest_icon")); dest_fi = GTK_LABEL(gtk_builder_get_object(builder, "dest_fi")); filename = GTK_ENTRY(gtk_builder_get_object(builder, "filename")); apply_all = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "apply_all")); gtk_window_set_transient_for(GTK_WINDOW(dlg), GTK_WINDOW(data->dlg)); gtk_image_set_from_gicon(src_icon, G_ICON(icon), GTK_ICON_SIZE_DIALOG); disp_size = fm_file_info_get_disp_size(src); if(disp_size) { tmp = g_strdup_printf(_("Type: %s\nSize: %s\nModified: %s"), fm_file_info_get_desc(src), disp_size, fm_file_info_get_disp_mtime(src)); } else { tmp = g_strdup_printf(_("Type: %s\nModified: %s"), fm_file_info_get_desc(src), fm_file_info_get_disp_mtime(src)); } gtk_label_set_text(src_fi, tmp); g_free(tmp); gtk_image_set_from_gicon(dest_icon, G_ICON(icon), GTK_ICON_SIZE_DIALOG); disp_size = fm_file_info_get_disp_size(dest); if(disp_size) { tmp = g_strdup_printf(_("Type: %s\nSize: %s\nModified: %s"), fm_file_info_get_desc(dest), disp_size, fm_file_info_get_disp_mtime(dest)); } else if (no_valid_dest) { tmp = NULL; gtk_widget_destroy(GTK_WIDGET(dest_icon)); gtk_widget_destroy(GTK_WIDGET(dest_fi)); /* FIXME: change texts in dialog appropriately */ } else { tmp = g_strdup_printf(_("Type: %s\nModified: %s"), fm_file_info_get_desc(dest), fm_file_info_get_disp_mtime(dest)); } if (tmp) gtk_label_set_text(dest_fi, tmp); g_free(tmp); options = fm_file_ops_job_get_options(job); if (!(options & FM_FILE_OP_RENAME)) { GtkWidget *widget = GTK_WIDGET(gtk_builder_get_object(builder, "rename")); gtk_widget_destroy(widget); } if (!(options & FM_FILE_OP_OVERWRITE) || no_valid_dest) { GtkWidget *widget = GTK_WIDGET(gtk_builder_get_object(builder, "overwrite")); gtk_widget_destroy(widget); } if (!(options & FM_FILE_OP_SKIP)) { GtkWidget *widget = GTK_WIDGET(gtk_builder_get_object(builder, "skip")); gtk_widget_destroy(widget); } tmp = g_filename_display_name(fm_path_get_basename(path)); gtk_entry_set_text(filename, tmp); g_object_set_data_full(G_OBJECT(filename), "old_name", tmp, g_free); g_signal_connect(filename, "changed", G_CALLBACK(on_filename_changed), gtk_builder_get_object(builder, "rename")); g_object_unref(builder); res = gtk_dialog_run(dlg); switch(res) { case RESPONSE_RENAME: *new_name = g_strdup(gtk_entry_get_text(filename)); res = FM_FILE_OP_RENAME; break; case RESPONSE_OVERWRITE: res = FM_FILE_OP_OVERWRITE; break; case RESPONSE_SKIP: res = FM_FILE_OP_SKIP; break; default: res = FM_FILE_OP_CANCEL; } if(gtk_toggle_button_get_active(apply_all)) { if(res == RESPONSE_OVERWRITE || res == FM_FILE_OP_SKIP) data->default_opt = res; } gtk_widget_destroy(GTK_WIDGET(dlg)); if(data->timer) g_timer_continue(data->timer); return res; }
static void sync_dialog_netarea_start_actions(SyncDialog * sd, SyncNetAction sna[], gint n) { gint i; GtkWidget **labels; GtkWidget **icons; GdkPixbuf *done_icon = icon_cache_get_pixbuf("status-done.png"); GdkPixbuf *curr_icon = icon_cache_get_pixbuf("status-curr.png"); labels = g_new0(GtkWidget *, n); icons = g_new0(GtkWidget *, n); for (i = 0; i < n; i++) { GtkWidget *hbox; hbox = gtk_hbox_new(FALSE, 5); labels[i] = gtk_label_new(sna[i].name); icons[i] = gtk_image_new(); gtk_widget_set_size_request(icons[i], gdk_pixbuf_get_width(done_icon), gdk_pixbuf_get_height(done_icon)); gtk_label_set_use_markup(GTK_LABEL(labels[i]), TRUE); gtk_misc_set_alignment(GTK_MISC(labels[i]), 0.0, 0.5); gtk_box_pack_start(GTK_BOX(hbox), icons[i], FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), labels[i], TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(sd->sna->vbox), hbox, FALSE, FALSE, 3); gtk_widget_show_all(hbox); } while (gtk_events_pending()) gtk_main_iteration(); for (i = 0; i < n; i++) { gchar *markup; if (sd->flag_cancel) { markup = g_strdup_printf("<s>%s</s> <i>(canceled)</i>", sna[i].name); gtk_label_set_markup(GTK_LABEL(labels[i]), markup); g_free(markup); gtk_image_set_from_pixbuf(GTK_IMAGE(icons[i]), icon_cache_get_pixbuf ("dialog-error.png")); break; } markup = g_strdup_printf("<b>%s</b>", sna[i].name); gtk_label_set_markup(GTK_LABEL(labels[i]), markup); g_free(markup); gtk_image_set_from_pixbuf(GTK_IMAGE(icons[i]), curr_icon); if (sna[i].do_action && !sna[i].do_action(sd, &sna[i])) { markup = g_strdup_printf("<b><s>%s</s></b> <i>(failed)</i>", sna[i].name); gtk_label_set_markup(GTK_LABEL(labels[i]), markup); g_free(markup); sd->flag_cancel = TRUE; gtk_image_set_from_pixbuf(GTK_IMAGE(icons[i]), icon_cache_get_pixbuf ("dialog-error.png")); if (sna[i].error) { if (sna[i].error->code != 1) { /* the user has not cancelled something... */ g_warning ("Failed while performing \"%s\". Please file a bug report " "if this problem persists. (Use the Help\342\206\222Report" " bug option.)\n\nDetails: %s", sna[i].name, sna[i].error->message); } g_error_free(sna[i].error); } else { g_warning ("Failed while performing \"%s\". Please file a bug report " "if this problem persists. (Use the Help\342\206\222Report" " bug option.)", sna[i].name); } break; } gtk_image_set_from_pixbuf(GTK_IMAGE(icons[i]), done_icon); gtk_label_set_markup(GTK_LABEL(labels[i]), sna[i].name); } g_free(labels); g_free(icons); }
static gboolean event_box_button_press_event (GtkWidget *widget, GdkEventButton *event, GConfChangeSet *changeset) { gint double_click_time; GConfValue *value; static struct test_data_t data; static gint test_on_timeout_id = 0; static gint test_maybe_timeout_id = 0; static guint32 double_click_timestamp = 0; GtkWidget *image; GConfClient *client; if (event->type != GDK_BUTTON_PRESS) return FALSE; image = g_object_get_data (G_OBJECT (widget), "image"); if (!(changeset && gconf_change_set_check_value (changeset, DOUBLE_CLICK_KEY, &value))) { client = gconf_client_get_default(); double_click_time = gconf_client_get_int (client, DOUBLE_CLICK_KEY, NULL); g_object_unref (client); } else double_click_time = gconf_value_get_int (value); if (test_maybe_timeout_id != 0) gtk_timeout_remove (test_maybe_timeout_id); if (test_on_timeout_id != 0) gtk_timeout_remove (test_on_timeout_id); switch (double_click_state) { case DOUBLE_CLICK_TEST_OFF: double_click_state = DOUBLE_CLICK_TEST_MAYBE; data.image = image; data.timeout_id = &test_maybe_timeout_id; test_maybe_timeout_id = gtk_timeout_add (double_click_time, (GtkFunction) test_maybe_timeout, &data); break; case DOUBLE_CLICK_TEST_MAYBE: if (event->time - double_click_timestamp < double_click_time) { double_click_state = DOUBLE_CLICK_TEST_ON; data.image = image; data.timeout_id = &test_on_timeout_id; test_on_timeout_id = gtk_timeout_add (2500, (GtkFunction) test_maybe_timeout, &data); } break; case DOUBLE_CLICK_TEST_ON: double_click_state = DOUBLE_CLICK_TEST_OFF; break; } double_click_timestamp = event->time; switch (double_click_state) { case DOUBLE_CLICK_TEST_ON: gtk_image_set_from_stock (GTK_IMAGE (image), MOUSE_DBLCLCK_ON, mouse_capplet_dblclck_icon_get_size()); break; case DOUBLE_CLICK_TEST_MAYBE: gtk_image_set_from_stock (GTK_IMAGE (image), MOUSE_DBLCLCK_MAYBE, mouse_capplet_dblclck_icon_get_size()); break; case DOUBLE_CLICK_TEST_OFF: gtk_image_set_from_stock (GTK_IMAGE (image), MOUSE_DBLCLCK_OFF, mouse_capplet_dblclck_icon_get_size()); break; } return TRUE; }
static GtkWidget * csm_get_dialog (CsmDialogLogoutType type, GdkScreen *screen, guint32 activate_time) { CsmLogoutDialog *logout_dialog; GtkWidget *dialog_image; const char *primary_text; const char *icon_name; if (current_dialog != NULL) { gtk_widget_destroy (GTK_WIDGET (current_dialog)); } logout_dialog = g_object_new (CSM_TYPE_LOGOUT_DIALOG, NULL); current_dialog = logout_dialog; gtk_window_set_title (GTK_WINDOW (logout_dialog), ""); logout_dialog->priv->type = type; icon_name = NULL; primary_text = NULL; switch (type) { case CSM_DIALOG_LOGOUT_TYPE_LOGOUT: icon_name = CSM_ICON_LOGOUT; primary_text = _("Log out of this system now?"); logout_dialog->priv->default_response = CSM_LOGOUT_RESPONSE_LOGOUT; if (csm_logout_supports_switch_user (logout_dialog)) { gtk_dialog_add_button (GTK_DIALOG (logout_dialog), _("_Switch User"), CSM_LOGOUT_RESPONSE_SWITCH_USER); } gtk_dialog_add_button (GTK_DIALOG (logout_dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); gtk_dialog_add_button (GTK_DIALOG (logout_dialog), _("_Log Out"), CSM_LOGOUT_RESPONSE_LOGOUT); break; case CSM_DIALOG_LOGOUT_TYPE_SHUTDOWN: icon_name = CSM_ICON_SHUTDOWN; primary_text = _("Shut down this system now?"); logout_dialog->priv->default_response = CSM_LOGOUT_RESPONSE_SHUTDOWN; if (csm_logout_supports_system_suspend (logout_dialog)) { gtk_dialog_add_button (GTK_DIALOG (logout_dialog), _("S_uspend"), CSM_LOGOUT_RESPONSE_SLEEP); } if (csm_logout_supports_system_hibernate (logout_dialog)) { gtk_dialog_add_button (GTK_DIALOG (logout_dialog), _("_Hibernate"), CSM_LOGOUT_RESPONSE_HIBERNATE); } if (csm_logout_supports_reboot (logout_dialog)) { gtk_dialog_add_button (GTK_DIALOG (logout_dialog), _("_Restart"), CSM_LOGOUT_RESPONSE_REBOOT); } gtk_dialog_add_button (GTK_DIALOG (logout_dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); if (csm_logout_supports_shutdown (logout_dialog)) { gtk_dialog_add_button (GTK_DIALOG (logout_dialog), _("_Shut Down"), CSM_LOGOUT_RESPONSE_SHUTDOWN); } break; case CSM_DIALOG_LOGOUT_TYPE_REBOOT: icon_name = CSM_ICON_SHUTDOWN; primary_text = _("Restart this system now?"); logout_dialog->priv->default_response = CSM_LOGOUT_RESPONSE_REBOOT; gtk_dialog_add_button (GTK_DIALOG (logout_dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); if (csm_logout_supports_reboot (logout_dialog)) { gtk_dialog_add_button (GTK_DIALOG (logout_dialog), _("_Restart"), CSM_LOGOUT_RESPONSE_REBOOT); } break; default: g_assert_not_reached (); } dialog_image = gtk_message_dialog_get_image (GTK_MESSAGE_DIALOG (logout_dialog)); gtk_image_set_from_icon_name (GTK_IMAGE (dialog_image), icon_name, GTK_ICON_SIZE_DIALOG); gtk_window_set_icon_name (GTK_WINDOW (logout_dialog), icon_name); gtk_window_set_position (GTK_WINDOW (logout_dialog), GTK_WIN_POS_CENTER_ALWAYS); gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (logout_dialog), primary_text); gtk_dialog_set_default_response (GTK_DIALOG (logout_dialog), logout_dialog->priv->default_response); gtk_window_set_screen (GTK_WINDOW (logout_dialog), screen); return GTK_WIDGET (logout_dialog); }
static void photos_preview_nav_buttons_constructed (GObject *object) { PhotosPreviewNavButtons *self = PHOTOS_PREVIEW_NAV_BUTTONS (object); GtkStyleContext *context; GtkWidget *button; GtkWidget *image; G_OBJECT_CLASS (photos_preview_nav_buttons_parent_class)->constructed (object); self->prev_widget = g_object_ref_sink (gtk_revealer_new ()); gtk_widget_set_halign (self->prev_widget, GTK_ALIGN_START); gtk_widget_set_margin_start (self->prev_widget, 30); gtk_widget_set_margin_end (self->prev_widget, 30); gtk_widget_set_valign (self->prev_widget, GTK_ALIGN_CENTER); gtk_revealer_set_transition_type (GTK_REVEALER (self->prev_widget), GTK_REVEALER_TRANSITION_TYPE_CROSSFADE); gtk_overlay_add_overlay (GTK_OVERLAY (self->overlay), self->prev_widget); image = gtk_image_new_from_icon_name (PHOTOS_ICON_GO_PREVIOUS_SYMBOLIC, GTK_ICON_SIZE_INVALID); gtk_image_set_pixel_size (GTK_IMAGE (image), 16); button = gtk_button_new (); gtk_button_set_image (GTK_BUTTON (button), image); gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "app.load-previous"); context = gtk_widget_get_style_context (button); gtk_style_context_add_class (context, "osd"); gtk_container_add (GTK_CONTAINER (self->prev_widget), button); g_signal_connect_swapped (button, "enter-notify-event", G_CALLBACK (photos_preview_nav_buttons_enter_notify), self); g_signal_connect_swapped (button, "leave-notify-event", G_CALLBACK (photos_preview_nav_buttons_leave_notify), self); self->next_widget = g_object_ref_sink (gtk_revealer_new ()); gtk_widget_set_halign (self->next_widget, GTK_ALIGN_END); gtk_widget_set_margin_start (self->next_widget, 30); gtk_widget_set_margin_end (self->next_widget, 30); gtk_widget_set_valign (self->next_widget, GTK_ALIGN_CENTER); gtk_revealer_set_transition_type (GTK_REVEALER (self->next_widget), GTK_REVEALER_TRANSITION_TYPE_CROSSFADE); gtk_overlay_add_overlay (GTK_OVERLAY (self->overlay), self->next_widget); image = gtk_image_new_from_icon_name (PHOTOS_ICON_GO_NEXT_SYMBOLIC, GTK_ICON_SIZE_INVALID); gtk_image_set_pixel_size (GTK_IMAGE (image), 16); button = gtk_button_new (); gtk_button_set_image (GTK_BUTTON (button), image); gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "app.load-next"); context = gtk_widget_get_style_context (button); gtk_style_context_add_class (context, "osd"); gtk_container_add (GTK_CONTAINER (self->next_widget), button); g_signal_connect_swapped (button, "enter-notify-event", G_CALLBACK (photos_preview_nav_buttons_enter_notify), self); g_signal_connect_swapped (button, "leave-notify-event", G_CALLBACK (photos_preview_nav_buttons_leave_notify), self); g_signal_connect_swapped (self->overlay, "motion-notify-event", G_CALLBACK (photos_preview_nav_buttons_motion_notify), self); self->long_press_gesture = gtk_gesture_long_press_new (self->preview_view); gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (self->long_press_gesture), TRUE); g_signal_connect_swapped (self->long_press_gesture, "pressed", G_CALLBACK (photos_preview_nav_buttons_long_press_pressed), self); self->tap_gesture = gtk_gesture_multi_press_new (self->preview_view); gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (self->tap_gesture), TRUE); gtk_gesture_group (self->long_press_gesture, self->tap_gesture); g_signal_connect_swapped (self->tap_gesture, "end", G_CALLBACK (photos_preview_nav_buttons_multi_press_end), self); /* We will not need them any more */ self->overlay = NULL; self->preview_view = NULL; }
gint register_action() { GtkWidget *window; GtkWidget *label; GtkWidget *entry_nickname, *entry_password, *entry_password2; GtkWidget *button, *button_male, *button_female; GtkWidget *spinner_year, *spinner_month, *spinner_day; GtkWidget *table; GSList *group; GtkAdjustment *adj; GtkWidget *image; window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "注册"); g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (close_current_window), window); gtk_container_set_border_width (GTK_CONTAINER (window), 20); gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER); table = gtk_table_new (8, 17, TRUE); gtk_table_set_row_spacing(GTK_TABLE (table), 0, 5 ); gtk_table_set_row_spacing(GTK_TABLE (table), 1, 5 ); gtk_table_set_row_spacing(GTK_TABLE (table), 2, 5 ); gtk_table_set_row_spacing(GTK_TABLE (table), 3, 5 ); gtk_container_add (GTK_CONTAINER (window), table); image = gtk_image_new(); gtk_image_set_from_file(GTK_IMAGE(image),"aaa.png"); gtk_table_attach_defaults (GTK_TABLE (table), image, 0, 4, 0, 10); label = gtk_label_new ("昵称:"); gtk_table_attach_defaults (GTK_TABLE (table), label, 4, 7, 0, 1); gtk_misc_set_alignment(GTK_MISC (label), 1, 0.5); gtk_widget_show (label); label = gtk_label_new ("密码:"); gtk_table_attach_defaults (GTK_TABLE (table), label, 4, 7, 1, 2); gtk_misc_set_alignment(GTK_MISC (label), 1, 0.5); gtk_widget_show (label); label = gtk_label_new ("确认密码:"); gtk_table_attach_defaults (GTK_TABLE (table), label, 4, 7, 2, 3); gtk_misc_set_alignment(GTK_MISC (label), 1, 0.5); gtk_widget_show (label); label = gtk_label_new ("性别:"); gtk_table_attach_defaults (GTK_TABLE (table), label, 4, 7, 3, 4); gtk_misc_set_alignment(GTK_MISC (label), 1, 0.5); gtk_widget_show (label); label = gtk_label_new ("生日:"); gtk_table_attach_defaults (GTK_TABLE (table), label, 4, 7, 4, 5); gtk_misc_set_alignment(GTK_MISC (label), 1, 0.5); gtk_widget_show (label); entry_nickname = gtk_entry_new (); gtk_entry_set_max_length (GTK_ENTRY (entry_nickname), 20); g_signal_connect (G_OBJECT (entry_nickname), "activate",G_CALLBACK (enter_nickname), entry_nickname); gtk_entry_set_text (GTK_ENTRY (entry_nickname), ""); gtk_editable_select_region (GTK_EDITABLE (entry_nickname),0, GTK_ENTRY (entry_nickname)->text_length); gtk_table_attach_defaults (GTK_TABLE (table), entry_nickname, 7,13, 0, 1); gtk_widget_show (entry_nickname); entry_password = gtk_entry_new (); gtk_entry_set_max_length (GTK_ENTRY (entry_password), 50); gtk_entry_set_text (GTK_ENTRY (entry_password), ""); gtk_editable_select_region (GTK_EDITABLE (entry_password),0, GTK_ENTRY (entry_password)->text_length); gtk_entry_set_visibility (GTK_ENTRY (entry_password),FALSE);// 是否***输出 gtk_table_attach_defaults (GTK_TABLE (table), entry_password, 7,13, 1, 2); gtk_widget_show (entry_password); entry_password2 = gtk_entry_new (); gtk_entry_set_max_length (GTK_ENTRY (entry_password2), 50); gtk_entry_set_text (GTK_ENTRY (entry_password2), ""); gtk_editable_select_region (GTK_EDITABLE (entry_password2),0, GTK_ENTRY (entry_password2)->text_length); gtk_entry_set_visibility (GTK_ENTRY (entry_password2),FALSE);// 是否***输出 gtk_table_attach_defaults (GTK_TABLE (table), entry_password2, 7,13, 2, 3); gtk_widget_show (entry_password2); button_male = gtk_radio_button_new_with_label (NULL, "男"); gtk_table_attach_defaults (GTK_TABLE (table), button_male, 7,10, 3, 4); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button_male), TRUE); gtk_widget_show (button_male); group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button_male)); button_female = gtk_radio_button_new_with_label (group, "女"); gtk_table_attach_defaults (GTK_TABLE (table), button_female,10,13, 3, 4); gtk_widget_show (button_female); label = gtk_label_new ("日:"); gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); gtk_table_attach_defaults (GTK_TABLE (table), label,11,13, 4, 5); adj = (GtkAdjustment *) gtk_adjustment_new (1.0, 1.0, 31.0, 1.0, 5.0, 0.0); spinner_day = gtk_spin_button_new (adj, 0, 0); gtk_spin_button_set_numeric(GTK_SPIN_BUTTON (spinner_day), TRUE ); gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner_day), TRUE); gtk_table_attach_defaults (GTK_TABLE (table), spinner_day,11,13, 5, 6); label = gtk_label_new ("月:"); gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); gtk_table_attach_defaults (GTK_TABLE (table), label, 9,11, 4, 5); adj = (GtkAdjustment *) gtk_adjustment_new (1.0, 1.0, 12.0, 1.0, 5.0, 0.0); spinner_month = gtk_spin_button_new (adj, 0, 0); gtk_spin_button_set_numeric(GTK_SPIN_BUTTON (spinner_month), TRUE ); gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner_month), TRUE); gtk_table_attach_defaults (GTK_TABLE (table), spinner_month, 9,11, 5, 6); label = gtk_label_new ("年:"); gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); gtk_table_attach_defaults (GTK_TABLE (table), label, 7, 9, 4, 5); adj = (GtkAdjustment *) gtk_adjustment_new (1950.0, 0.0, 2012.0, 1.0, 100.0, 0.0); spinner_year = gtk_spin_button_new (adj, 0, 0); gtk_spin_button_set_numeric(GTK_SPIN_BUTTON (spinner_year), TRUE ); gtk_spin_button_set_value(GTK_SPIN_BUTTON (spinner_year), 1993.0 ); gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner_year), FALSE); gtk_table_attach_defaults (GTK_TABLE (table), spinner_year, 7, 9, 5, 6); gtk_widget_set_size_request (spinner_year, 55, -1); button = gtk_button_new_with_label ("立即注册"); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (toggle_button_callback),GTK_TOGGLE_BUTTON(button_male)); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (return_year), spinner_year); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (return_month), spinner_month); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (return_day), spinner_day); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (enter_nickname), entry_nickname); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (enter_password), entry_password); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (enter_password2), entry_password2); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (checkpassword), table); //g_signal_connect_swapped (G_OBJECT (button), "clicked", //G_CALLBACK (delete_event), window); gtk_table_attach_defaults (GTK_TABLE (table), button, 7,13, 7, 9); gtk_widget_show_all (window); gtk_main (); //if ( nickname != '\0' && password != '\0' ) //{ struct reg *send_info; send_info=(struct reg *)malloc(sizeof(struct reg)); set_register(send_info); printf("%d\n",send_info->photo); send_reg(send_info, "10.3.2.126"); rec_reg(send_info); if (send_info->id != 0) { printf("%d\n",send_info->id); GtkWidget *window2; GtkWidget *table2; GtkWidget *button2; GtkWidget *label2; gchar* id_char; id_char=malloc(sizeof(char)*20); sprintf(id_char, "%d", send_info->id); window2= gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_position(GTK_WINDOW(window2),GTK_WIN_POS_CENTER); table2 = gtk_table_new (6, 4, TRUE); gtk_container_add (GTK_CONTAINER (window2), table2); gtk_widget_show(table2); label2 = gtk_label_new ("你的帐号是:"); gtk_table_attach_defaults (GTK_TABLE (table2), label2, 1, 3, 1, 2); gtk_misc_set_alignment(GTK_MISC (label2), 1, 0.5); gtk_widget_show (label2); label2 = gtk_label_new (id_char); gtk_table_attach_defaults (GTK_TABLE (table2), label2, 1, 3, 2, 3); gtk_label_set_selectable(GTK_LABEL(label2), TRUE); gtk_misc_set_alignment(GTK_MISC (label2), 0.5, 0.5); gtk_widget_show (label2); button2 = gtk_button_new_with_label ("立即登录"); gtk_table_attach_defaults (GTK_TABLE (table2), button2, 1, 3, 3, 4); g_signal_connect (G_OBJECT (button2), "clicked", G_CALLBACK (close_current_window), window2); g_signal_connect (G_OBJECT (button2), "clicked", G_CALLBACK (close_current_window), window); gtk_widget_show (button2); gtk_widget_show (window2); gtk_main (); } else { GtkWidget *window3; GtkWidget *table3; GtkWidget *button3; GtkWidget *label3; window3= gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_position(GTK_WINDOW(window3),GTK_WIN_POS_CENTER); table3 = gtk_table_new (6, 4, TRUE); gtk_container_add (GTK_CONTAINER (window3), table3); gtk_widget_show(table3); label3 = gtk_label_new ("注册失败"); gtk_table_attach_defaults (GTK_TABLE (table3), label3, 1, 3, 1,3 ); gtk_misc_set_alignment(GTK_MISC (label3), 0.5, 0.5); gtk_widget_show (label3); button3 = gtk_button_new_with_label ("重新注册"); gtk_table_attach_defaults (GTK_TABLE (table3), button3, 1, 3, 3, 4); g_signal_connect (G_OBJECT (button3), "clicked", G_CALLBACK (close_current_window), window3); g_signal_connect (G_OBJECT (button3), "clicked", G_CALLBACK (close_current_window), window); gtk_widget_show (button3); gtk_widget_show (window3); gtk_main (); //} } /* else { gtk_main_quit(); } */ return 0; }
static void update_icon(ShowDesktopData* sdd) { GtkStyleContext *context; GtkStateFlags state; GtkBorder padding; int width, height; GdkPixbuf* icon; GdkPixbuf* scaled; int icon_size; GError* error; #if !GTK_CHECK_VERSION (3, 20, 0) int focus_width = 0; int focus_pad = 0; #endif int thickness = 0; if (!sdd->icon_theme) return; state = gtk_widget_get_state_flags (sdd->button); context = gtk_widget_get_style_context (sdd->button); gtk_style_context_get_padding (context, state, &padding); #if !GTK_CHECK_VERSION (3, 20, 0) gtk_style_context_get_style (context, "focus-line-width", &focus_width, "focus-padding", &focus_pad, NULL); #endif switch (sdd->orient) { case GTK_ORIENTATION_HORIZONTAL: thickness = padding.top + padding.bottom; break; case GTK_ORIENTATION_VERTICAL: thickness = padding.left + padding.right; break; } #if GTK_CHECK_VERSION (3, 20, 0) icon_size = sdd->size - thickness; #else icon_size = sdd->size - 2 * (focus_width + focus_pad) - thickness; #endif if (icon_size < 22) icon_size = 16; else if (icon_size < 32) icon_size = 22; else if (icon_size < 48) icon_size = 32; error = NULL; icon = gtk_icon_theme_load_icon (sdd->icon_theme, SHOW_DESKTOP_ICON, icon_size, 0, &error); if (icon == NULL) { g_printerr(_("Failed to load %s: %s\n"), SHOW_DESKTOP_ICON, error ? error->message : _("Icon not found")); if (error) { g_error_free(error); error = NULL; } gtk_image_set_from_icon_name (GTK_IMAGE (sdd->image), "image-missing", GTK_ICON_SIZE_SMALL_TOOLBAR); return; } width = gdk_pixbuf_get_width(icon); height = gdk_pixbuf_get_height(icon); scaled = NULL; /* Make it fit on the given panel */ switch (sdd->orient) { case GTK_ORIENTATION_HORIZONTAL: width = (icon_size * width) / height; height = icon_size; break; case GTK_ORIENTATION_VERTICAL: height = (icon_size * height) / width; width = icon_size; break; } scaled = gdk_pixbuf_scale_simple(icon, width, height, GDK_INTERP_BILINEAR); if (scaled != NULL) { gtk_image_set_from_pixbuf(GTK_IMAGE(sdd->image), scaled); g_object_unref(scaled); } else { gtk_image_set_from_pixbuf (GTK_IMAGE (sdd->image), icon); } g_object_unref (icon); }
static void photos_empty_results_box_constructed (GObject *object) { PhotosEmptyResultsBox *self = PHOTOS_EMPTY_RESULTS_BOX (object); PhotosEmptyResultsBoxPrivate *priv = self->priv; GtkStyleContext *context; GtkWidget *image; GtkWidget *title_label; gchar *label; G_OBJECT_CLASS (photos_empty_results_box_parent_class)->constructed (object); gtk_widget_set_halign (GTK_WIDGET (self), GTK_ALIGN_CENTER); gtk_widget_set_hexpand (GTK_WIDGET (self), TRUE); gtk_widget_set_valign (GTK_WIDGET (self), GTK_ALIGN_CENTER); gtk_widget_set_vexpand (GTK_WIDGET (self), TRUE); gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_HORIZONTAL); gtk_grid_set_column_spacing (GTK_GRID (self), 12); context = gtk_widget_get_style_context (GTK_WIDGET (self)); gtk_style_context_add_class (context, "dim-label"); image = gtk_image_new_from_icon_name (PHOTOS_ICON_PHOTOS_SYMBOLIC, GTK_ICON_SIZE_INVALID); gtk_image_set_pixel_size (GTK_IMAGE (image), 64); gtk_container_add (GTK_CONTAINER (self), image); priv->labels_grid = gtk_grid_new (); gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->labels_grid), GTK_ORIENTATION_VERTICAL); gtk_grid_set_row_spacing (GTK_GRID (priv->labels_grid), 12); gtk_container_add (GTK_CONTAINER (self), priv->labels_grid); switch (priv->mode) { case PHOTOS_WINDOW_MODE_COLLECTIONS: label = g_strconcat ("<b><span size=\"large\">", _("No Albums Found"), "</span></b>", NULL); break; case PHOTOS_WINDOW_MODE_FAVORITES: label = g_strconcat ("<b><span size=\"large\">", _("No Favorites Found"), "</span></b>", NULL); break; case PHOTOS_WINDOW_MODE_OVERVIEW: case PHOTOS_WINDOW_MODE_SEARCH: label = g_strconcat ("<b><span size=\"large\">", _("No Photos Found"), "</span></b>", NULL); break; default: g_assert_not_reached (); break; } title_label = gtk_label_new (label); gtk_widget_set_halign (title_label, GTK_ALIGN_START); gtk_widget_set_vexpand (title_label, TRUE); gtk_label_set_use_markup (GTK_LABEL (title_label), TRUE); gtk_container_add (GTK_CONTAINER (priv->labels_grid), title_label); g_free (label); switch (priv->mode) { case PHOTOS_WINDOW_MODE_COLLECTIONS: gtk_widget_set_valign (title_label, GTK_ALIGN_START); photos_empty_results_box_add_collections_label (self); break; case PHOTOS_WINDOW_MODE_FAVORITES: case PHOTOS_WINDOW_MODE_SEARCH: gtk_widget_set_valign (title_label, GTK_ALIGN_CENTER); break; case PHOTOS_WINDOW_MODE_OVERVIEW: if (photos_source_manager_has_online_sources (PHOTOS_SOURCE_MANAGER (self->priv->src_mngr))) gtk_widget_set_valign (title_label, GTK_ALIGN_CENTER); else { gtk_widget_set_valign (title_label, GTK_ALIGN_START); photos_empty_results_box_add_system_settings_label (self); } break; default: g_assert_not_reached (); break; } gtk_widget_show_all (GTK_WIDGET (self)); }
static GtkWidget* create_test2_b_window (void) { GtkWidget *window; GtkImage *imageClient, *imageWellth, *imageTest, *imageBG, *add; GtkWidget *timer_label; GtkWidget *vbox1; GError** error = NULL; int i=0; char buf[8]; /* Load UI from file */ /* Auto-connect signal handlers */ gtk_builder_connect_signals (Test2bBuilder, NULL); /* Get the window object from the ui file */ window = GTK_WIDGET (gtk_builder_get_object (Test2bBuilder, TEST2_b_WINDOW)); if (!window) { g_critical ("Widget \"%s\" is missing in file %s.", TEST2_b_WINDOW, TEST2B_UI_FILE); } /* GdkPixbufAnimation * pixbufclntanm = gdk_pixbuf_animation_new_from_file(CLIENT_LOGO, error); GdkPixbufAnimation * pixbufwlthanm = gdk_pixbuf_animation_new_from_file(WELLTH_LOGO, error); imageClient = (GtkImage *) GTK_WIDGET (gtk_builder_get_object (Test1Builder, "clnt_logo")); imageWellth = (GtkImage *) GTK_WIDGET (gtk_builder_get_object (Test1Builder, "wellth_logo")); gtk_image_set_from_animation(GTK_IMAGE(imageClient), pixbufclntanm); gtk_image_set_from_animation (GTK_IMAGE(imageWellth), pixbufwlthanm); */ // GdkPixbufAnimation * pixbufBGanm = gdk_pixbuf_animation_new_from_file(BG, error); imageBG = (GtkImage *) GTK_WIDGET (gtk_builder_get_object (Test2bBuilder, "image1")); gtk_image_set_from_animation(GTK_IMAGE(imageBG), pixbufBGanm); /* GdkPixbufAnimation * pixbufTestanm = gdk_pixbuf_animation_new_from_file(TEST1, error); imageTest = (GtkImage *) GTK_WIDGET (gtk_builder_get_object (Test2bBuilder, "image2")); gtk_image_set_from_animation(GTK_IMAGE(imageTest), pixbufTestanm); */ // GdkPixbufAnimation * pixbufaddanm = gdk_pixbuf_animation_new_from_file(ADDS2, error); // add = (GtkImage *) GTK_WIDGET (gtk_builder_get_object (Test2bBuilder, "adds")); // gtk_image_set_from_animation(GTK_IMAGE(add), pixbufaddanm); //#endif //GdkPixbufAnimation * pixbuf1 = gdk_pixbuf_animation_new_from_file(GRAPH, error); //GtkImage * grf = (GtkImage *) GTK_WIDGET (gtk_builder_get_object (Test1Builder, "graph")); //gtk_image_set_from_animation(GTK_IMAGE(grf), pixbuf1); /*GdkPixbufAnimation * pixbuf2 = gdk_pixbuf_animation_new_from_file(T1_NEXT_ICON, error); GtkImage * nxt_icon = (GtkImage *) GTK_WIDGET (gtk_builder_get_object (Test2bBuilder, "next_icon")); gtk_image_set_from_animation(GTK_IMAGE(nxt_icon), pixbuf2); */ /* GdkPixbufAnimation * pixbuf2 = gdk_pixbuf_animation_new_from_file(T2_NEXT_ICON, error); GtkImage * nxt_icon = (GtkImage *) GTK_WIDGET (gtk_builder_get_object (Test2bBuilder, "next_icon")); gtk_image_set_from_animation(GTK_IMAGE(nxt_icon), pixbuf2); */ t2b_button1 = GTK_WIDGET (gtk_builder_get_object (Test2bBuilder, "exit")); g_signal_connect (G_OBJECT (t2b_button1), "clicked", G_CALLBACK (test_exit_btnclicked), NULL); t2b_home_button = GTK_WIDGET (gtk_builder_get_object (Test2bBuilder, "home")); g_signal_connect (G_OBJECT (t2b_home_button), "clicked", G_CALLBACK (test_home_btnclicked), NULL); t2b_button5 = GTK_WIDGET (gtk_builder_get_object (Test2bBuilder, "next")); g_signal_connect (G_OBJECT (t2b_button5), "clicked", G_CALLBACK (test2_b_next_btnclicked), NULL); priv = g_malloc (sizeof (struct _Private)); /* ANJUTA: Widgets initialization for WindowMain.ui - DO NOT REMOVE */ //g_object_unref (InitialBuilder); return window; }
static gboolean update_icon_idle (ButtonData *button_data) { int width, height; GdkPixbuf *icon; GdkPixbuf *scaled; int icon_size; GError *error; int xrequest, yrequest; GtkRequisition empty_button_request; /* FIXME this function could do a lot more short-circuiting and maybe * save some effort */ g_debug("Updating icon, allocated size=%d", button_data->size); if (!button_data->icon_theme) goto done; gtk_image_clear (GTK_IMAGE (button_data->image)); gtk_widget_set_size_request (button_data->image, 10, 10); /* we undo this later, it's just in case the button special-cases 0x0 contents */ gtk_widget_size_request (GTK_WIDGET(button_data->button), &empty_button_request); empty_button_request.width -= 10; empty_button_request.height -= 10; icon_size = 0; xrequest = -1; yrequest = -1; switch (button_data->orient) { case GTK_ORIENTATION_HORIZONTAL: xrequest = button_data->size - empty_button_request.width; if (xrequest < 0) xrequest = 0; yrequest = 12; icon_size = xrequest; break; case GTK_ORIENTATION_VERTICAL: xrequest = 12; yrequest = button_data->size - empty_button_request.height; if (yrequest < 0) yrequest = 0; icon_size = yrequest; break; } /* clamp icon size to a max of 60 which is the native server-side size */ if (icon_size < 22) icon_size = 16; else if (icon_size < 32) icon_size = 22; else if (icon_size < 48) icon_size = 32; else if (icon_size < 60) icon_size = 48; else icon_size = 60; g_debug("Settled on icon size %d, and image widget request %dx%d, based on empty button request %dx%d", icon_size, xrequest, yrequest, empty_button_request.width, empty_button_request.height); if (button_data->user_photo) { icon = button_data->user_photo; g_object_ref(icon); } else { error = NULL; icon = gtk_icon_theme_load_icon (button_data->icon_theme, ICON_NAME, icon_size, 0, &error); } if (icon == NULL) { g_printerr (_("Failed to load %s: %s\n"), ICON_NAME, error ? error->message : _("Icon not found")); if (error) { g_error_free (error); error = NULL; } icon = gdk_pixbuf_new_from_file (DATADIR "/pixmaps/nobody.png", NULL); if (icon == NULL) { gtk_image_set_from_stock (GTK_IMAGE (button_data->image), GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_SMALL_TOOLBAR); goto done; } } width = gdk_pixbuf_get_width (icon); height = gdk_pixbuf_get_height (icon); scaled = NULL; /* Make it fit on the given panel */ switch (button_data->orient) { case GTK_ORIENTATION_HORIZONTAL: width = (icon_size * width) / (double) height; height = icon_size; break; case GTK_ORIENTATION_VERTICAL: height = (icon_size * height) / (double) width; width = icon_size; break; } scaled = gdk_pixbuf_scale_simple (icon, width, height, GDK_INTERP_BILINEAR); if (scaled != NULL) { gtk_image_set_from_pixbuf (GTK_IMAGE (button_data->image), scaled); g_object_unref (scaled); } else { gtk_image_set_from_pixbuf (GTK_IMAGE (button_data->image), icon); } /* don't put much size request on the image, since we are scaling * to the allocation, if we didn't do this we could a) never be resized * smaller and b) get infinite request/alloc loops */ gtk_widget_set_size_request(button_data->image, xrequest, yrequest); g_object_unref (icon); #ifdef GUI_LOG { GtkRequisition with_image_request; gtk_widget_size_request(button_data->button, &with_image_request); g_debug("Entire button will request %dx%d", with_image_request.width, with_image_request.height); } #endif done: button_data->update_icon_idle = 0; return FALSE; }