static void
color_changed_cb (GtkColorButton    *button,
                  CcBackgroundPanel *panel)
{
  CcBackgroundPanelPrivate *priv = panel->priv;
  GdkColor color;
  gchar *value;
  gboolean is_pcolor = FALSE;

  gtk_color_button_get_color (button, &color);
  if (WID ("style-pcolor") == GTK_WIDGET (button))
    is_pcolor = TRUE;

  value = gdk_color_to_string (&color);

  if (priv->current_background)
    {
      g_object_set (G_OBJECT (priv->current_background),
		    is_pcolor ? "primary-color" : "secondary-color", value, NULL);
    }

  g_settings_set_string (priv->settings,
			 is_pcolor ? WP_PCOLOR_KEY : WP_SCOLOR_KEY, value);

  g_settings_apply (priv->settings);

  g_free (value);

  update_preview (priv, NULL);
}
Beispiel #2
0
void update_preview_cb(GtkFileChooser * file_chooser, gpointer data)
{
    gchar * filename;
    filename = gtk_file_chooser_get_preview_filename(file_chooser);
    update_preview(file_chooser,filename,GTK_IMAGE(data));
    g_free(filename);
}
static void
style_changed_cb (GtkComboBox       *box,
                  CcBackgroundPanel *panel)
{
  CcBackgroundPanelPrivate *priv = panel->priv;
  GtkTreeModel *model;
  GtkTreeIter iter;
  GDesktopBackgroundStyle value;

  if (!gtk_combo_box_get_active_iter (box, &iter))
    {
      return;
    }

  model = gtk_combo_box_get_model (box);

  gtk_tree_model_get (model, &iter, 1, &value, -1);

  g_settings_set_enum (priv->settings, WP_OPTIONS_KEY, value);

  if (priv->current_background)
    g_object_set (G_OBJECT (priv->current_background), "placement", value, NULL);

  g_settings_apply (priv->settings);

  update_preview (priv, NULL);
}
static void
swap_colors_clicked (GtkButton         *button,
                     CcBackgroundPanel *panel)
{
  CcBackgroundPanelPrivate *priv = panel->priv;
  GdkColor pcolor, scolor;
  char *new_pcolor, *new_scolor;

  gtk_color_button_get_color (GTK_COLOR_BUTTON (WID ("style-pcolor")), &pcolor);
  gtk_color_button_get_color (GTK_COLOR_BUTTON (WID ("style-scolor")), &scolor);

  gtk_color_button_set_color (GTK_COLOR_BUTTON (WID ("style-scolor")), &pcolor);
  gtk_color_button_set_color (GTK_COLOR_BUTTON (WID ("style-pcolor")), &scolor);

  new_pcolor = gdk_color_to_string (&scolor);
  new_scolor = gdk_color_to_string (&pcolor);

  g_object_set (priv->current_background,
                "primary-color", new_pcolor,
                "secondary-color", new_scolor,
                NULL);

  g_settings_set_string (priv->settings, WP_PCOLOR_KEY, new_pcolor);
  g_settings_set_string (priv->settings, WP_SCOLOR_KEY, new_scolor);

  g_free (new_pcolor);
  g_free (new_scolor);

  g_settings_apply (priv->settings);

  update_preview (priv, NULL);
}
Beispiel #5
0
void PngyuPreviewWindow::compress_finished()
{
  if( m_execute_compress_thread.is_compress_succeeded() )
  {
    const QByteArray &src_data = m_execute_compress_thread.original_png_data();
    const QByteArray &dst_data = m_execute_compress_thread.output_png_data();
    const qint64 src_size = src_data.size();
    const qint64 dst_size = dst_data.size();

    const double saved_rate = static_cast<double>( src_size - dst_size ) / ( src_size );

    QString result_test =
        tr("Original Size : ") + pngyu::util::size_to_string_kb( src_size ) + " " +
        tr("Output Size : ") + pngyu::util::size_to_string_kb( dst_size ).rightJustified( 8, ' ' ) + " " +
        tr("Saved : ") + QString::number( static_cast<int>(saved_rate * 100) ).rightJustified( 3, ' ' ) + "% " +
        QString("");

    ui->statusbar->showMessage( result_test );
    m_is_compress_finished = true;
    m_dst_image = QImage::fromData( dst_data );
  }
  else
  {
    set_compress_result_failed( m_execute_compress_thread.error_string() );
  }

  ui->spinner->setVisible( false );

  m_execute_compress_thread.clear_all();
  update_preview();
}
Beispiel #6
0
void
gt_channel_update_from_raw_data(GtChannel* self, GtChannelRawData* data)
{
    GtChannelPrivate* priv = gt_channel_get_instance_private(self);

    if (!data) // TODO: Need to log error?
        return;

    priv->updating = TRUE;
    g_object_notify_by_pspec(G_OBJECT(self), props[PROP_UPDATING]);

    g_object_set(self,
                 "viewers", data->viewers,
                 "display-name", data->display_name,
                 "status", data->status,
                 "game", data->game,
                 "preview-url", data->preview_url,
                 "video-banner-url", data->video_banner_url,
                 "stream-started-time", data->stream_started_time,
                 NULL);

    if (priv->online != data->online)
    {
        priv->preview_timestamp = 0;
        g_object_set(self, "online", data->online, NULL);
    }

    update_preview(self);
}
// Update the bed shape from the dialog fields.
void BedShapePanel::update_shape()
{
	auto page_idx = m_shape_options_book->GetSelection();
	if (page_idx == SHAPE_RECTANGULAR) {
		Pointf rect_size, rect_origin;
		try{
			rect_size = boost::any_cast<Pointf>(m_optgroups[SHAPE_RECTANGULAR]->get_value("rect_size")); }
		catch (const std::exception &e){
			return;}
		try{
			rect_origin = boost::any_cast<Pointf>(m_optgroups[SHAPE_RECTANGULAR]->get_value("rect_origin"));
		}
		catch (const std::exception &e){
			return;}
		
		auto x = rect_size.x;
		auto y = rect_size.y;
		// empty strings or '-' or other things
		if (x == 0 || y == 0)	return;
		double x0 = 0.0;
		double y0 = 0.0;
		double x1 = x;
		double y1 = y;

		auto dx = rect_origin.x;
		auto dy = rect_origin.y;

		x0 -= dx;
		x1 -= dx;
		y0 -= dy;
		y1 -= dy;
		m_canvas->m_bed_shape = {	Pointf(x0, y0),
									Pointf(x1, y0),
									Pointf(x1, y1),
									Pointf(x0, y1)};
	} 
	else if(page_idx == SHAPE_CIRCULAR) {
		double diameter;
		try{
			diameter = boost::any_cast<double>(m_optgroups[SHAPE_CIRCULAR]->get_value("diameter"));
		}
		catch (const std::exception &e){
			return;
		} 
 		if (diameter == 0.0) return ;
		auto r = diameter / 2;
		auto twopi = 2 * PI;
		auto edges = 60;
		std::vector<Pointf> points;
		for (size_t i = 1; i <= 60; ++i){
			auto angle = i * twopi / edges;
			points.push_back(Pointf(r*cos(angle), r*sin(angle)));
		}
		m_canvas->m_bed_shape = points;
	}

//	$self->{on_change}->();
	update_preview();
}
Beispiel #8
0
void PngyuPreviewWindow::showEvent( QShowEvent * )
{
  if( ! m_is_image_loaded )
  {
    load_png_file();
  }
  update_preview();
}
static void
on_settings_changed (GSettings         *settings,
                     gchar             *key,
                     CcBackgroundPanel *self)
{
  reload_current_bg (self, settings);
  update_preview (self->priv, settings, NULL);
}
static void
copy_finished_cb (GObject      *source_object,
                  GAsyncResult *result,
                  gpointer      pointer)
{
  GError *err = NULL;
  CcBackgroundPanel *panel = (CcBackgroundPanel *) pointer;
  CcBackgroundPanelPrivate *priv = panel->priv;
  CcBackgroundItem *item;
  CcBackgroundItem *current_background;
  GSettings *settings;

  if (!g_file_copy_finish (G_FILE (source_object), result, &err))
    {
      if (g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
        g_error_free (err);
        return;
      }
      g_warning ("Failed to copy image to cache location: %s", err->message);
      g_error_free (err);
    }
  item = g_object_get_data (source_object, "item");
  settings = g_object_get_data (source_object, "settings");
  current_background = CURRENT_BG;

  g_settings_apply (settings);

  /* the panel may have been destroyed before the callback is run, so be sure
   * to check the widgets are not NULL */

  if (priv->spinner)
    {
      gtk_widget_destroy (GTK_WIDGET (priv->spinner));
      priv->spinner = NULL;
    }

  if (current_background)
    cc_background_item_load (current_background, NULL);

  if (priv->builder)
    {
      char *filename;

      update_preview (priv, settings, item);
      current_background = CURRENT_BG;

      /* Save the source XML if there is one */
      filename = get_save_path (SAVE_PATH);
      if (create_save_dir ())
        cc_background_xml_save (current_background, filename);
    }

  /* remove the reference taken when the copy was set up */
  g_object_unref (panel);
}
Beispiel #11
0
void PngyuPreviewWindow::set_current_pngquant_option( const pngyu::PngquantOption &option )
{
  if( m_pngquant_option == option )
  {
    return;
  }
  m_pngquant_option = option;

  clear_compress_result();
  update_preview();
}
static void
update_controls_from_theme (GthContactSheetThemeDialog *self,
			    GthContactSheetTheme       *theme)
{
	if (theme == NULL)
		theme = _gth_contact_sheet_theme_new_default ();
	self->priv->theme = gth_contact_sheet_theme_dup (theme);

	gtk_entry_set_text (GTK_ENTRY (GET_WIDGET ("name_entry")), theme->display_name);

	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("solid_color_radiobutton")), theme->background_type == GTH_CONTACT_SHEET_BACKGROUND_TYPE_SOLID);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("gradient_radiobutton")), theme->background_type != GTH_CONTACT_SHEET_BACKGROUND_TYPE_SOLID);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("h_gradient_checkbutton")), (theme->background_type == GTH_CONTACT_SHEET_BACKGROUND_TYPE_HORIZONTAL) || (theme->background_type == GTH_CONTACT_SHEET_BACKGROUND_TYPE_FULL));
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("v_gradient_checkbutton")), (theme->background_type == GTH_CONTACT_SHEET_BACKGROUND_TYPE_VERTICAL) || (theme->background_type == GTH_CONTACT_SHEET_BACKGROUND_TYPE_FULL));

	if (theme->background_type == GTH_CONTACT_SHEET_BACKGROUND_TYPE_SOLID) {
		gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("solid_color_colorpicker")), &theme->background_color1);
		gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("h_gradient_1_colorpicker")), &theme->background_color1);
		gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("h_gradient_2_colorpicker")), &theme->background_color1);
		gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("v_gradient_1_colorpicker")), &theme->background_color1);
		gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("v_gradient_2_colorpicker")), &theme->background_color1);
	}
	else if (theme->background_type == GTH_CONTACT_SHEET_BACKGROUND_TYPE_FULL) {
		gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("solid_color_colorpicker")), &theme->background_color1);
		gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("h_gradient_1_colorpicker")), &theme->background_color1);
		gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("h_gradient_2_colorpicker")), &theme->background_color2);
		gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("v_gradient_1_colorpicker")), &theme->background_color3);
		gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("v_gradient_2_colorpicker")), &theme->background_color4);
	}
	else {
		gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("solid_color_colorpicker")), &theme->background_color1);
		gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("h_gradient_1_colorpicker")), &theme->background_color1);
		gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("h_gradient_2_colorpicker")), &theme->background_color2);
		gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("v_gradient_1_colorpicker")), &theme->background_color1);
		gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("v_gradient_2_colorpicker")), &theme->background_color2);
	}

	gtk_combo_box_set_active (GTK_COMBO_BOX (GET_WIDGET ("frame_style_combobox")), theme->frame_style);
	gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("frame_colorpicker")), &theme->frame_color);

	gtk_font_button_set_font_name (GTK_FONT_BUTTON (GET_WIDGET ("header_fontpicker")), theme->header_font_name);
	gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("header_colorpicker")), &theme->header_color);

	gtk_font_button_set_font_name (GTK_FONT_BUTTON (GET_WIDGET ("footer_fontpicker")), theme->footer_font_name);
	gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("footer_colorpicker")), &theme->footer_color);

	gtk_font_button_set_font_name (GTK_FONT_BUTTON (GET_WIDGET ("caption_fontpicker")), theme->caption_font_name);
	gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("caption_colorpicker")), &theme->caption_color);

	update_preview (self);
}
static void
v_gradient_swap_button_clicked_cb (GtkButton *button,
				   gpointer   user_data)
{
	GthContactSheetThemeDialog *self = user_data;
	GdkRGBA                     color1;
	GdkRGBA                     color2;

	gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("v_gradient_1_colorpicker")), &color1);
	gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("v_gradient_2_colorpicker")), &color2);
	gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("v_gradient_2_colorpicker")), &color1);
	gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("v_gradient_1_colorpicker")), &color2);
	update_preview (self);
}
static void
cc_background_panel_init (CcBackgroundPanel *self)
{
  CcBackgroundPanelPrivate *priv;
  gchar *objects[] = {"background-panel", NULL };
  GError *err = NULL;
  GtkWidget *widget;

  priv = self->priv = BACKGROUND_PANEL_PRIVATE (self);

  priv->builder = gtk_builder_new ();
  priv->connection = g_application_get_dbus_connection (g_application_get_default ());

  gtk_builder_add_objects_from_file (priv->builder,
                                     UIDIR"/background.ui",
                                     objects, &err);

  if (err)
    {
      g_warning ("Could not load ui: %s", err->message);
      g_error_free (err);
      return;
    }

  priv->settings = g_settings_new (WP_PATH_ID);
  g_settings_delay (priv->settings);

  /* add the top level widget */
  widget = WID ("background-panel");

  gtk_container_add (GTK_CONTAINER (self), widget);
  gtk_widget_show_all (GTK_WIDGET (self));

  /* setup preview area */
  widget = WID ("background-desktop-drawingarea");
  g_signal_connect (widget, "draw", G_CALLBACK (on_preview_draw),
                    self);

  priv->copy_cancellable = g_cancellable_new ();

  priv->thumb_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE);

  reload_current_bg (self);
  update_preview (priv, NULL);

  g_signal_connect (priv->settings, "changed", G_CALLBACK (on_settings_changed), self);

  widget = WID ("background-set-button");
  g_signal_connect (widget, "clicked", G_CALLBACK (on_background_button_clicked), self);
}
Beispiel #15
0
// Loads an stl file, projects it to the XY plane and calculates a polygon.
void BedShapePanel::load_stl()
{
	t_file_wild_card vec_FILE_WILDCARDS = get_file_wild_card();
    std::vector<std::string> file_types = { "known", "stl", "obj", "amf", "3mf", "prusa" };
    wxString MODEL_WILDCARD;
	for (auto file_type: file_types)
		MODEL_WILDCARD += vec_FILE_WILDCARDS.at(file_type) + "|";

	auto dialog = new wxFileDialog(this, _(L("Choose a file to import bed shape from (STL/OBJ/AMF/3MF/PRUSA):")), "", "",
		MODEL_WILDCARD, wxFD_OPEN | wxFD_FILE_MUST_EXIST);
	if (dialog->ShowModal() != wxID_OK) {
		dialog->Destroy();
		return;
	}
	wxArrayString input_file;
	dialog->GetPaths(input_file);
	dialog->Destroy();

	std::string file_name = input_file[0].ToStdString();

	Model model;
	try {
		model = Model::read_from_file(file_name);
	}
	catch (std::exception &e) {
		auto msg = _(L("Error! ")) + file_name + " : " + e.what() + ".";
		show_error(this, msg);
		exit(1);
	}

	auto mesh = model.mesh();
	auto expolygons = mesh.horizontal_projection();

	if (expolygons.size() == 0) {
		show_error(this, _(L("The selected file contains no geometry.")));
		return;
	}
	if (expolygons.size() > 1) {
		show_error(this, _(L("The selected file contains several disjoint areas. This is not supported.")));
		return;
	}

	auto polygon = expolygons[0].contour;
	std::vector<Pointf> points;
	for (auto pt : polygon.points)
		points.push_back(Pointf::new_unscale(pt));
	m_canvas->m_bed_shape = points;
	update_preview();
}
Beispiel #16
0
static void init_ram_dialog(HWND hwnd)
{
    HWND    temp_hwnd, temp_hwnd2;
    int     i;
    LOGFONT logfont = { -12, -7, 0, 0, 400, 0, 0, 0, 0, 0, 0,
                      DRAFT_QUALITY, FIXED_PITCH|FF_MODERN, TEXT("") };
    HFONT   hfont = CreateFontIndirect(&logfont);

    if (hfont)
        SendDlgItemMessage(hwnd, IDC_RAMINIT_PREVIEW, WM_SETFONT,
            (WPARAM)hfont, MAKELPARAM(TRUE, 0));

    resources_get_int("RAMInitStartValue", &orig_startvalue);
    temp_hwnd = GetDlgItem(hwnd,IDC_RAMINIT_STARTVALUE);

    for (i = 0; ui_ram_startvalue[i] >= 0; i++) {
        TCHAR s[16];

        _stprintf(s, TEXT("%d"), ui_ram_startvalue[i]);
        SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)s);
        if (orig_startvalue == ui_ram_startvalue[i])
            SendMessage(temp_hwnd, CB_SETCURSEL, (WPARAM)i, 0);
    }

    resources_get_int("RAMInitValueInvert", &orig_valueinvert);
    resources_get_int("RAMInitPatternInvert", &orig_patterninvert);
    temp_hwnd = GetDlgItem(hwnd, IDC_RAMINIT_VALUEINVERT);
    temp_hwnd2 = GetDlgItem(hwnd, IDC_RAMINIT_PATTERNINVERT);
    
    for (i = 0; ui_ram_invertvalue[i] >= 0; i++) {
        TCHAR s[16];

        _stprintf(s, TEXT("%d"), ui_ram_invertvalue[i]);
        SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)s);
        SendMessage(temp_hwnd2, CB_ADDSTRING, 0, (LPARAM)s);
        if (ui_ram_invertvalue[i] == orig_valueinvert)
            SendMessage(temp_hwnd, CB_SETCURSEL, (WPARAM)i, 0);
        if (ui_ram_invertvalue[i] == orig_patterninvert)
            SendMessage(temp_hwnd2, CB_SETCURSEL, (WPARAM)i, 0);
    }

    update_preview(hwnd);
}
Beispiel #17
0
// Loads an stl file, projects it to the XY plane and calculates a polygon.
void BedShapePanel::load_stl()
{
	auto dialog = new wxFileDialog(this, _(L("Choose a file to import bed shape from (STL/OBJ/AMF/3MF/PRUSA):")), "", "",
		file_wildcards(FT_MODEL), wxFD_OPEN | wxFD_FILE_MUST_EXIST);
	if (dialog->ShowModal() != wxID_OK) {
		dialog->Destroy();
		return;
	}
	wxArrayString input_file;
	dialog->GetPaths(input_file);
	dialog->Destroy();

	std::string file_name = input_file[0].ToUTF8().data();

	Model model;
	try {
		model = Model::read_from_file(file_name);
	}
	catch (std::exception &e) {
		auto msg = _(L("Error! ")) + file_name + " : " + e.what() + ".";
		show_error(this, msg);
		exit(1);
	}

	auto mesh = model.mesh();
	auto expolygons = mesh.horizontal_projection();

	if (expolygons.size() == 0) {
		show_error(this, _(L("The selected file contains no geometry.")));
		return;
	}
	if (expolygons.size() > 1) {
		show_error(this, _(L("The selected file contains several disjoint areas. This is not supported.")));
		return;
	}

	auto polygon = expolygons[0].contour;
	std::vector<Vec2d> points;
	for (auto pt : polygon.points)
		points.push_back(unscale(pt));
	m_canvas->m_bed_shape = points;
	update_preview();
}
void PakFileDialog::OnListItemSelected( wxListEvent& ev )
{
  m_selected = ev.GetLabel();
  pakbrowser_files_type::iterator fit = m_files.find(m_selected);
  if( fit != m_files.end() )
  { // it's a file
    update_preview(fit->second + wxT("#zip:") + m_curpath + m_selected);
    pakbrowser_files_type::iterator fit = m_files.find(m_selected);
#ifdef NDEBUG
    if( fit != m_files.end() )
#endif
      m_infolabel->SetLabel( _("Archive: ") + fit->second);
    
  }
  else
  { // it's a dir
    m_preview->SetBitmap(wxArtProvider::GetBitmap(wxART_FOLDER, wxART_OTHER, wxSize(64, 64)));
    update_nolabel();
  }
}
Beispiel #19
0
static void toggle_num_pages(HWND hMainWnd)
{
    HWND hReBar = GetDlgItem(hMainWnd, IDC_REBAR);
    WCHAR name[MAX_STRING_LEN];
    HINSTANCE hInst = GetModuleHandleW(0);
    int nPreviewPages;

    preview.pages_shown = preview.pages_shown > 1 ? 1 : 2;

    nPreviewPages = preview.zoomlevel > 0 ? preview.saved_pages_shown :
                                            preview.pages_shown;

    LoadStringW(hInst, nPreviewPages > 1 ? STRING_PREVIEW_ONEPAGE :
                                           STRING_PREVIEW_TWOPAGES,
                name, MAX_STRING_LEN);

    SetWindowTextW(GetDlgItem(hReBar, ID_PREVIEW_NUMPAGES), name);
    update_preview_sizes(GetDlgItem(hMainWnd, IDC_PREVIEW), TRUE);
    update_preview(hMainWnd);
}
Beispiel #20
0
/**
 * exo_gtk_file_chooser_add_thumbnail_preview:
 * @chooser : a #GtkFileChooser.
 *
 * This is a convenience function that adds a preview widget to the @chooser,
 * which displays thumbnails for the selected filenames using the thumbnail
 * database. The preview widget is also able to generate thumbnails for all
 * image formats supported by #GdkPixbuf.
 *
 * Use this function whenever you display a #GtkFileChooser to ask the user
 * to select an image file from the file system.
 *
 * The preview widget also supports URIs other than file:-URIs to a certain
 * degree, but this support is rather limited currently, so you may want to
 * use gtk_file_chooser_set_local_only() to ensure that the user can only
 * select files from the local file system.
 *
 * When @chooser is configured to select multiple image files - using the
 * gtk_file_chooser_set_select_multiple() method - the behaviour of the
 * preview widget is currently undefined, in that it is not defined for
 * which of the selected files the preview will be displayed.
 *
 * Since: 0.3.1.9
 **/
void
exo_gtk_file_chooser_add_thumbnail_preview (GtkFileChooser *chooser)
{
    GtkWidget *thumbnail_preview;

    g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));

    /* add the preview to the file chooser */
    thumbnail_preview = _exo_thumbnail_preview_new ();
    gtk_file_chooser_set_preview_widget (chooser, thumbnail_preview);
    gtk_file_chooser_set_preview_widget_active (chooser, TRUE);
    gtk_file_chooser_set_use_preview_label (chooser, FALSE);
    gtk_widget_show (thumbnail_preview);

    /* update the preview as necessary */
    g_signal_connect (G_OBJECT (chooser), "update-preview", G_CALLBACK (update_preview), thumbnail_preview);

    /* initially update the preview, in case the file chooser is already setup */
    update_preview (chooser, EXO_THUMBNAIL_PREVIEW (thumbnail_preview));
}
Beispiel #21
0
LRESULT CALLBACK preview_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch(msg)
    {
        case WM_CREATE:
        {
            HWND hMainWnd = GetParent(hWnd);
            HWND hEditorWnd = GetDlgItem(hMainWnd, IDC_EDITOR);
            FORMATRANGE fr;
            GETTEXTLENGTHEX gt = {GTL_DEFAULT, 1200};
            HDC hdc = GetDC(hWnd);
            HDC hdcTarget = make_dc();

            fr.rc = preview.rcPage = get_print_rect(hdcTarget);
            preview.rcPage.bottom += margins.bottom;
            preview.rcPage.right += margins.right;
            preview.rcPage.top = preview.rcPage.left = 0;
            fr.rcPage = preview.rcPage;

            preview.bmSize.cx = twips_to_pixels(preview.rcPage.right, GetDeviceCaps(hdc, LOGPIXELSX));
            preview.bmSize.cy = twips_to_pixels(preview.rcPage.bottom, GetDeviceCaps(hdc, LOGPIXELSY));

            preview.textlength = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)&gt, 0);

            fr.hdc = CreateCompatibleDC(hdc);
            fr.hdcTarget = hdcTarget;
            fr.chrg.cpMin = 0;
            fr.chrg.cpMax = preview.textlength;
            DeleteDC(fr.hdc);
            DeleteDC(hdcTarget);
            ReleaseDC(hWnd, hdc);

            update_preview_sizes(hWnd, TRUE);
            update_preview(hMainWnd);
            break;
        }

        case WM_PAINT:
            return print_preview(hWnd);

        case WM_SIZE:
        {
            update_preview_sizes(hWnd, FALSE);
            InvalidateRect(hWnd, NULL, FALSE);
            break;
        }

        case WM_VSCROLL:
        case WM_HSCROLL:
        {
            SCROLLINFO si;
            RECT rc;
            int nBar = (msg == WM_VSCROLL) ? SB_VERT : SB_HORZ;
            int origPos;

            GetClientRect(hWnd, &rc);
            si.cbSize = sizeof(si);
            si.fMask = SIF_ALL;
            GetScrollInfo(hWnd, nBar, &si);
            origPos = si.nPos;
            switch(LOWORD(wParam))
            {
                case SB_TOP: /* == SB_LEFT */
                    si.nPos = si.nMin;
                    break;
                case SB_BOTTOM: /* == SB_RIGHT */
                    si.nPos = si.nMax;
                    break;
                case SB_LINEUP: /* == SB_LINELEFT */
                    si.nPos -= si.nPage / 10;
                    break;
                case SB_LINEDOWN: /* == SB_LINERIGHT */
                    si.nPos += si.nPage / 10;
                    break;
                case SB_PAGEUP: /* == SB_PAGELEFT */
                    si.nPos -= si.nPage;
                    break;
                case SB_PAGEDOWN: /* SB_PAGERIGHT */
                    si.nPos += si.nPage;
                    break;
                case SB_THUMBTRACK:
                    si.nPos = si.nTrackPos;
                    break;
            }
            si.fMask = SIF_POS;
            SetScrollInfo(hWnd, nBar, &si, TRUE);
            GetScrollInfo(hWnd, nBar, &si);
            if (si.nPos != origPos)
            {
                int amount = origPos - si.nPos;
                if (msg == WM_VSCROLL)
                    ScrollWindow(hWnd, 0, amount, NULL, NULL);
                else
                    ScrollWindow(hWnd, amount, 0, NULL, NULL);
            }
            return 0;
        }

        case WM_SETCURSOR:
        {
            POINT pt;
            RECT rc;
            int bHittest = FALSE;
            DWORD messagePos = GetMessagePos();
            pt.x = (short)LOWORD(messagePos);
            pt.y = (short)HIWORD(messagePos);
            ScreenToClient(hWnd, &pt);

            GetClientRect(hWnd, &rc);
            if (PtInRect(&rc, pt))
            {
                pt.x += GetScrollPos(hWnd, SB_HORZ);
                pt.y += GetScrollPos(hWnd, SB_VERT);
                bHittest = preview_page_hittest(pt);
            }

            if (bHittest)
                SetCursor(LoadCursorW(GetModuleHandleW(0),
                                      MAKEINTRESOURCEW(IDC_ZOOM)));
            else
                SetCursor(LoadCursorW(NULL, (WCHAR*)IDC_ARROW));

            return TRUE;
        }

        case WM_LBUTTONDOWN:
        {
            int page;
            POINT pt;
            pt.x = (short)LOWORD(lParam) + GetScrollPos(hWnd, SB_HORZ);
            pt.y = (short)HIWORD(lParam) + GetScrollPos(hWnd, SB_VERT);
            if ((page = preview_page_hittest(pt)) > 0)
            {
                HWND hMainWnd = GetParent(hWnd);

                /* Convert point from client coordinate to unzoomed page
                 * coordinate. */
                pt.x -= preview.spacing.cx;
                if (page > 1)
                    pt.x -= preview.bmScaledSize.cx + preview.spacing.cx;
                pt.y -= preview.spacing.cy;
                pt.x /= preview.zoomratio;
                pt.y /= preview.zoomratio;

                if (preview.zoomlevel == 0)
                    preview.saved_pages_shown = preview.pages_shown;
                preview.zoomlevel = (preview.zoomlevel + 1) % 3;
                preview.zoomratio = 0;
                if (preview.zoomlevel == 0 && preview.saved_pages_shown > 1)
                {
                    toggle_num_pages(hMainWnd);
                } else if (preview.pages_shown > 1) {
                    if (page >= 2) preview.page++;
                    toggle_num_pages(hMainWnd);
                } else {
                    update_preview_sizes(hWnd, TRUE);
                    InvalidateRect(hWnd, NULL, FALSE);
                    update_preview_buttons(hMainWnd);
                }

                if (preview.zoomlevel > 0) {
                    SCROLLINFO si;
                    /* Convert the coordinate back to client coordinate. */
                    pt.x *= preview.zoomratio;
                    pt.y *= preview.zoomratio;
                    pt.x += preview.spacing.cx;
                    pt.y += preview.spacing.cy;
                    /* Scroll to center view at that point on the page */
                    si.cbSize = sizeof(si);
                    si.fMask = SIF_PAGE;
                    GetScrollInfo(hWnd, SB_HORZ, &si);
                    pt.x -= si.nPage / 2;
                    SetScrollPos(hWnd, SB_HORZ, pt.x, TRUE);
                    GetScrollInfo(hWnd, SB_VERT, &si);
                    pt.y -= si.nPage / 2;
                    SetScrollPos(hWnd, SB_VERT, pt.y, TRUE);
                }
            }
        }

        default:
            return DefWindowProcW(hWnd, msg, wParam, lParam);
    }

    return 0;
}
Beispiel #22
0
static gboolean
select_row (GtkTreeView *list, Browser *br)
{
	update_preview (br);
	return FALSE;
}
Beispiel #23
0
static void
preview_realized (GtkWidget *widget, Browser *br)
{
	update_preview (br);
}
Beispiel #24
0
void BedShapePanel::build_panel(ConfigOptionPoints* default_pt)
{
//	on_change(nullptr);

	auto box = new wxStaticBox(this, wxID_ANY, _(L("Shape")));
	auto sbsizer = new wxStaticBoxSizer(box, wxVERTICAL);

	// shape options
	m_shape_options_book = new wxChoicebook(this, wxID_ANY, wxDefaultPosition, wxSize(300, -1), wxCHB_TOP);
	sbsizer->Add(m_shape_options_book);

	auto optgroup = init_shape_options_page(_(L("Rectangular")));
		ConfigOptionDef def;
		def.type = coPoints;
		def.default_value = new ConfigOptionPoints{ Pointf(200, 200) };
		def.label = L("Size");
		def.tooltip = L("Size in X and Y of the rectangular plate.");
		Option option(def, "rect_size");
		optgroup->append_single_option_line(option);

		def.type = coPoints;
		def.default_value = new ConfigOptionPoints{ Pointf(0, 0) };
		def.label = L("Origin");
		def.tooltip = L("Distance of the 0,0 G-code coordinate from the front left corner of the rectangle.");
		option = Option(def, "rect_origin");
		optgroup->append_single_option_line(option);

		optgroup = init_shape_options_page(_(L("Circular")));
		def.type = coFloat;
		def.default_value = new ConfigOptionFloat(200);
		def.sidetext = L("mm");
		def.label = L("Diameter");
		def.tooltip = L("Diameter of the print bed. It is assumed that origin (0,0) is located in the center.");
		option = Option(def, "diameter");
		optgroup->append_single_option_line(option);

		optgroup = init_shape_options_page(_(L("Custom")));
		Line line{ "", "" };
		line.full_width = 1;
		line.widget = [this](wxWindow* parent) {
			auto btn = new wxButton(parent, wxID_ANY, _(L("Load shape from STL...")), wxDefaultPosition, wxDefaultSize);
			
			auto sizer = new wxBoxSizer(wxHORIZONTAL);
			sizer->Add(btn);

			btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e)
			{
				load_stl();
			}));

			return sizer;
		};
		optgroup->append_line(line);

	Bind(wxEVT_CHOICEBOOK_PAGE_CHANGED, ([this](wxCommandEvent e)
	{
		update_shape();
	}));

	// right pane with preview canvas
	m_canvas = new Bed_2D(this);
	m_canvas->m_bed_shape = default_pt->values;

	// main sizer
	auto top_sizer = new wxBoxSizer(wxHORIZONTAL);
	top_sizer->Add(sbsizer, 0, wxEXPAND | wxLeft | wxTOP | wxBOTTOM, 10);
	if (m_canvas)
		top_sizer->Add(m_canvas, 1, wxEXPAND | wxALL, 10) ;

	SetSizerAndFit(top_sizer);

	set_shape(default_pt);
	update_preview();
}
Beispiel #25
0
MainWindow::MainWindow(QWidget* parent, Qt::WFlags fl)
		: QWidget(parent, fl),m_optionWidget(0)
{

	char bstyle_text[][50] = {
		"Australia Post Redirect Code",
		"Australia Post Reply-Paid",
		"Australia Post Routing Code",
		"Australia Post Standard Customer",
		"Aztec Code (ISO 24778)",
		"Aztec Runes",
		"Channel Code",
		"Codabar",
		"Code 11",
		"Code 128 (ISO 15417)",
		"Code 16k",
		"Code 2 of 5 Data Logic",
		"Code 2 of 5 IATA",
		"Code 2 of 5 Industrial",
		"Code 2 of 5 Interleaved",
		"Code 2 of 5 Matrix",
		"Code 32 (Italian Pharmacode)",
		"Code 39 (ISO 16388)",
		"Code 39 Extended",
		"Code 49",
		"Code 93", 
		"Code One",
		"Databar",
		"Databar Expanded",
		"Databar Expanded Stacked",
		"Databar Limited",
		"Databar Stacked",
		"Databar Stacked Omnidirectional",
		"Data Matrix (ISO 16022)",
		"Deutsche Post Identcode",
		"Deutsche Post Leitcode",
		"Dutch Post KIX",
		"EAN-14",
		"European Article Number (EAN)",
		"Facing Identification Mark (FIM)",
		"Flattermarken",
		"Grid Matrix",
		"ITF-14",
		"International Standard Book Number (ISBN)",
		"Japanese Postal Barcode",
		"Korean Postal Barcode",
		"LOGMARS",
		"Maxicode (ISO 16023)",
		"MicroPDF417 (ISO 24728)",
		"Micro QR Code",
		"MSI Plessey",
		"NVE-18",
		"PDF417 (ISO 15438)",
		"Pharmacode",
		"Pharmacode 2-track",
		"Pharma Zentralnummer (PZN)",
		"PLANET",
		"Postnet",
		"QR Code (ISO 18004)",
		"Royal Mail 4-state Barcode",
		"Telepen",
		"Telepen Numeric",
		"UK Plessey",
		"Universal Product Code (UPC-A)",
		"Universal Product Code (UPC-E)",
		"USPS Intelligent Mail"
	};
		
	/* createActions();
	createMenus();	*/
	
	setupUi(this);
	view->setScene(new QGraphicsScene);
	
	m_fgcolor=qRgb(0,0,0);
	m_bgcolor=qRgb(0xff,0xff,0xff);
	for (int i=0;i<metaObject()->enumerator(0).keyCount();i++) {
		bstyle->addItem(metaObject()->enumerator(0).key(i));
		bstyle->setItemText(i,bstyle_text[i]);
	}
	bstyle->setCurrentIndex(9);
	change_options();
	update_preview();
	view->scene()->addItem(&m_bc);
	connect(bstyle, SIGNAL(currentIndexChanged( int )), SLOT(change_options()));
	connect(bstyle, SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
	connect(heightb, SIGNAL(valueChanged( int )), SLOT(update_preview()));
	connect(bwidth,  SIGNAL(valueChanged( int )), SLOT(update_preview()));
	connect(btype, SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
	connect(txtData, SIGNAL(textChanged( const QString& )), SLOT(update_preview()));
	connect(txtComposite, SIGNAL(textChanged()), SLOT(update_preview()));
	connect(chkComposite, SIGNAL(stateChanged( int )), SLOT(composite_enable()));
	connect(chkComposite, SIGNAL(stateChanged( int )), SLOT(update_preview()));
	connect(cmbCompType, SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
	connect(spnWhitespace, SIGNAL(valueChanged( int )), SLOT(update_preview()));
	connect(btnAbout, SIGNAL(clicked( bool )), SLOT(about()));
	connect(btnSave, SIGNAL(clicked( bool )), SLOT(save()));
	connect(spnScale, SIGNAL(valueChanged( double )), SLOT(change_print_scale()));
	connect(btnExit, SIGNAL(clicked( bool )), SLOT(quit_now()));
	connect(btnReset, SIGNAL(clicked( bool )), SLOT(reset_view()));
	connect(btnMoreData, SIGNAL(clicked( bool )), SLOT(open_data_dialog()));
	connect(btnSequence, SIGNAL(clicked( bool )), SLOT(open_sequence_dialog()));
	connect(chkHRTHide, SIGNAL(stateChanged( int )), SLOT(update_preview()));
}
Beispiel #26
0
void MainWindow::on_bgcolor_clicked()
{
	m_bgcolor=QColorDialog::getColor(m_bgcolor,this);
	update_preview();
}
static void
backgrounds_changed_cb (GtkIconView       *icon_view,
                        CcBackgroundPanel *panel)
{
  GtkTreeIter iter;
  GtkTreeModel *model;
  CcBackgroundItem *item;
  CcBackgroundPanelPrivate *priv = panel->priv;
  char *pcolor, *scolor;
  gboolean draw_preview = TRUE;
  const char *uri;
  CcBackgroundItemFlags flags;
  char *filename;

  item = get_selected_item (panel);

  if (item == NULL)
    return;

  /* Update current source */
  model = gtk_combo_box_get_model (GTK_COMBO_BOX (WID ("sources-combobox")));
  gtk_combo_box_get_active_iter (GTK_COMBO_BOX (WID ("sources-combobox")),
                                 &iter);
  gtk_tree_model_get (model, &iter,
		      COL_SOURCE_TYPE, &priv->current_source, -1);

  uri = cc_background_item_get_uri (item);
  flags = cc_background_item_get_flags (item);

  if ((flags & CC_BACKGROUND_ITEM_HAS_URI) && uri == NULL)
    {
      g_settings_set_enum (priv->settings, WP_OPTIONS_KEY, G_DESKTOP_BACKGROUND_STYLE_NONE);
      g_settings_set_string (priv->settings, WP_URI_KEY, "");
    }
  else if (cc_background_item_get_source_url (item) != NULL &&
	   cc_background_item_get_needs_download (item))
    {
      GFile *source, *dest;
      gchar *cache_path, *basename, *dest_path, *display_name, *dest_uri;
      GdkPixbuf *pixbuf;

      cache_path = bg_pictures_source_get_cache_path ();
      if (g_mkdir_with_parents (cache_path, 0755) < 0)
        {
          g_warning ("Failed to create directory '%s'", cache_path);
          g_free (cache_path);
          return;
	}
      g_free (cache_path);

      dest_path = bg_pictures_source_get_unique_path (cc_background_item_get_source_url (item));
      dest = g_file_new_for_path (dest_path);
      g_free (dest_path);
      source = g_file_new_for_uri (cc_background_item_get_source_url (item));
      basename = g_file_get_basename (source);
      display_name = g_filename_display_name (basename);
      dest_path = g_file_get_path (dest);
      g_free (basename);

      /* create a blank image to use until the source image is ready */
      pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 1, 1);
      gdk_pixbuf_fill (pixbuf, 0x00000000);
      gdk_pixbuf_save (pixbuf, dest_path, "png", NULL, NULL);
      g_object_unref (pixbuf);
      g_free (dest_path);

      if (priv->copy_cancellable)
        {
          g_cancellable_cancel (priv->copy_cancellable);
          g_cancellable_reset (priv->copy_cancellable);
        }

      if (priv->spinner)
        {
          gtk_widget_destroy (GTK_WIDGET (priv->spinner));
          priv->spinner = NULL;
        }

      /* create a spinner while the file downloads */
      priv->spinner = gtk_spinner_new ();
      gtk_spinner_start (GTK_SPINNER (priv->spinner));
      gtk_box_pack_start (GTK_BOX (WID ("bottom-hbox")), priv->spinner, FALSE,
                          FALSE, 6);
      gtk_widget_show (priv->spinner);

      /* reference the panel in case it is removed before the copy is
       * finished */
      g_object_ref (panel);
      g_object_set_data_full (G_OBJECT (source), "item", g_object_ref (item), g_object_unref);
      g_file_copy_async (source, dest, G_FILE_COPY_OVERWRITE,
                         G_PRIORITY_DEFAULT, priv->copy_cancellable,
                         NULL, NULL,
                         copy_finished_cb, panel);
      g_object_unref (source);
      dest_uri = g_file_get_uri (dest);
      g_object_unref (dest);

      g_settings_set_string (priv->settings, WP_URI_KEY, dest_uri);
      g_object_set (G_OBJECT (item),
		    "uri", dest_uri,
		    "needs-download", FALSE,
		    "name", display_name,
		    NULL);
      g_free (display_name);
      g_free (dest_uri);

      /* delay the updated drawing of the preview until the copy finishes */
      draw_preview = FALSE;
    }
  else
    {
      g_settings_set_string (priv->settings, WP_URI_KEY, uri);
    }

  /* Also set the placement if we have a URI and the previous value was none */
  if (flags & CC_BACKGROUND_ITEM_HAS_PLACEMENT)
    {
      g_settings_set_enum (priv->settings, WP_OPTIONS_KEY, cc_background_item_get_placement (item));
    }
  else if (uri != NULL)
    {
      GDesktopBackgroundStyle style;
      style = g_settings_get_enum (priv->settings, WP_OPTIONS_KEY);
      if (style == G_DESKTOP_BACKGROUND_STYLE_NONE)
        g_settings_set_enum (priv->settings, WP_OPTIONS_KEY, cc_background_item_get_placement (item));
    }

  if (flags & CC_BACKGROUND_ITEM_HAS_SHADING)
    g_settings_set_enum (priv->settings, WP_SHADING_KEY, cc_background_item_get_shading (item));

  /* When changing to a background with colours set,
   * don't overwrite what's in GSettings, but read
   * from it instead.
   * We have a hack for the colors source though */
  if (flags & CC_BACKGROUND_ITEM_HAS_PCOLOR &&
      priv->current_source != SOURCE_COLORS)
    {
      g_settings_set_string (priv->settings, WP_PCOLOR_KEY, cc_background_item_get_pcolor (item));
    }
  else
    {
      pcolor = g_settings_get_string (priv->settings, WP_PCOLOR_KEY);
      g_object_set (G_OBJECT (item), "primary-color", pcolor, NULL);
    }

  if (flags & CC_BACKGROUND_ITEM_HAS_SCOLOR &&
      priv->current_source != SOURCE_COLORS)
    {
      g_settings_set_string (priv->settings, WP_SCOLOR_KEY, cc_background_item_get_scolor (item));
    }
  else
    {
      scolor = g_settings_get_string (priv->settings, WP_SCOLOR_KEY);
      g_object_set (G_OBJECT (item), "secondary-color", scolor, NULL);
    }

  /* Apply all changes */
  g_settings_apply (priv->settings);

  update_remove_button (panel, item);

  /* update the preview information */
  if (draw_preview != FALSE)
    {
      update_preview (priv, item);

      /* Save the source XML if there is one */
      filename = get_save_path ();
      if (create_save_dir ())
        cc_background_xml_save (priv->current_background, filename);
    }
}
static void
cc_background_panel_init (CcBackgroundPanel *self)
{
  CcBackgroundPanelPrivate *priv;
  gchar *objects[] = { "style-liststore",
      "sources-liststore", "background-panel", "sizegroup", NULL };
  GError *err = NULL;
  GtkWidget *widget;
  GtkListStore *store;
  GtkStyleContext *context;

  priv = self->priv = BACKGROUND_PANEL_PRIVATE (self);

  priv->builder = gtk_builder_new ();

  gtk_builder_add_objects_from_file (priv->builder,
                                     DATADIR"/background.ui",
                                     objects, &err);

  if (err)
    {
      g_warning ("Could not load ui: %s", err->message);
      g_error_free (err);
      return;
    }

  /* See shell_notify_cb for details */
  g_signal_connect (WID ("scrolledwindow1"), "realize",
                    G_CALLBACK (scrolled_realize_cb), self);

  priv->settings = g_settings_new (WP_PATH_ID);
  g_settings_delay (priv->settings);

  store = (GtkListStore*) gtk_builder_get_object (priv->builder,
                                                  "sources-liststore");

  priv->wallpapers_source = bg_wallpapers_source_new ();
  gtk_list_store_insert_with_values (store, NULL, G_MAXINT,
                                     COL_SOURCE_NAME, _("Wallpapers"),
                                     COL_SOURCE_TYPE, SOURCE_WALLPAPERS,
                                     COL_SOURCE, priv->wallpapers_source,
                                     -1);

  priv->pictures_source = bg_pictures_source_new ();
  gtk_list_store_insert_with_values (store, NULL, G_MAXINT,
                                     COL_SOURCE_NAME, _("Pictures Folder"),
                                     COL_SOURCE_TYPE, SOURCE_PICTURES,
                                     COL_SOURCE, priv->pictures_source,
                                     -1);

  priv->colors_source = bg_colors_source_new ();
  gtk_list_store_insert_with_values (store, NULL, G_MAXINT,
                                     COL_SOURCE_NAME, _("Colors & Gradients"),
                                     COL_SOURCE_TYPE, SOURCE_COLORS,
                                     COL_SOURCE, priv->colors_source,
                                     -1);

#ifdef HAVE_LIBSOCIALWEB
  priv->flickr_source = bg_flickr_source_new ();
  gtk_list_store_insert_with_values (store, NULL, G_MAXINT,
                                     COL_SOURCE_NAME, _("Flickr"),
                                     COL_SOURCE_TYPE, SOURCE_FLICKR,
                                     COL_SOURCE, priv->flickr_source,
                                     -1);
#endif


  /* add the top level widget */
  widget = WID ("background-panel");

  gtk_container_add (GTK_CONTAINER (self), widget);
  gtk_widget_show_all (GTK_WIDGET (self));

  /* connect to source change signal */
  widget = WID ("sources-combobox");
  g_signal_connect (widget, "changed", G_CALLBACK (source_changed_cb), priv);

  /* select first item */
  gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);

  /* connect to the background iconview change signal */
  widget = WID ("backgrounds-iconview");
  g_signal_connect (widget, "selection-changed",
                    G_CALLBACK (backgrounds_changed_cb),
                    self);

  /* Join treeview and buttons */
  widget = WID ("scrolledwindow1");
  context = gtk_widget_get_style_context (widget);
  gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);
  widget = WID ("toolbar1");
  context = gtk_widget_get_style_context (widget);
  gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);

  g_signal_connect (WID ("add_button"), "clicked",
		    G_CALLBACK (add_button_clicked), self);
  g_signal_connect (WID ("remove_button"), "clicked",
		    G_CALLBACK (remove_button_clicked), self);

  /* Add drag and drop support for bg images */
  widget = WID ("scrolledwindow1");
  gtk_drag_dest_set (widget, GTK_DEST_DEFAULT_ALL, NULL, 0, GDK_ACTION_COPY);
  gtk_drag_dest_add_uri_targets (widget);
  g_signal_connect (widget, "drag-data-received",
		    G_CALLBACK (cc_background_panel_drag_uris), self);


  /* setup preview area */
  gtk_label_set_ellipsize (GTK_LABEL (WID ("background-label")), PANGO_ELLIPSIZE_END);
  widget = WID ("preview-area");
  g_signal_connect (widget, "draw", G_CALLBACK (preview_draw_cb),
                    self);

  priv->display_base = gdk_pixbuf_new_from_file (DATADIR "/display-base.png",
                                                 NULL);
  priv->display_overlay = gdk_pixbuf_new_from_file (DATADIR
                                                    "/display-overlay.png",
                                                    NULL);

  g_signal_connect (WID ("style-combobox"), "changed",
                    G_CALLBACK (style_changed_cb), self);

  g_signal_connect (WID ("style-pcolor"), "color-set",
                    G_CALLBACK (color_changed_cb), self);
  g_signal_connect (WID ("style-scolor"), "color-set",
                    G_CALLBACK (color_changed_cb), self);
  g_signal_connect (WID ("swap-color-button"), "clicked",
                    G_CALLBACK (swap_colors_clicked), self);

  priv->copy_cancellable = g_cancellable_new ();

  priv->thumb_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL);

  load_current_bg (self);

  update_preview (priv, NULL);

  /* Setup the edit box with our current settings */
  source_update_edit_box (priv, TRUE);
}
Beispiel #29
0
LRESULT preview_command(HWND hWnd, WPARAM wParam)
{
    switch(LOWORD(wParam))
    {
        case ID_FILE_EXIT:
            PostMessageW(hWnd, WM_CLOSE, 0, 0);
            break;

        case ID_PREVIEW_NEXTPAGE:
        case ID_PREVIEW_PREVPAGE:
        {
            if(LOWORD(wParam) == ID_PREVIEW_NEXTPAGE)
                preview.page++;
            else
                preview.page--;

            update_preview(hWnd);
        }
        break;

        case ID_PREVIEW_NUMPAGES:
            toggle_num_pages(hWnd);
            break;

        case ID_PREVIEW_ZOOMIN:
            if (preview.zoomlevel < 2)
            {
                if (preview.zoomlevel == 0)
                    preview.saved_pages_shown = preview.pages_shown;
                preview.zoomlevel++;
                preview.zoomratio = 0;
                if (preview.pages_shown > 1)
                {
                    /* Forced switch to one page when zooming in. */
                    toggle_num_pages(hWnd);
                } else {
                    HWND hwndPreview = GetDlgItem(hWnd, IDC_PREVIEW);
                    update_preview_sizes(hwndPreview, TRUE);
                    InvalidateRect(hwndPreview, NULL, FALSE);
                    update_preview_buttons(hWnd);
                }
            }
            break;

        case ID_PREVIEW_ZOOMOUT:
            if (preview.zoomlevel > 0)
            {
                HWND hwndPreview = GetDlgItem(hWnd, IDC_PREVIEW);
                preview.zoomlevel--;
                preview.zoomratio = 0;
                if (preview.zoomlevel == 0 && preview.saved_pages_shown > 1) {
                    toggle_num_pages(hWnd);
                } else {
                    update_preview_sizes(hwndPreview, TRUE);
                    InvalidateRect(hwndPreview, NULL, FALSE);
                    update_preview_buttons(hWnd);
                }
            }
            break;

        case ID_PRINT:
            dialog_print(hWnd, preview.wszFileName);
            SendMessageW(hWnd, WM_CLOSE, 0, 0);
            break;
    }

    return 0;
}
Beispiel #30
0
void PngyuPreviewWindow::show_original_toggled( bool )
{
  update_preview();
}