コード例 #1
0
void validate_menu(GtkTreeIter * iter)
{
	struct validate *validate;
	GtkWidget *scrolled_window;
	GtkWidget *text_view;
	GtkTextBuffer *text_buffer;

	gboolean updated = FALSE; 
	gdouble scroll_hvalue = 0;
	gdouble scroll_vvalue = 0;

	gtk_tree_model_get(GTK_TREE_MODEL(debr.ui_menu.model), iter, MENU_VALIDATE_POINTER, &validate, -1);
	if (validate != NULL) {
		updated = TRUE;
		validate->menu_iter = *iter;
		scroll_hvalue = gtk_adjustment_get_value(gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(validate->widget)));
		scroll_vvalue = gtk_adjustment_get_value(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(validate->widget)));
		gtk_text_buffer_set_text(validate->text_buffer, "", 0);
		goto out;
	}

	scrolled_window = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC,
				       GTK_POLICY_AUTOMATIC);
	gtk_box_pack_end(GTK_BOX(debr.ui_validate.text_view_vbox), scrolled_window, TRUE, TRUE, 0);
	text_buffer = gtk_text_buffer_new(NULL);
	text_view = gtk_text_view_new_with_buffer(text_buffer);
	gtk_widget_show(text_view);
	gtk_container_add(GTK_CONTAINER(scrolled_window), text_view);
	g_object_set(G_OBJECT(text_view), "editable", FALSE, "cursor-visible", FALSE, NULL);

	PangoFontDescription *font = pango_font_description_new();
	pango_font_description_set_family(font, "monospace");
	gtk_widget_modify_font(text_view, font);
	pango_font_description_free(font);

	GebrGeoXmlValidateOperations operations;
	operations.append_text = (void(*)(gpointer,const gchar*,...))validate_append_text;
	operations.append_text_emph = (void(*)(gpointer,const gchar*,...))validate_append_text_emph;
	operations.append_text_error = NULL;
	operations.append_text_error_with_paths = (void(*)(gpointer, gint, const gchar *, const gchar *, GebrValidateCaseName, const gchar *,
							   ...))validate_append_text_error;
	GebrGeoXmlValidateOptions options;
	options.all = TRUE;
	options.ehelp = -1;
	validate = g_new(struct validate, 1);
	validate->widget = scrolled_window;
	validate->text_view = text_view;
	validate->text_buffer = text_buffer;
	validate->menu_iter = *iter;
	validate->geoxml_validate = gebr_geoxml_validate_new(validate, operations, options);
	gtk_list_store_append(debr.ui_validate.list_store, &validate->iter);

out:
	gtk_tree_store_set(debr.ui_menu.model, iter, MENU_VALIDATE_NEED_UPDATE, FALSE,
			   MENU_VALIDATE_POINTER, validate, -1);

	GebrGeoXmlFlow * menu = menu_get_xml_pointer(iter);
	gint error_count = gebr_geoxml_validate_report_menu(validate->geoxml_validate, menu);
	gtk_list_store_set(debr.ui_validate.list_store, &validate->iter,
			   VALIDATE_ICON, !error_count ? debr.pixmaps.stock_apply : debr.pixmaps.stock_warning,
			   VALIDATE_FILENAME, gebr_geoxml_document_get_filename(GEBR_GEOXML_DOCUMENT(menu)),
			   VALIDATE_POINTER, validate, -1);
	validate_set_selected(&validate->iter);

	if (updated) {
		gtk_adjustment_set_value(gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(validate->widget)), scroll_hvalue);
		gtk_adjustment_set_value(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(validate->widget)), scroll_vvalue);
	}
}
コード例 #2
0
int
main(int argc, char **argv)
{
    GtkWidget *widget;
    gchar *glade_xml_file;

    gtk_init(&argc, &argv);
    set_font();
    get_asf_share_dir_with_argv0(argv[0]);
    set_tiff_warning_handler();

    asfPrintStatus("\nASF MapReady:\n");
    const char *share_dir = get_asf_share_dir();

    if (!share_dir)
      // this actually should never happen with the current implementation
      // of get_asf_share_dir() -- always sets the share dir to something
      // even if it is a bad guess... in which case the next check will fail
      asfPrintError("Could not find the ASF share directory!\n");

    glade_xml_file = (gchar *)find_in_share("mapready.glade");
    if (!glade_xml_file)
      asfPrintError("Could not find the mapready.glade file!\n"
                    "It should be in the share files directory, here:\n"
                    "  %s\n", share_dir);
    glade_xml = glade_xml_new(glade_xml_file, NULL, NULL);
    if (!glade_xml)
      asfPrintError("Could not load the mapready.glade file!\n"
                    "This file may be corrupt. mapready.glade was found in:\n"
                    "  %s\n", share_dir);
    g_free(glade_xml_file);

    asfPrintStatus("Using share files directory: %s\n\n", share_dir);

    /* thumbnails supported in GTK 2.4 or greater */
#ifdef G_THREADS_ENABLED
    use_thumbnails = gtk_major_version >= 2 && gtk_minor_version >= 4;
#else
    use_thumbnails = FALSE;
#endif

#ifdef win32
    // On windows, ensure that our installed sh.exe is the one that is found,
    // by severely restricting the path.
    char pathenv[1024];
    sprintf(pathenv, "PATH=%s", get_asf_bin_dir());
    putenv(pathenv);
#endif

    if (!use_thumbnails)
    {
        printf("GTK Version < 2.4 -- output thumbnails disabled.\n");
    }
    else
    {
        // We will want to load thumbnails in other threads.
        if ( !g_thread_supported () ) {
            g_thread_init (NULL);
        }
    }

    /* allow FOPEN, FREAD, FWRITE to fail without aborting */
    caplib_behavior_on_error = BEHAVIOR_ON_ERROR_CONTINUE;

    /* add version number to window title, request a default size */
    char gtitle [256];
    sprintf (gtitle, "ASF MapReady: Version %s",
             MAPREADY_VERSION_STRING);

    widget = get_widget_checked("asf_convert");
    gtk_window_set_title(GTK_WINDOW(widget), gtitle);
    // commenting this out - now supported within glade
    //gtk_window_resize(GTK_WINDOW(widget), 1000, 700);

    /* select defaults for dropdowns & buttons & labeling */
    widget = get_widget_checked("scaling_method_combobox");
    set_combo_box_item(widget, SCALING_METHOD_SIGMA);

    widget = get_widget_checked("import_checkbutton");
    gtk_widget_set_sensitive(widget, FALSE);

    widget = get_widget_checked("input_data_type_combobox");
    set_combo_box_item(widget, INPUT_TYPE_AMP);

    widget = get_widget_checked("resample_option_menu");
    set_combo_box_item(widget, RESAMPLE_BILINEAR);

    // Populate the colormap drop-downs on both the import tab and in the
    // browse dialog
    populate_polsarpro_classification_optionmenu();
    widget = get_widget_checked("browse_select_colormap_optionmenu");
    gtk_option_menu_set_history(GTK_OPTION_MENU(widget), 0);

    widget = get_widget_checked("output_format_combobox");
    set_combo_box_item(widget, OUTPUT_FORMAT_JPEG);

    widget = get_widget_checked("geocode_checkbutton");
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
    geocode_options_changed();
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), FALSE);

    widget = get_widget_checked("about_dialog_copyright_label");
    gtk_label_set_text(GTK_LABEL(widget), ASF_COPYRIGHT_STRING);

    // Hide latitude selection stuff until we start supporting
    // swath products (level 0) again
    widget = get_widget_checked("latitude_checkbutton");
    gtk_widget_hide(widget);
    widget = get_widget_checked("latitude_low_label");
    gtk_widget_hide(widget);
    widget = get_widget_checked("latitude_hi_label");
    gtk_widget_hide(widget);
    widget = get_widget_checked("latitude_low_entry");
    gtk_widget_hide(widget);
    widget = get_widget_checked("latitude_hi_entry");
    gtk_widget_hide(widget);

    // For now, do not allow manual offsets
    show_widget("hbox_tc_matching", FALSE);

    // This option is deprecated -- we always apply the fix now
    // and don't give the user the option of turning it off.  Probably
    // we can just delete all code associated with it, but for now we
    // just turn it on, and hide it.
    set_checked("apply_metadata_fix_checkbutton", TRUE);
    widget = get_widget_checked("apply_metadata_fix_checkbutton");
    gtk_widget_hide(widget);

    // Muck with the fonts in the About dialog
    widget = get_widget_checked("about_dialog_mapready_label");
    gchar *str = gtitle;
    gchar *text;
    PangoAttrList *attrs;
    sprintf(gtitle,
                "\n<b>ASF MapReady</b>\n"
                "<i>Remote Sensing Toolkit</i>\n"
                "ver. %s",
                MAPREADY_VERSION_STRING);
    if (strlen(SVN_REV)>0)
        sprintf(gtitle, "%s (build %s)", gtitle, SVN_REV);
    else
        strcat(gtitle, " (custom build)");

    pango_parse_markup(str, -1, 0, &attrs, &text, NULL, NULL);
    gtk_label_set_attributes(GTK_LABEL(widget), attrs);
    gtk_label_set_text(GTK_LABEL(widget), text);
    PangoFontDescription *font_desc =
      pango_font_description_from_string("Sans 12");
    gtk_widget_modify_font(widget, font_desc);

    // Muck with the "Select Processing Steps" label
    widget = get_widget_checked("select_processing_steps_label");
    str = gtitle;
    sprintf(gtitle, "<b><i>  Select Processing Steps:</i></b>");
    pango_parse_markup(str, -1, 0, &attrs, &text, NULL, NULL);
    gtk_label_set_attributes(GTK_LABEL(widget), attrs);
    gtk_label_set_text(GTK_LABEL(widget), text);
    font_desc = pango_font_description_from_string("Sans 12");
    gtk_widget_modify_font(widget, font_desc);

    /* fire handlers for hiding/showing stuff */
    output_format_combobox_changed();
    input_data_type_changed();
    geocode_options_changed();
    load_external_commands();
    external_settings_changed();
    set_toolbar_images();
    show_execute_button(TRUE);

    /* build columns in the files section */
    show_full_paths = FALSE; // Set before setup_files_list(), default to FALSE
    widget = get_widget_checked("show_full_path_names_checkbutton");
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), FALSE);
    setup_files_list();

    /* allow multiple selects */
    widget = get_widget_checked("input_file_selection");
    gtk_file_selection_set_select_multiple(GTK_FILE_SELECTION(widget), TRUE);

    /* drag-n-drop setup */
    setup_dnd();

    /* right-click menu setup */
    setup_popup_menu();

    /* bands dropdown setup*/
    setup_band_comboboxes();

    current_naming_scheme = naming_scheme_default();

    /* set initial vpanel setting */
    //widget = get_widget_checked("vertical_pane");
    //gtk_paned_set_position(GTK_PANED(widget), 240);

    /* Connect signal handlers.  */
    glade_xml_signal_autoconnect (glade_xml);

    /* initial flag settings */
    processing = FALSE;
    settings_on_execute = NULL;

    /* explicit call to the function that refreshes the "summary" */
    /* section when options are changed, so get the settings      */
    /* initially in there                                         */
    input_data_formats_changed();
    input_data_type_combobox_changed();
    default_to_terrcorr_on();
    default_to_keep_temp();
    terrcorr_options_changed();
    init_browse_format_combobox();

    /* For some reason, it did not work to set this via glade        */
    /* So, we have to select our default faraday rotation style here */
    rb_select("rb_fr_global", TRUE);
    polarimetry_settings_changed();

    /* put files on the command-line into the files section */
    populate_files_list(argc, argv);

    /* set up the rgb stuff on the export tab */
    rgb_combo_box_setup();

    /* enters the main GTK loop */
    gtk_main ();

    /* clean up, application has been closed */
    if (settings_on_execute)
        settings_delete(settings_on_execute);

    if (output_directory)
        g_free(output_directory);

    if (current_naming_scheme)
        naming_scheme_delete(current_naming_scheme);

    release_predefined_projections();

    exit (EXIT_SUCCESS);
}
コード例 #3
0
ファイル: iupgtk_tabs.c プロジェクト: svn2github/iup-iup
static void gtkTabsChildAddedMethod(Ihandle* ih, Ihandle* child)
{
  if (IupGetName(child) == NULL)
    iupAttribSetHandleName(child);

  if (ih->handle)
  {
    GtkWidget* tab_page;
    GtkWidget *tab_label = NULL, *tab_image = NULL;
    char *tabtitle, *tabimage;
    int pos;
    unsigned char r, g, b;

    pos = IupGetChildPos(ih, child);

    tab_page = gtk_fixed_new();
    gtk_widget_show(tab_page);

    tabtitle = iupAttribGet(child, "TABTITLE");
    if (!tabtitle) tabtitle = iupTabsAttribGetStrId(ih, "TABTITLE", pos);
    tabimage = iupAttribGet(child, "TABIMAGE");
    if (!tabimage) tabimage = iupTabsAttribGetStrId(ih, "TABIMAGE", pos);
    if (!tabtitle && !tabimage)
      tabtitle = "     ";

    if (tabtitle)
    {
      tab_label = gtk_label_new(iupgtkStrConvertToUTF8(tabtitle));

#if GTK_CHECK_VERSION(2, 6, 0)
      if (ih->data->orientation == ITABS_VERTICAL)
        gtk_label_set_angle((GtkLabel*)tab_label, 90);
#endif
    }

    if (tabimage)
    {
      GdkPixbuf* pixbuf = iupImageGetImage(tabimage, ih, 0, "TABIMAGE");

      tab_image = gtk_image_new();

      if (pixbuf)
        gtk_image_set_from_pixbuf((GtkImage*)tab_image, pixbuf);
    }

    iupAttribSetStr(ih, "_IUPGTK_IGNORE_CHANGE", "1");

    if (tabimage && tabtitle)
    {
      GtkWidget* box;
      if (ih->data->orientation == ITABS_VERTICAL)
        box = gtk_vbox_new(FALSE, 2);
      else
        box = gtk_hbox_new(FALSE, 2);
      gtk_widget_show(box);

      gtk_container_add((GtkContainer*)box, tab_image);
      gtk_container_add((GtkContainer*)box, tab_label);

      gtk_notebook_insert_page((GtkNotebook*)ih->handle, tab_page, box, pos);
      gtk_notebook_set_menu_label_text((GtkNotebook*)ih->handle, tab_page, gtk_label_get_text((GtkLabel*)tab_label));
    }
    else if (tabimage)
      gtk_notebook_insert_page((GtkNotebook*)ih->handle, tab_page, tab_image, pos);
    else
      gtk_notebook_insert_page((GtkNotebook*)ih->handle, tab_page, tab_label, pos);

    gtk_widget_realize(tab_page);

    iupAttribSetStr(child, "_IUPGTK_TABIMAGE", (char*)tab_image);  /* store it even if its NULL */
    iupAttribSetStr(child, "_IUPGTK_TABLABEL", (char*)tab_label);
    iupAttribSetStr(child, "_IUPTAB_CONTAINER", (char*)tab_page);
    iupStrToRGB(IupGetAttribute(ih, "BGCOLOR"), &r, &g, &b);
    iupgtkBaseSetBgColor(tab_page, r, g, b);

    if (tabtitle)
    {
      PangoFontDescription* fontdesc = (PangoFontDescription*)iupgtkGetPangoFontDescAttrib(ih);
      gtk_widget_modify_font(tab_label, fontdesc);
      iupgtkFontUpdatePangoLayout(ih, gtk_label_get_layout((GtkLabel*)tab_label));

      iupgtkBaseSetBgColor(tab_label, r, g, b);

      iupStrToRGB(IupGetAttribute(ih, "FGCOLOR"), &r, &g, &b);
      iupgtkBaseSetFgColor(tab_label, r, g, b);

      gtk_widget_show(tab_label);
      gtk_widget_realize(tab_label);
    }

    if (tabimage)
    {
      gtk_widget_show(tab_image);
      gtk_widget_realize(tab_image);
    }

    iupAttribSetStr(ih, "_IUPGTK_IGNORE_CHANGE", NULL);
  }
}
コード例 #4
0
ファイル: isf_setup_win.cpp プロジェクト: Tarnyko/dali-isf
GtkWidget *ISFSetupWin::create_isf_setup_widget (void)
{
    GtkWidget *language_button = NULL, *hbox = NULL, *vbox = NULL, *scroll = NULL;

    GtkTreeIter      iter, it;
    GtkCellRenderer *cell = NULL;

    vbox = gtk_vbox_new (FALSE, 0);
    gtk_widget_show (vbox);

    hbox = gtk_hbox_new (FALSE, 0);
    gtk_widget_show (hbox);
    gtk_box_pack_start (GTK_BOX (vbox), hbox, false, false, 0);
    gtk_widget_set_size_request (hbox, _screen_width, (int)(40*_height_rate));
    gtk_container_set_border_width (GTK_CONTAINER (hbox),(int)( 5*_height_rate));

    // Create application list combox
    _combo_app = gtk_combo_box_new ();
    cell = gtk_cell_renderer_text_new ();
    _app_list_store = gtk_list_store_new (1, G_TYPE_STRING);

    for (unsigned int i = 0; i < _isf_app_list.size (); i++) {
        gtk_list_store_prepend (_app_list_store, &iter);
        gtk_list_store_set (_app_list_store, &iter, 0, _isf_app_list[_isf_app_list.size () - i - 1].c_str (), -1);
    }

    _app_combo_default_path = gtk_tree_model_get_path (GTK_TREE_MODEL (_app_list_store), &iter);

    gtk_cell_layout_pack_start ((GtkCellLayout *) _combo_app, cell, TRUE);
    gtk_cell_layout_set_attributes ((GtkCellLayout *) _combo_app, cell, "text", 0, NULL);
    gtk_combo_box_set_model ((GtkComboBox *) _combo_app, (GtkTreeModel *) _app_list_store);
    gtk_tree_model_get_iter (GTK_TREE_MODEL (_app_list_store), &it, _app_combo_default_path);
    gtk_combo_box_set_active_iter ((GtkComboBox *) _combo_app, &it);
//    gtk_widget_show (_combo_app);  //hide the app list combox temp
    g_signal_connect ((gpointer) _combo_app, "changed",
                      G_CALLBACK (app_selection_changed_callback), (gpointer)this);

    // Create language button
    language_button = gtk_button_new_with_label ("Language");
    GtkStyle *style1 = gtk_rc_get_style (language_button);
    GtkWidget *newlabel = gtk_label_new ("Language");
    if (newlabel) {
        GtkWidget * old = gtk_bin_get_child (GTK_BIN (language_button));
        if (old)
            gtk_container_remove (GTK_CONTAINER (language_button), old);
        gtk_container_add (GTK_CONTAINER (language_button), newlabel);
    }
    if(style1)
    {
        gtk_widget_modify_font (language_button, style1->font_desc);
    }
    gtk_widget_show (language_button);
    gtk_box_pack_start (GTK_BOX (hbox), language_button, true, true, 0);
    g_signal_connect ((gpointer) language_button, "clicked",
                      G_CALLBACK (on_language_button_clicked_callback), (gpointer)this);

    // Create ISE list view
    scroll = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
                                    GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
    gtk_container_add (GTK_CONTAINER (vbox), scroll);
    gtk_widget_show (scroll);

    GtkWidget *view = create_factory_list_view ();
    create_and_fill_factory_list_store ();
    gtk_tree_view_set_model (GTK_TREE_VIEW  (view), GTK_TREE_MODEL (_factory_list_store));
    gtk_container_add (GTK_CONTAINER (scroll), view);
    gtk_widget_show (view);

    return vbox;
}
コード例 #5
0
SourceView::SourceView(const std::string& language, bool readOnly)
{
	// Set the search path to the language and style files
	gchar* directories[2];

#if defined(POSIX) && defined(PKGDATADIR)
	std::string langFilesDir = std::string(PKGDATADIR) + "/sourceviewer/";
#else
	std::string langFilesDir = GlobalRegistry().get(RKEY_APP_PATH) + "sourceviewer/";
#endif

	directories[0] = const_cast<gchar*>(langFilesDir.c_str()); // stupid GtkSourceLanguageManager is expecting non-const gchar* pointer...
	directories[1] = NULL;

	GtkSourceStyleSchemeManager* styleSchemeManager = gtk_source_style_scheme_manager_get_default();
	gtk_source_style_scheme_manager_set_search_path(styleSchemeManager, directories);
	gtk_source_style_scheme_manager_force_rescan(styleSchemeManager);

	_langManager = gtk_source_language_manager_new();
	gtk_source_language_manager_set_search_path(_langManager, directories);

	GtkSourceLanguage* lang = gtk_source_language_manager_get_language(_langManager, language.c_str());

	if (lang == NULL)
	{
		globalErrorStream() << "SourceView: Cannot find language " << language << " in " << langFilesDir << std::endl;
	}

	// Remember the pointers to the textbuffers
	if (lang != NULL)
	{
		_buffer = gtk_source_buffer_new_with_language(lang);
		gtk_source_buffer_set_highlight_syntax(_buffer, TRUE);
	}
	else
	{
		_buffer = gtk_source_buffer_new(NULL);
		gtk_source_buffer_set_highlight_syntax(_buffer, FALSE);
	}

	_view = GTK_SOURCE_VIEW(gtk_source_view_new_with_buffer(_buffer));

	gtk_widget_set_size_request(GTK_WIDGET(_view), 0, -1); // allow shrinking
	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(_view), GTK_WRAP_WORD);
	gtk_text_view_set_editable(GTK_TEXT_VIEW(_view), readOnly ? FALSE : TRUE);

	gtk_source_view_set_show_line_numbers(_view, TRUE);
	gtk_source_view_set_auto_indent(_view, TRUE);

	// Use a fixed width font
	PangoFontDescription* fontDesc = pango_font_description_from_string("Monospace");

	if (fontDesc != NULL)
	{
		gtk_widget_modify_font(GTK_WIDGET(_view), fontDesc);
	}

	// Use a tab size of 4
	gtk_source_view_set_tab_width(GTK_SOURCE_VIEW(_view), 4);

	widget_connect_escape_clear_focus_widget(GTK_WIDGET(_view));

	_widget = gtkutil::ScrolledFrame(GTK_WIDGET(_view));
}
コード例 #6
0
ファイル: desktopicon.c プロジェクト: khorben/DeforaOS
/* desktopicon_set_font */
void desktopicon_set_font(DesktopIcon * desktopicon,
		PangoFontDescription * font)
{
	gtk_widget_modify_font(desktopicon->label, font);
}
コード例 #7
0
ファイル: cvs.c プロジェクト: khorben/DeforaOS
/* cvs_add_task */
static int _cvs_add_task(CVS * cvs, char const * title,
		char const * directory, char * argv[])
{
	BrowserPluginHelper * helper = cvs->helper;
	CVSTask ** p;
	CVSTask * task;
	GSpawnFlags flags = G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD;
	gboolean res;
	GError * error = NULL;
	PangoFontDescription * font;
	char buf[256];
	GtkWidget * vbox;
	GtkWidget * widget;

	if((p = realloc(cvs->tasks, sizeof(*p) * (cvs->tasks_cnt + 1))) == NULL)
		return -helper->error(helper->browser, strerror(errno), 1);
	cvs->tasks = p;
	if((task = object_new(sizeof(*task))) == NULL)
		return -helper->error(helper->browser, error_get(), 1);
	task->cvs = cvs;
#ifdef DEBUG
	argv[0] = "echo";
#endif
	res = g_spawn_async_with_pipes(directory, argv, NULL, flags, NULL, NULL,
			&task->pid, NULL, &task->o_fd, &task->e_fd, &error);
	if(res != TRUE)
	{
		helper->error(helper->browser, error->message, 1);
		g_error_free(error);
		object_delete(task);
		return -1;
	}
	cvs->tasks[cvs->tasks_cnt++] = task;
	/* widgets */
	font = pango_font_description_new();
	pango_font_description_set_family(font, "monospace");
	task->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_default_size(GTK_WINDOW(task->window), 600, 400);
#if GTK_CHECK_VERSION(2, 6, 0)
	gtk_window_set_icon_name(GTK_WINDOW(task->window), plugin.icon);
#endif
	snprintf(buf, sizeof(buf), "%s - %s (%s)", _("CVS"), title, directory);
	gtk_window_set_title(GTK_WINDOW(task->window), buf);
	g_signal_connect_swapped(task->window, "delete-event", G_CALLBACK(
				_cvs_task_on_closex), task);
	vbox = gtk_vbox_new(FALSE, 0);
	widget = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(widget),
			GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	task->view = gtk_text_view_new();
	gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(task->view), FALSE);
	gtk_text_view_set_editable(GTK_TEXT_VIEW(task->view), FALSE);
	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(task->view),
			GTK_WRAP_WORD_CHAR);
	gtk_widget_modify_font(task->view, font);
	gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(widget),
			task->view);
	gtk_box_pack_start(GTK_BOX(vbox), widget, TRUE, TRUE, 0);
	task->statusbar = gtk_statusbar_new();
	task->statusbar_id = 0;
	gtk_box_pack_start(GTK_BOX(vbox), task->statusbar, FALSE, TRUE, 0);
	gtk_container_add(GTK_CONTAINER(task->window), vbox);
	gtk_widget_show_all(task->window);
	pango_font_description_free(font);
	/* events */
	task->source = g_child_watch_add(task->pid, _cvs_task_on_child_watch,
			task);
	task->o_channel = g_io_channel_unix_new(task->o_fd);
	if((g_io_channel_set_encoding(task->o_channel, NULL, &error))
			!= G_IO_STATUS_NORMAL)
	{
		helper->error(helper->browser, error->message, 1);
		g_error_free(error);
	}
	task->o_source = g_io_add_watch(task->o_channel, G_IO_IN,
			_cvs_task_on_io_can_read, task);
	task->e_channel = g_io_channel_unix_new(task->e_fd);
	if((g_io_channel_set_encoding(task->e_channel, NULL, &error))
			!= G_IO_STATUS_NORMAL)
	{
		helper->error(helper->browser, error->message, 1);
		g_error_free(error);
	}
	task->e_source = g_io_add_watch(task->e_channel, G_IO_IN,
			_cvs_task_on_io_can_read, task);
	_cvs_task_set_status(task, _("Running command..."));
	return 0;
}
コード例 #8
0
ファイル: glide-gtk-util.c プロジェクト: GNOME/glide
void
glide_gtk_util_set_widget_font_small (GtkWidget *w)
{
  gtk_widget_modify_font (w, pango_font_description_from_string ("Sans 8"));
}
コード例 #9
0
ファイル: bmp.c プロジェクト: ProjectZeroSlackr/XMP
static void file_info_box_build()
{
	GtkWidget *hbox1, *vbox1;
	GtkWidget *info_exit, *info_mute;
	GtkWidget *info_unmute, *info_about;
	GtkWidget *scrw1;
	GtkWidget *expander;
	GdkVisual *visual;
	PangoFontDescription *desc;

	info_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_object_set_data(GTK_OBJECT(info_window),
					"info_window", info_window);
	gtk_window_set_title(GTK_WINDOW(info_window),"Extended Module Player");
	gtk_window_set_policy(GTK_WINDOW(info_window), FALSE, FALSE, TRUE);
	gtk_signal_connect(GTK_OBJECT(info_window), "destroy",
		GTK_SIGNAL_FUNC(gtk_widget_destroyed), &info_window);
	gtk_container_border_width(GTK_CONTAINER(info_window), 0);
	gtk_widget_realize (info_window);

	vbox1 = gtk_vbox_new(FALSE, 0);
	gtk_container_add(GTK_CONTAINER(info_window), vbox1);
	gtk_object_set_data(GTK_OBJECT(vbox1), "vbox1", vbox1);
	gtk_container_border_width(GTK_CONTAINER(vbox1), 4);

	visual = gdk_visual_get_system();

	/*
	 * Image
	 */

	frame1 = gtk_event_box_new();
	gtk_object_set_data(GTK_OBJECT(frame1), "frame1", frame1);
	gtk_widget_set_size_request(frame1, 300, 128);
	gtk_box_pack_start(GTK_BOX(vbox1), frame1, FALSE, FALSE, 0);

	image = gdk_image_new(GDK_IMAGE_FASTEST, visual, 300, 128);
	ximage = GDK_IMAGE_XIMAGE(image);
	image1 = gtk_image_new_from_image(image, NULL);

	gtk_object_set_data(GTK_OBJECT(image1), "image1", image1);
	gtk_container_add (GTK_CONTAINER(frame1), image1);
	gtk_widget_set_events (frame1, GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK);
	gtk_signal_connect (GTK_OBJECT (frame1), "button_press_event",
			(GtkSignalFunc)image1_clicked, NULL);

	/*
	 * Buttons
	 */

	hbox1 = gtk_hbox_new (TRUE, 0);
	gtk_object_set_data(GTK_OBJECT(hbox1), "hbox1", hbox1);
	gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, FALSE, 0);

	info_mute = gtk_button_new_with_label("Mute");
	gtk_signal_connect (GTK_OBJECT (info_mute), "clicked",
                            (GtkSignalFunc) button_mute, NULL);
	gtk_object_set_data(GTK_OBJECT(info_mute), "info_mute", info_mute);
	gtk_box_pack_start(GTK_BOX(hbox1), info_mute, TRUE, TRUE, 0);

	info_unmute = gtk_button_new_with_label("Unmute");
	gtk_signal_connect (GTK_OBJECT (info_unmute), "clicked",
                            (GtkSignalFunc) button_unmute, NULL);
	gtk_object_set_data(GTK_OBJECT(info_unmute), "info_unmute", info_unmute);
	gtk_box_pack_start(GTK_BOX(hbox1), info_unmute, TRUE, TRUE, 0);

	info_about = gtk_button_new_with_label("About");
	gtk_signal_connect_object(GTK_OBJECT(info_about), "clicked",
			(GtkSignalFunc) aboutbox, NULL);
	gtk_object_set_data(GTK_OBJECT(info_about), "info_about", info_about);
	gtk_box_pack_start(GTK_BOX(hbox1), info_about, TRUE, TRUE, 0);

	info_exit = gtk_button_new_with_label("Close");
	gtk_signal_connect_object(GTK_OBJECT(info_exit), "clicked",
		GTK_SIGNAL_FUNC(gtk_widget_hide), GTK_OBJECT(info_window));
	gtk_object_set_data(GTK_OBJECT(info_exit), "info_exit", info_exit);
	gtk_box_pack_start(GTK_BOX(hbox1), info_exit, TRUE, TRUE, 0);

	/*
	 * Info area
	 */

	expander = gtk_expander_new("Module information");

	scrw1 = gtk_scrolled_window_new(NULL, NULL);
	gtk_object_set_data(GTK_OBJECT(scrw1), "scrw1", scrw1);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrw1),
				GTK_POLICY_ALWAYS, GTK_POLICY_AUTOMATIC);

	gtk_container_add(GTK_CONTAINER(expander), scrw1);
	gtk_box_pack_start(GTK_BOX(vbox1), expander, TRUE, TRUE, 0);

	gtk_widget_set_size_request(scrw1, 290, 200);
	text1b = gtk_text_buffer_new(NULL);
	text1 = gtk_text_view_new_with_buffer(text1b);
	desc = pango_font_description_new();
	pango_font_description_set_family(desc, "Monospace");
	gtk_widget_modify_font(text1, desc);
	pango_font_description_free(desc);
	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text1), GTK_WRAP_NONE);

	gtk_object_set_data(GTK_OBJECT(text1), "text1", text1);
	gtk_container_add(GTK_CONTAINER(scrw1), text1);
	gtk_widget_realize(text1);

	gtk_widget_realize(image1);

	display = GDK_WINDOW_XDISPLAY(info_window->window);
	window = GDK_WINDOW_XWINDOW(info_window->window);
    	colormap = gdk_colormap_get_system();

	gdk_color_black(colormap, color_black);
	gdk_color_white(colormap, color_white);

	init_visual(visual);

	set_palette();
	clear_screen();

	ii->wresult = 0;

	panel_setup();
	gtk_timeout_add(50, (GtkFunction)panel_loop, NULL);
}
コード例 #10
0
ファイル: l_prov_usl.c プロジェクト: zaharchuktv/linuxbuh
void l_prov_usl(short dd,short md,short gd,
int podr,
int tipz,
const char *nomdok,
const char *nomdokp,
const char *kontr,
const char *kodop,
int lnds,
double sumad,//Сумма по документа
double sumkor, //Сумма корректировки к документа
float pnds,
GtkWidget *wpredok)
{
class prov_usl_data data;
char strsql[512];
SQL_str row;
SQLCURSOR cur;
iceb_u_str shet_suma;
sprintf(data.imaf_prot,"uslpr%d.tmp",getpid());

prosprusw(1,podr,dd,md,gd,nomdok,tipz,lnds,kodop,pnds,NULL,wpredok);
prosprusw(2,podr,dd,md,gd,nomdok,tipz,lnds,kodop,pnds,&shet_suma,wpredok);

data.tipz=tipz;
data.dd=dd;
data.md=md;
data.gd=gd;
data.nomdok.plus(nomdok);
data.podr=podr;
strcpy(data.metkasys,gettext("УСЛ"));
data.kontr.plus(kontr);
data.kodop.plus(kodop);
data.lnds=lnds;
data.nomdokp.plus(nomdokp);
data.sumkor=sumkor;
data.pnds=pnds;

//Читаем наименование склада
sprintf(strsql,"select naik from Sklad where kod=%d",podr);
if(iceb_sql_readkey(strsql,&row,&cur,wpredok) == 1)
 data.naim_podr.new_plus(row[0]);

//Читаем наименование операции
if(tipz == 1)
  sprintf(strsql,"select naik from Usloper1 where kod='%s'",kodop);
if(tipz == 2)
  sprintf(strsql,"select naik from Usloper2 where kod='%s'",kodop);
if(iceb_sql_readkey(strsql,&row,&cur,wpredok) == 1)
 data.naim_kodop.new_plus(row[0]);

//Читаем наименование контрагента
sprintf(strsql,"select naikon from Kontragent where kodkon='%s'",kontr);
if(iceb_sql_readkey(strsql,&row,&cur,wpredok) == 1)
 data.naim_kontr.new_plus(row[0]);


data.window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

gtk_window_set_position( GTK_WINDOW(data.window),ICEB_POS_CENTER);
gtk_window_set_modal(GTK_WINDOW(data.window),TRUE);

sprintf(strsql,"%s %s",name_system,
gettext("Работа с проводками (учёт услуг)"));

gtk_window_set_title (GTK_WINDOW (data.window),iceb_u_toutf(strsql));
gtk_container_set_border_width (GTK_CONTAINER (data.window), 5);

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


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

gtk_signal_connect_after(GTK_OBJECT(data.window),"key_press_event",GTK_SIGNAL_FUNC(prov_usl_key_press),&data);
gtk_signal_connect_after(GTK_OBJECT(data.window),"key_release_event",GTK_SIGNAL_FUNC(iceb_key_release),&data.kl_shift);

GtkWidget *hbox = gtk_hbox_new (FALSE, 1);
gtk_container_add (GTK_CONTAINER (data.window), hbox);

GtkWidget *vbox1 = gtk_vbox_new (FALSE, 1);
GtkWidget *vbox2 = gtk_vbox_new (FALSE, 1);

data.label_sheta=gtk_label_new (shet_suma.ravno_toutf());
PangoFontDescription *font_pango=pango_font_description_from_string(shrift_ravnohir.ravno());
gtk_widget_modify_font(GTK_WIDGET(data.label_sheta),font_pango);
pango_font_description_free(font_pango);

gtk_box_pack_start (GTK_BOX (hbox), vbox1, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox),data.label_sheta,FALSE, FALSE, 0);
gtk_widget_show_all(hbox);

data.label_kolstr=gtk_label_new ("");

iceb_u_str stroka;

prov_usl_sapka_menu(&data);



gtk_box_pack_start (GTK_BOX (vbox2),data.label_kolstr,FALSE, FALSE, 0);

gtk_widget_show(vbox1);
gtk_widget_show(vbox2);


data.sw = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_set_usize(GTK_WIDGET(data.sw),400,300);

gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (data.sw),GTK_SHADOW_ETCHED_IN);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (data.sw),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
//gtk_box_pack_start (GTK_BOX (vbox2), data.sw, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox2), data.sw, TRUE, TRUE, 0);

GtkWidget *hboxradio = gtk_hbox_new (TRUE, 0);

//Вставляем радиокнопки
GSList *group;

data.radiobutton[0]=gtk_radio_button_new_with_label(NULL,gettext("Дебет"));
//  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data.radiobutton[0]),TRUE); //Устанавливем активной кнопку
gtk_box_pack_start (GTK_BOX (hboxradio),data.radiobutton[0], TRUE, TRUE, 0);
gtk_signal_connect(GTK_OBJECT(data.radiobutton[0]), "clicked",GTK_SIGNAL_FUNC(prov_usl_radio0),&data);
//gtk_object_set_user_data(GTK_OBJECT(data.radiobutton0),(gpointer)"0");

group=gtk_radio_button_group(GTK_RADIO_BUTTON(data.radiobutton[0]));

sprintf(strsql,"%s",gettext("Кредит"));
data.radiobutton[1]=gtk_radio_button_new_with_label(group,strsql);
//  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data.radiobutton[1]),TRUE); //Устанавливем активной кнопку
gtk_signal_connect(GTK_OBJECT(data.radiobutton[1]), "clicked",GTK_SIGNAL_FUNC(prov_usl_radio1),&data);
gtk_box_pack_start (GTK_BOX (hboxradio),data.radiobutton[1], TRUE, TRUE, 0);

group=gtk_radio_button_group(GTK_RADIO_BUTTON(data.radiobutton[1]));

sprintf(strsql,"%s",gettext("Все"));
data.radiobutton[2]=gtk_radio_button_new_with_label(group,strsql);
//  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data.radiobutton[2]),TRUE); //Устанавливем активной кнопку
gtk_signal_connect(GTK_OBJECT(data.radiobutton[2]), "clicked",GTK_SIGNAL_FUNC(prov_usl_radio2),&data);
gtk_box_pack_start (GTK_BOX (hboxradio),data.radiobutton[2], TRUE, TRUE, 0);

gtk_box_pack_start(GTK_BOX (vbox2), hboxradio, FALSE,FALSE, 0);
gtk_widget_show_all(hboxradio);

//Кнопки
GtkTooltips *tooltips[KOL_F_KL];

sprintf(strsql,"F2 %s",gettext("Ввести"));
data.knopka[FK2]=gtk_button_new_with_label(strsql);
gtk_signal_connect(GTK_OBJECT(data.knopka[FK2]), "clicked",GTK_SIGNAL_FUNC(prov_usl_knopka),&data);
gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[FK2],TRUE,TRUE, 0);
tooltips[FK2]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[FK2],data.knopka[FK2],gettext("Ввод новой проводки"),NULL);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK2]),(gpointer)FK2);
gtk_widget_show(data.knopka[FK2]);

sprintf(strsql,"%sF2 %s",RFK,gettext("Корректировать"));
data.knopka[SFK2]=gtk_button_new_with_label(strsql);
gtk_signal_connect(GTK_OBJECT(data.knopka[SFK2]), "clicked",GTK_SIGNAL_FUNC(prov_usl_knopka),&data);
gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[SFK2],TRUE,TRUE, 0);
tooltips[SFK2]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[SFK2],data.knopka[SFK2],gettext("Корректировка выбранной записи"),NULL);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[SFK2]),(gpointer)SFK2);
gtk_widget_show(data.knopka[SFK2]);

sprintf(strsql,"F3 %s",gettext("Удалить"));
data.knopka[FK3]=gtk_button_new_with_label(strsql);
gtk_signal_connect(GTK_OBJECT(data.knopka[FK3]), "clicked",GTK_SIGNAL_FUNC(prov_usl_knopka),&data);
gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[FK3],TRUE,TRUE, 0);
tooltips[FK3]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[FK3],data.knopka[FK3],gettext("Удалить выбранную запись"),NULL);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK3]),(gpointer)FK3);
gtk_widget_show(data.knopka[FK3]);

sprintf(strsql,"%sF3 %s",RFK,gettext("Удалить"));
data.knopka[SFK3]=gtk_button_new_with_label(strsql);
gtk_signal_connect(GTK_OBJECT(data.knopka[SFK3]), "clicked",GTK_SIGNAL_FUNC(prov_usl_knopka),&data);
gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[SFK3],TRUE,TRUE, 0);
tooltips[SFK3]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[SFK3],data.knopka[SFK3],gettext("Удалить все проводки"),NULL);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[SFK3]),(gpointer)SFK3);
gtk_widget_show(data.knopka[SFK3]);

sprintf(strsql,"F4 %s",gettext("Проводки"));
data.knopka[FK4]=gtk_button_new_with_label(strsql);
gtk_signal_connect(GTK_OBJECT(data.knopka[FK4]), "clicked",GTK_SIGNAL_FUNC(prov_usl_knopka),&data);
gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[FK4],TRUE,TRUE, 0);
tooltips[FK4]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[FK4],data.knopka[FK4],gettext("Автоматическое выполнение проводок с использованием табличной настройки"),NULL);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK4]),(gpointer)FK4);
gtk_widget_show(data.knopka[FK4]);

sprintf(strsql,"%sF4 %s",RFK,gettext("Просмотр"));
data.knopka[SFK4]=gtk_button_new_with_label(strsql);
gtk_signal_connect(GTK_OBJECT(data.knopka[SFK4]), "clicked",GTK_SIGNAL_FUNC(prov_usl_knopka),&data);
gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[SFK4],TRUE,TRUE, 0);
tooltips[SFK4]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[SFK4],data.knopka[SFK4],gettext("Просмотр протокола хода автоматичного виконання проводок"),NULL);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[SFK4]),(gpointer)SFK4);
gtk_widget_show(data.knopka[SFK4]);

sprintf(strsql,"F5 %s",gettext("Настройка"));
data.knopka[FK5]=gtk_button_new_with_label(strsql);
gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[FK5],TRUE,TRUE, 0);
gtk_signal_connect(GTK_OBJECT(data.knopka[FK5]), "clicked",GTK_SIGNAL_FUNC(prov_usl_knopka),&data);
tooltips[FK5]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[FK5],data.knopka[FK5],gettext("Насторойка автоматического выполнения проводок"),NULL);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK5]),(gpointer)FK5);
gtk_widget_show(data.knopka[FK5]);

sprintf(strsql,"%sF5 %s",RFK,gettext("Печать"));
data.knopka[SFK5]=gtk_button_new_with_label(strsql);
gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[SFK5],TRUE,TRUE, 0);
gtk_signal_connect(GTK_OBJECT(data.knopka[SFK5]), "clicked",GTK_SIGNAL_FUNC(prov_usl_knopka),&data);
tooltips[SFK5]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[SFK5],data.knopka[SFK5],gettext("Распечатка проводок"),NULL);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[SFK5]),(gpointer)SFK5);
gtk_widget_show(data.knopka[SFK5]);

sprintf(strsql,"F6 %s",gettext("Проводки"));
data.knopka[FK6]=gtk_button_new_with_label(strsql);
gtk_signal_connect(GTK_OBJECT(data.knopka[FK6]), "clicked",GTK_SIGNAL_FUNC(prov_usl_knopka),&data);
gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[FK6],TRUE,TRUE, 0);
tooltips[FK6]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[FK6],data.knopka[FK6],gettext("Автоматическое выполнение проводок с использованием списка настройки"),NULL);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK6]),(gpointer)FK6);
gtk_widget_show(data.knopka[FK6]);

sprintf(strsql,"F9 %s",gettext("Оплата"));
data.knopka[FK9]=gtk_button_new_with_label(strsql);
gtk_signal_connect(GTK_OBJECT(data.knopka[FK9]), "clicked",GTK_SIGNAL_FUNC(prov_usl_knopka),&data);
gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[FK9],TRUE,TRUE, 0);
tooltips[FK9]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[FK9],data.knopka[FK9],gettext("Переход в режим ввода и корректировки оплат к документу"),NULL);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK9]),(gpointer)FK9);
gtk_widget_show(data.knopka[FK9]);

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

gtk_widget_realize(data.window);
gdk_window_set_cursor(data.window->window,gdk_cursor_new(ICEB_CURSOR));

gtk_widget_grab_focus(data.knopka[FK10]);

prov_usl_create_list(&data);

//gtk_window_maximize(GTK_WINDOW(data.window));
//gtk_window_fullscreen(GTK_WINDOW(data.window));
gtk_widget_show(data.window);


gtk_main();

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


}
コード例 #11
0
ファイル: manpage.c プロジェクト: Jonimoose/tilp
gint display_manpage_dbox()
{
	GladeXML *xml;
	GtkWidget *dbox;
	GtkTextBuffer *txtbuf;
	GtkWidget *text;
	FILE *fd;
	gchar *filename;
	gchar buffer[32768];
	gint len = 0;
	struct stat stbuf;
	gint result;
	PangoFontDescription *font_desc;

	filename = g_strconcat(inst_paths.manpage_dir, "Manpage.txt", NULL);

	if (access(filename, F_OK) == 0) 
	{
		if (stat(filename, &stbuf) != -1) 
		{
			len = stbuf.st_size;
			len -= 2;
		}
		if ((fd = fopen(filename, "r")) != NULL) 
		{
			memset(buffer, 0, sizeof(buffer));
			len = fread(buffer, 1, len, fd);
			fclose(fd);
		}
	}

	xml = glade_xml_new(tilp_paths_build_glade("manpage-2.glade"), "manpage_dbox", PACKAGE);
	if (!xml)
		g_error("GUI loading failed !\n");
	glade_xml_signal_autoconnect(xml);

	dbox = glade_xml_get_widget(xml, "manpage_dbox");
	text = glade_xml_get_widget(xml, "textview1");

	// Change font
	font_desc = pango_font_description_from_string ("Courier");
	gtk_widget_modify_font (text, font_desc);
	pango_font_description_free (font_desc);

	// Set text
	txtbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
	gtk_text_buffer_set_text(txtbuf, buffer, len);

	result = gtk_dialog_run(GTK_DIALOG(dbox));
	switch (result) 
	{
	case GTK_RESPONSE_OK:
		break;
	default:
		break;
	}

	gtk_widget_destroy(dbox);

	return 0;
}
コード例 #12
0
/*
 Creates & runs dialog setting
*/
void
touchatag_applet_setting_dialog_run (touchatag_applet_core_s *touchatag_applet_core)
{
	GtkWidget *dialog;
	GtkWidget *label, *h_box, *v_box;
	GtkWidget *notebook;
	GtkWidget *scrolled_win;
	GtkWidget *v_box_info;
	GtkWidget *h_box_info;
	GtkWidget *separator;

	GtkWidget *button_db_delete_all;
	GtkWidget *button_db_remove_tag;
	GtkWidget *button_db_remove_tag_action;
	GtkWidget *check_save_tag;
	int i;

	/* Create dialog */
	dialog = gtk_dialog_new_with_buttons ("Setting", NULL, GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_OK, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
    gtk_window_set_position (GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
	gtk_window_set_default_size (GTK_WINDOW(dialog), 400, -1);
	gtk_window_set_title (GTK_WINDOW(dialog), " Setting ");
	gtk_dialog_set_has_separator (GTK_DIALOG(dialog), FALSE);
	gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE);

	/* Create notebook */
	notebook = gtk_notebook_new ();
	gtk_notebook_set_scrollable (GTK_NOTEBOOK(notebook), FALSE);
	gtk_widget_set_size_request (notebook, 300, 400);

	/* Create scrolled window */
	scrolled_win = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win), GTK_SHADOW_NONE);

	/* Create info section */
	v_box_info = gtk_vbox_new (FALSE, 0);

		/* Header */
		h_box = gtk_hbox_new (FALSE, 0);	
			label = gtk_label_new ("Devices Info");	
			gtk_widget_modify_font (label, pango_font_description_from_string ("sans center bold 9"));		
			gtk_box_pack_start(GTK_BOX(h_box), label, FALSE, FALSE, 10);		
			gtk_widget_show (label);	
		gtk_box_pack_start(GTK_BOX(v_box_info), h_box, FALSE, FALSE, 15);
		gtk_widget_show (h_box);

		
		h_box_info = gtk_hbox_new (FALSE, 0);
	
			v_box = gtk_vbox_new (FALSE, 0);
	
				for (i = 0; i < touchatag_applet_core->numofdev; i++) {

						/* Reader ID */
						h_box = gtk_hbox_new (FALSE, 0);
							label = touchatag_applet_setting_create_label ("Reader ID:");
							gtk_box_pack_start(GTK_BOX(h_box), label, TRUE, FALSE, 0);
							gtk_widget_show (label);
							label = touchatag_applet_setting_create_label ((char *) touchatag_reader_return_reader_id (&touchatag_applet_core->reader[i]));
							gtk_box_pack_start (GTK_BOX(h_box), label, TRUE, FALSE, 0);
							gtk_widget_show (label);
						gtk_widget_show(h_box);
						gtk_box_pack_start(GTK_BOX(v_box), h_box, FALSE, FALSE, 0);
		
						/* Reader FIRMWARE */
						h_box = gtk_hbox_new (FALSE, 0);
							label = touchatag_applet_setting_create_label ("Firmware:");
							gtk_box_pack_start(GTK_BOX(h_box), label, TRUE, FALSE, 0);
							gtk_widget_show (label);
							label = touchatag_applet_setting_create_label ((char *) touchatag_reader_return_reader_firmware (&touchatag_applet_core->reader[i]));
							gtk_box_pack_start (GTK_BOX(h_box), label, TRUE, FALSE, 0);
							gtk_widget_show (label);
						gtk_widget_show(h_box);
						gtk_box_pack_start(GTK_BOX(v_box), h_box, FALSE, FALSE, 0);

						/* Reader SERIAL SAM */
						h_box = gtk_hbox_new (FALSE, 0);
							label = touchatag_applet_setting_create_label ("Serial number SAM:");
							gtk_box_pack_start(GTK_BOX(h_box), label, TRUE, FALSE, 0);
							gtk_widget_show (label);
							label = touchatag_applet_setting_create_label ((char *) touchatag_reader_return_reader_serial_sam (&touchatag_applet_core->reader[i]));
							gtk_box_pack_start (GTK_BOX(h_box), label, TRUE, FALSE, 0);
							gtk_widget_show (label);
						gtk_widget_show(h_box);
						gtk_box_pack_start(GTK_BOX(v_box), h_box, FALSE, FALSE, 0);

						/* Reader IDENTIFICATION SAM */
						h_box = gtk_hbox_new (FALSE, 0);
							label = touchatag_applet_setting_create_label ("Id. number SAM:");
							gtk_box_pack_start(GTK_BOX(h_box), label, TRUE, FALSE, 0);
							gtk_widget_show (label);
							label = touchatag_applet_setting_create_label ((char *) touchatag_reader_return_reader_identification_sam (&touchatag_applet_core->reader[i]));
							gtk_box_pack_start (GTK_BOX(h_box), label, TRUE, FALSE, 0);
							gtk_widget_show (label);
						gtk_widget_show(h_box);
						gtk_box_pack_start(GTK_BOX(v_box), h_box, FALSE, FALSE, 0);

						/* Reader HANDLER POSITION */
						h_box = gtk_hbox_new (FALSE, 0);
							label = touchatag_applet_setting_create_label ("Handler:");
							gtk_box_pack_start(GTK_BOX(h_box), label, TRUE, FALSE, 0);
							gtk_widget_show (label);
							label = touchatag_applet_setting_create_label (g_strdup_printf("%d", touchatag_applet_core->reader[i].hand));
							gtk_box_pack_start (GTK_BOX(h_box), label, TRUE, FALSE, 0);
							gtk_widget_show (label);
						gtk_widget_show(h_box);
						gtk_box_pack_start(GTK_BOX(v_box), h_box, FALSE, FALSE, 0);	

				
						/* Separator */
						h_box = gtk_hbox_new(FALSE, 0);
							separator = gtk_hseparator_new();
							gtk_widget_set_size_request (separator, 200, 3);
							gtk_box_pack_start(GTK_BOX(h_box), separator, TRUE, FALSE, 2);
							gtk_widget_show (separator);
						gtk_widget_show(h_box);
						gtk_box_pack_start(GTK_BOX(v_box), h_box, FALSE, FALSE, 10);
					}
	
			gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW(scrolled_win), v_box);
			gtk_widget_show (v_box);
	
			gtk_box_pack_start(GTK_BOX(h_box_info), scrolled_win, TRUE, TRUE, 5);
			gtk_widget_show (scrolled_win);
	
			gtk_box_pack_start(GTK_BOX(v_box_info), h_box_info, TRUE, TRUE, 10);
			gtk_widget_show (h_box_info);

 	label = gtk_label_new ("Readers");
	gtk_notebook_append_page (GTK_NOTEBOOK(notebook), v_box_info, label);
	gtk_widget_show (h_box_info);

	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), notebook, FALSE, FALSE, 10);
	gtk_widget_show_all (notebook);	


	/* run the dialog */
	gint result = gtk_dialog_run (GTK_DIALOG (dialog));

	switch (result){
		case GTK_RESPONSE_DELETE_EVENT:
			gtk_widget_destroy (dialog);
			break;
		case GTK_RESPONSE_CANCEL:
			gtk_widget_destroy (dialog);
			break;	
		case GTK_RESPONSE_OK:
			gtk_widget_destroy (dialog);
			break;
	}
	return;
}
コード例 #13
0
static void alertpanel_create(const gchar *title,
			      const gchar *message,
			      AlertType    type,
			      AlertValue   default_value,
			      gboolean	   can_disable,
			      const gchar *button1_label,
			      const gchar *button2_label,
			      const gchar *button3_label)
{
	static PangoFontDescription *font_desc;
	GtkWidget *image;
	GtkWidget *label;
	GtkWidget *hbox;
	GtkWidget *vbox;
	GtkWidget *disable_chkbtn;
	GtkWidget *confirm_area;
	GtkWidget *button1;
	GtkWidget *button2;
	GtkWidget *button3;
	const gchar *label2;
	const gchar *label3;

	debug_print(_("Creating alert panel dialog...\n"));

	dialog = gtk_dialog_new();
	gtk_window_set_title(GTK_WINDOW(dialog), title);
	gtk_window_set_policy(GTK_WINDOW(dialog), FALSE, FALSE, FALSE);
	gtk_window_set_position(GTK_WINDOW(dialog),
				GTK_WIN_POS_CENTER_ON_PARENT);
	gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
	manage_window_set_transient(GTK_WINDOW(dialog));
	gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
	gtk_widget_realize(dialog);
	g_signal_connect(G_OBJECT(dialog), "delete_event",
			 G_CALLBACK(alertpanel_deleted),
			 (gpointer)G_ALERTCANCEL);
	g_signal_connect(G_OBJECT(dialog), "key_press_event",
			 G_CALLBACK(alertpanel_close),
			 (gpointer)G_ALERTCANCEL);
	g_signal_connect(G_OBJECT(dialog), "focus_out_event",
			 G_CALLBACK(alertpanel_focus_out), NULL);

	/* for title icon, label and message */
	hbox = gtk_hbox_new(FALSE, 12);
	gtk_container_set_border_width(GTK_CONTAINER(hbox), 12);
	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
			   hbox, FALSE, FALSE, 0);

	/* title icon */
	switch (type) {
	case ALERT_QUESTION:
		image = gtk_image_new_from_stock
			(GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
		break;
	case ALERT_WARNING:
		image = gtk_image_new_from_stock
			(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
		break;
	case ALERT_ERROR:
		image = gtk_image_new_from_stock
			(GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG);
		break;
	case ALERT_NOTICE:
	default:
		image = gtk_image_new_from_stock
			(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
		break;
	}
	gtk_misc_set_alignment(GTK_MISC(image), 0.5, 0.0);
	gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);

	/* for title and message */
	vbox = gtk_vbox_new(FALSE, 12);
	gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);

	label = gtk_label_new(title);
	gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
	gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
	if (!font_desc) {
		gint size;

		size = pango_font_description_get_size
			(label->style->font_desc);
		font_desc = pango_font_description_new();
		pango_font_description_set_weight
			(font_desc, PANGO_WEIGHT_BOLD);
		pango_font_description_set_size
			(font_desc, size * PANGO_SCALE_LARGE);
	}
	if (font_desc)
		gtk_widget_modify_font(label, font_desc);

	/* message label */
	label = gtk_label_new(message);
	gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
	gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
	gtk_label_set_selectable(GTK_LABEL(label), TRUE);
	GTK_WIDGET_UNSET_FLAGS(label, GTK_CAN_FOCUS);
#ifdef G_OS_WIN32
	{
		GtkStyle *style;
		style = gtk_widget_get_style(dialog);
		gtk_widget_modify_base(label, GTK_STATE_ACTIVE,
				       &style->base[GTK_STATE_SELECTED]);
		gtk_widget_modify_text(label, GTK_STATE_ACTIVE,
				       &style->text[GTK_STATE_SELECTED]);
	}
#endif

	if (can_disable) {
		hbox = gtk_hbox_new(FALSE, 0);
		gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox,
				   FALSE, FALSE, 0);

		disable_chkbtn = gtk_check_button_new_with_label
			(_("Show this message next time"));
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(disable_chkbtn),
					     TRUE);
		gtk_box_pack_start(GTK_BOX(hbox), disable_chkbtn,
				   FALSE, FALSE, 12);
		g_signal_connect(G_OBJECT(disable_chkbtn), "toggled",
				 G_CALLBACK(alertpanel_button_toggled),
				 GUINT_TO_POINTER(G_ALERTDISABLE));
	}

	/* for button(s) */
	if (!button1_label)
		button1_label = GTK_STOCK_OK;
	label2 = button2_label;
	label3 = button3_label;
	if (label2 && *label2 == '+') label2++;
	if (label3 && *label3 == '+') label3++;

	gtkut_stock_button_set_create(&confirm_area,
				      &button1, button1_label,
				      button2_label ? &button2 : NULL, label2,
				      button3_label ? &button3 : NULL, label3);

	gtk_box_pack_end(GTK_BOX(GTK_DIALOG(dialog)->action_area),
			 confirm_area, FALSE, FALSE, 0);
	gtk_container_set_border_width(GTK_CONTAINER(confirm_area), 5);
	gtk_widget_grab_default(button1);
	gtk_widget_grab_focus(button1);
	if (button2_label &&
	    (default_value == G_ALERTALTERNATE || *button2_label == '+')) {
		gtk_widget_grab_default(button2);
		gtk_widget_grab_focus(button2);
	}
	if (button3_label &&
	    (default_value == G_ALERTOTHER || *button3_label == '+')) {
		gtk_widget_grab_default(button3);
		gtk_widget_grab_focus(button3);
	}

	g_signal_connect(G_OBJECT(button1), "clicked",
			 G_CALLBACK(alertpanel_button_clicked),
			 GUINT_TO_POINTER(G_ALERTDEFAULT));
	if (button2_label)
		g_signal_connect(G_OBJECT(button2), "clicked",
				 G_CALLBACK(alertpanel_button_clicked),
				 GUINT_TO_POINTER(G_ALERTALTERNATE));
	if (button3_label)
		g_signal_connect(G_OBJECT(button3), "clicked",
				 G_CALLBACK(alertpanel_button_clicked),
				 GUINT_TO_POINTER(G_ALERTOTHER));

	gtk_widget_show_all(dialog);
}
コード例 #14
0
ファイル: download.c プロジェクト: DeforaOS/Surfer
Download * download_new(DownloadPrefs * prefs, char const * url)
{
    Download * download;
    char * p;
    char buf[256];
    GtkWidget * vbox;
    GtkWidget * hbox;
    GtkSizeGroup * left;
    GtkWidget * widget;
    PangoFontDescription * bold;
    unsigned long id;

    /* verify arguments */
    if(prefs == NULL || url == NULL)
    {
        errno = EINVAL;
        _download_error(NULL, NULL, 1);
        return NULL;
    }
    if((download = malloc(sizeof(*download))) == NULL)
    {
        _download_error(NULL, "malloc", 1);
        return NULL;
    }
    /* initialize structure */
    download->prefs.output = (prefs->output != NULL) ? strdup(prefs->output)
                             : NULL;
    download->prefs.user_agent = (prefs->user_agent != NULL)
                                 ? strdup(prefs->user_agent) : NULL;
    if((p = _ghtml_make_url(NULL, url)) != NULL)
        url = p;
    download->url = strdup(url);
    free(p);
    if(download->url != NULL && prefs->output == NULL)
        download->prefs.output = strdup(basename(download->url));
    download->conn = NULL;
    download->data_received = 0;
    download->content_length = 0;
    download->timeout = 0;
    download->pulse = 0;
    /* verify initialization */
    if((prefs->output != NULL && download->prefs.output == NULL)
            || (prefs->user_agent != NULL
                && download->prefs.user_agent == NULL)
            || download->url == NULL
            || gettimeofday(&download->tv, NULL) != 0)
    {
        _download_error(NULL, "gettimeofday", 1);
        download_delete(download);
        return NULL;
    }
    /* window */
    if(prefs->embedded == 0)
    {
        download->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        snprintf(buf, sizeof(buf), "%s %s", _("Download"),
                 download->url);
#if GTK_CHECK_VERSION(2, 6, 0)
        gtk_window_set_icon_name(GTK_WINDOW(download->window),
                                 "stock_download");
#endif
        gtk_window_set_resizable(GTK_WINDOW(download->window), FALSE);
        gtk_window_set_title(GTK_WINDOW(download->window), buf);
        g_signal_connect_swapped(download->window, "delete-event",
                                 G_CALLBACK(_download_on_closex), download);
    }
    else
    {
        download->window = gtk_plug_new(0);
        g_signal_connect_swapped(download->window, "embedded",
                                 G_CALLBACK(_download_on_embedded), download);
    }
#if GTK_CHECK_VERSION(3, 0, 0)
    vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
#else
    vbox = gtk_vbox_new(FALSE, 2);
#endif
    bold = pango_font_description_new();
    pango_font_description_set_weight(bold, PANGO_WEIGHT_BOLD);
    left = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
    /* address */
#if GTK_CHECK_VERSION(3, 0, 0)
    hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
#else
    hbox = gtk_hbox_new(FALSE, 4);
#endif
    widget = gtk_label_new(_("Address: "));
#if GTK_CHECK_VERSION(3, 0, 0)
    gtk_widget_override_font(widget, bold);
    g_object_set(widget, "halign", GTK_ALIGN_START, NULL);
#else
    gtk_widget_modify_font(widget, bold);
    gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
#endif
    gtk_size_group_add_widget(left, widget);
    gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0);
    download->address = gtk_entry_new();
    gtk_entry_set_text(GTK_ENTRY(download->address), download->url);
    gtk_editable_set_editable(GTK_EDITABLE(download->address), FALSE);
    gtk_box_pack_start(GTK_BOX(hbox), download->address, TRUE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
    /* labels */
    _download_label(vbox, bold, left, _("File: "), &download->filename,
                    download->prefs.output);
    _download_label(vbox, bold, left, _("Status: "), &download->status,
                    _("Resolving..."));
    _download_label(vbox, bold, left, _("Received: "), &download->received,
                    _("0.0 kB"));
    _download_label(vbox, bold, left, _("Remaining: "),
                    &download->remaining, _("Unknown"));
    /* progress bar */
    download->progress = gtk_progress_bar_new();
    gtk_box_pack_start(GTK_BOX(vbox), download->progress, FALSE, FALSE, 0);
    /* checkbox */
    download->check = gtk_check_button_new_with_label(
                          _("Close window when the download is complete"));
    gtk_box_pack_start(GTK_BOX(vbox), download->check, FALSE, FALSE, 0);
    /* button */
#if GTK_CHECK_VERSION(3, 0, 0)
    hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
#else
    hbox = gtk_hbox_new(FALSE, 4);
#endif
    download->cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
    g_signal_connect_swapped(download->cancel, "clicked", G_CALLBACK(
                                 _download_on_cancel), download);
    gtk_box_pack_end(GTK_BOX(hbox), download->cancel, FALSE, TRUE, 0);
    download->browse = gtk_button_new_with_mnemonic("_Open folder");
    gtk_widget_set_no_show_all(download->browse, TRUE);
    widget = gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON);
    gtk_button_set_image(GTK_BUTTON(download->browse), widget);
    g_signal_connect_swapped(download->browse, "clicked", G_CALLBACK(
                                 _download_on_browse), download);
    gtk_box_pack_end(GTK_BOX(hbox), download->browse, FALSE, TRUE, 0);
    gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
    gtk_container_set_border_width(GTK_CONTAINER(download->window), 4);
    gtk_container_add(GTK_CONTAINER(download->window), vbox);
    download->timeout = g_idle_add(_download_on_idle, download);
    _download_refresh(download);
    gtk_widget_show_all(vbox);
    if(prefs->embedded == 0)
        gtk_widget_show(download->window);
    else
    {
        id = gtk_plug_get_id(GTK_PLUG(download->window));
        printf("%lu\n", id);
        fclose(stdout);
    }
    _download_cnt++;
    return download;
}
コード例 #15
0
static GtkWidget*
preview_collection (int font_size,
                    PangoFontDescription *base_desc)
{
    GtkWidget *box;
    GtkWidget *sw;
    GdkColor desktop_color;
    int i;
    GtkWidget *eventbox;

    sw = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
                                    GTK_POLICY_AUTOMATIC,
                                    GTK_POLICY_AUTOMATIC);

    box = gtk_vbox_new (FALSE, 0);
    gtk_box_set_spacing (GTK_BOX (box), 20);
    gtk_container_set_border_width (GTK_CONTAINER (box), 20);

    eventbox = gtk_event_box_new ();
    gtk_container_add (GTK_CONTAINER (eventbox), box);

    gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), eventbox);

    desktop_color.red = 0x5144;
    desktop_color.green = 0x75D6;
    desktop_color.blue = 0xA699;

    gtk_widget_modify_bg (eventbox, GTK_STATE_NORMAL, &desktop_color);

    i = 0;
    while (i < META_FRAME_TYPE_LAST)
    {
        const char *title = NULL;
        GtkWidget *contents;
        GtkWidget *align;
        double xalign, yalign;
        GtkWidget *eventbox2;
        GtkWidget *preview;
        PangoFontDescription *font_desc;
        double scale;

        eventbox2 = gtk_event_box_new ();

        preview = meta_preview_new ();

        gtk_container_add (GTK_CONTAINER (eventbox2), preview);

        meta_preview_set_frame_type (META_PREVIEW (preview), i);
        meta_preview_set_frame_flags (META_PREVIEW (preview),
                                      get_window_flags (i));

        meta_preview_set_theme (META_PREVIEW (preview), global_theme);

        contents = get_window_contents (i, &title);

        meta_preview_set_title (META_PREVIEW (preview), title);

        gtk_container_add (GTK_CONTAINER (preview), contents);

        if (i == META_FRAME_TYPE_MENU)
        {
            xalign = 0.0;
            yalign = 0.0;
        }
        else
        {
            xalign = 0.5;
            yalign = 0.5;
        }

        align = gtk_alignment_new (0.0, 0.0, xalign, yalign);
        gtk_container_add (GTK_CONTAINER (align), eventbox2);

        gtk_box_pack_start (GTK_BOX (box), align, TRUE, TRUE, 0);

        switch (font_size)
        {
        case FONT_SIZE_SMALL:
            scale = PANGO_SCALE_XX_SMALL;
            break;
        case FONT_SIZE_LARGE:
            scale = PANGO_SCALE_XX_LARGE;
            break;
        default:
            scale = 1.0;
            break;
        }

        if (scale != 1.0)
        {
            font_desc = pango_font_description_new ();

            pango_font_description_set_size (font_desc,
                                             MAX (pango_font_description_get_size (base_desc) * scale, 1));

            gtk_widget_modify_font (preview, font_desc);

            pango_font_description_free (font_desc);
        }

        previews[font_size*META_FRAME_TYPE_LAST + i] = preview;

        ++i;
    }

    return sw;
}
コード例 #16
0
ファイル: manpage.c プロジェクト: debrouxl/tilp
gint display_manpage_dbox()
{
	GtkBuilder *builder;
	GError* error = NULL;
	GtkWidget *dbox;
	GtkTextBuffer *txtbuf;
	GtkWidget *text;
	FILE *fd;
	gchar *filename;
	gchar buffer[32768];
	gint len = 0;
	struct stat stbuf;
	gint result;
	PangoFontDescription *font_desc;

	filename = g_strconcat(inst_paths.manpage_dir, "Manpage.txt", NULL);

	if (access(filename, F_OK) == 0) 
	{
		if (stat(filename, &stbuf) != -1) 
		{
			len = stbuf.st_size;
			len -= 2;
		}
		if ((fd = fopen(filename, "r")) != NULL) 
		{
			memset(buffer, 0, sizeof(buffer));
			len = fread(buffer, 1, len, fd);
			fclose(fd);
		}
	}

	builder = gtk_builder_new();
	if (!gtk_builder_add_from_file (builder, tilp_paths_build_builder("manpage.ui"), &error))
	{
		g_warning (_("Couldn't load builder file: %s\n"), error->message);
		g_error_free (error);
		return 0; // THIS RETURNS !
	}
	gtk_builder_connect_signals(builder, NULL);

	dbox = GTK_WIDGET (gtk_builder_get_object (builder, "manpage_dbox"));
	text = GTK_WIDGET (gtk_builder_get_object (builder, "textview1"));

	// Change font
	font_desc = pango_font_description_from_string ("Courier");
	gtk_widget_modify_font (text, font_desc);
	pango_font_description_free (font_desc);

	// Set text
	txtbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
	gtk_text_buffer_set_text(txtbuf, buffer, len);

	result = gtk_dialog_run(GTK_DIALOG(dbox));
	switch (result) 
	{
	case GTK_RESPONSE_OK:
		break;
	default:
		break;
	}

	gtk_widget_destroy(dbox);

	return 0;
}
コード例 #17
0
ファイル: main.c プロジェクト: Cmarone/xlook
int main(
	int argc, 
	char *argv[])
{
	int exit_code= 0;
	
	initialize_globals();
	if(initialize(argc, argv))
	{
		GtkBuilder *builder;
		GError *error= NULL;
		
		gtk_init (&argc, &argv);

		builder = gtk_builder_new ();
#ifdef STATIC_UI
		if(!gtk_builder_add_from_string(builder,  xlook_glade_data, -1, &error))
		{
			if (error != NULL)
			{
				/* Report error to user, and free error */
				fprintf (stderr, "Unable to add from string: %s\n", error->message);
				g_error_free (error);
			}
		}
#else
		gtk_builder_add_from_file (builder, "xlook.glade", NULL);
#endif
		// load the rest of them...
		ui_globals.main_window = (struct GtkWidget *)(gtk_builder_get_object (builder, "mainWindow"));
		ui_globals.command_history = (struct GtkWidget *)(gtk_builder_get_object (builder, "commandWindow"));


		// set the font.
		PangoFontDescription *desc= pango_font_description_from_string("Monospace 9");
		char *names[]= { "textview_FileInfo", "textview_Message"};
		int ii;
		for(ii= 0; ii<ARRAY_SIZE(names); ii++)
		{
			GtkWidget *w = (struct GtkWidget *)(gtk_builder_get_object (builder, names[ii]));
			gtk_widget_modify_font(w, desc);
		}

		setup_command_window(GTK_WINDOW(ui_globals.command_history));

		gtk_builder_connect_signals (builder, NULL);          
		g_object_unref (G_OBJECT (builder));

		// set the messages appropriately
		display_active_window(0);
		display_active_plot(0);
		display_active_file(0);

		gtk_widget_show(GTK_WIDGET(ui_globals.main_window));       
		
		// set the font..
//		GtkWidget *fileInfo= lookup_widget_by_name(ui_globals.main_window, "textview_FileInfo");
//		gtk_widget_modify_font(fileinfo, PangoFontDescription *font_desc);
		
		
		
		// open if we should from command line.
		if(strlen(delayed_file_to_open))
		{
			handle_open_filepath(delayed_file_to_open);
		}

		gtk_main ();
		exit_code= 0;
	} else {
		exit_code= -1;
	}
	
	return exit_code;
}
コード例 #18
0
ファイル: planner-show-view.c プロジェクト: zsyyr/PlannerWin
static GtkWidget *
show_view_create_widget (PlannerShowView *view)
{
	PlannerShowViewPriv  *priv;
	GtkWidget        *pertlayout;
	GtkWidget        *tree;
	GtkWidget        *sw;
	GtkWidget        *frame;
	GtkWidget        *layout;
	GtkWidget        *vpaned;
	GtkAdjustment    *hadj, *vadj;
	GtkTreeModel     *model;
	MrpTaskManager   *task_manager;
	GtkLabel         *label;
	GtkEntry         *entry;
	GtkButton        *button;
	GtkWidget        *hbox,*vbox,*vbox2;
	GtkWidget		   *progressbar;

	GtkWidget *randomtogglebutton;
	GtkWidget *deleteresourcetogglebutton;
	GtkWidget *ganttcharttogglebutton;
	GtkWidget *manulsettogglebutton;
	GtkWidget *table;

	MrpProject *project;
	GtkTreeSelection *selection;
	GList *task_list;

	project = planner_window_get_project (PLANNER_VIEW (view)->main_window);

	task_manager = imrp_project_get_task_manager(project);
	priv = view->priv;

	g_signal_connect (project,
			  "loaded",
			  G_CALLBACK (show_view_project_loaded_cb),
			  view);

	model = GTK_TREE_MODEL (planner_gantt_model_new (project));

	tree = planner_task_tree_new (PLANNER_VIEW (view)->main_window,
				      PLANNER_GANTT_MODEL (model),
				      FALSE,
				      TRUE,

				      COL_WBS, _("WBS"),
				      COL_NAME, _("Name"),
				      COL_START, _("Start"),
				      COL_FINISH, _("Finish"),
				      COL_WORK, _("Work"),
				      COL_DURATION, _("Duration"),
				      COL_SLACK, _("Slack"),
				      COL_COST, _("Cost"),
				      COL_ASSIGNED_TO, _("Assigned to"),

				      COL_COMPLETE, _("% Complete"),
				      -1);
	priv->tree = tree;


	priv->gantt = planner_gantt_chart_new_with_model (model);
	g_object_set (priv->gantt,
				  "header_height", 50,
			      NULL);
	planner_gantt_chart_set_view (PLANNER_GANTT_CHART (priv->gantt),
				      PLANNER_TASK_TREE (tree));

	//*********************
	//events sensitive on gantt widget
	gtk_widget_set_events (GTK_WIDGET (priv->gantt), GDK_SCROLL_MASK);

	g_signal_connect (priv->gantt, "scroll-event",
                    G_CALLBACK (show_view_chart_scroll_event), view);

	g_object_unref (model);

	g_signal_connect (priv->gantt,
			  "status_updated",
			  G_CALLBACK (show_view_gantt_status_updated_cb),
			  view);

	g_signal_connect (priv->gantt,
			  "resource_clicked",
			  G_CALLBACK (show_view_gantt_resource_clicked_cb),
			  view);

	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
	gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);

	//g_signal_connect (tree,
			  //"style_set",
			  //G_CALLBACK (show_view_tree_style_set_cb),
			  //view);

	//*********************
	//interface design
	//GtkVPaned
	//  GtkFrame -> GtkScrollWindow ->GtkLayout (pert view showed here)A
	//  GtkHBox
	//    GtkVBox -> GtkHBox (show run-in-time data showed here)B
	//                 GtkLabel
	//                 GtkEntry
	//    GtkScrollWindow  (gantt view showed here)C

	//interface design in A
	//GtkScrollWindow, let its scrollbar displayed if needed, put the pert view inside
	layout = gtk_layout_new(NULL,NULL);
	priv->pertlayout = layout;

	sw = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
					GTK_POLICY_ALWAYS, GTK_POLICY_AUTOMATIC);
	gtk_container_add (GTK_CONTAINER (sw),
			        priv->pertlayout);

	//GtkFrame, put the GtkScrollWindow in the GtkFrame
	frame = gtk_frame_new (NULL);
	gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
	gtk_container_add (GTK_CONTAINER (frame), sw);

	//GtkVPaned, add the GtkFrame in the GtkVPaned
	vpaned = gtk_vpaned_new ();
	gtk_paned_add1 (GTK_PANED (vpaned), frame);

	//interface design in B
    //GtkVBox, holds labels and entry and buttons
    vbox = gtk_vbox_new(FALSE, 0);
    vbox2 = gtk_vbox_new(FALSE,0);
    progressbar = gtk_progress_bar_new();
	//GtkLabel, "The Current Task Is: "
    label = gtk_label_new("当前执行审计任务: ");
    gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (label), FALSE, FALSE, 0);

    //GtkEntry, holds task name
    entry = gtk_entry_new();
    gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (entry), FALSE, FALSE, 0);
    priv->currenttaskentry = entry;

    //GtkLabel, "The Current Delay Is:: "
    label = gtk_label_new("当前审计延迟时间: ");
    gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (label), FALSE, FALSE, 0);

    //GtkEntry, holds task delay
    entry = gtk_entry_new();
    gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (entry), FALSE, FALSE, 0);
    priv->currentdelayentry = entry;

    //GtkLabel, "The Current duration is "
    label = gtk_label_new("当前审计总时间: ");
    gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (label), FALSE, FALSE, 0);

    //GtkEntry, holds total duration
    entry = gtk_entry_new();
    gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (entry), FALSE, FALSE, 0);
    priv->currentdurationentry = entry;

    //GtkLabel, "The Duration has changed :: "
    label = gtk_label_new("延迟后审计总时间: ");
    gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (label), FALSE, FALSE, 0);

    //GtkEntry, The Duration has changed to
    entry = gtk_entry_new();
    gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (entry), FALSE, FALSE, 0);
    priv->lastdurationentry = entry;

    lastdurationentry = entry;

	//GtkLabel, "delete resource"
	label = gtk_label_new("调整的审计人员: ");
	gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (label), FALSE, FALSE, 0);

	//GtkEntry, delete resource
	entry = gtk_entry_new();
	gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (entry), FALSE, FALSE, 0);
	priv->deleteresourceentry = entry;



	GtkWidget *labelChild;
	PangoFontDescription *font1;
	short fontSize = 8;


    //GtkButton, delete resource
    button = gtk_button_new_with_label("重大事项显示");
    GdkColor color;
       color.red = 50000;
       color.green = 20000;
       color.blue = 15000;
       gtk_widget_modify_bg(button, GTK_STATE_INSENSITIVE, &color);

      // font1 = pango_font_description_from_string("Sans");//"Sans"字体名
       //pango_font_description_set_size(font1, fontSize * PANGO_SCALE);//设置字体大小
      // labelChild = gtk_bin_get_child(GTK_BIN(button));//取出GtkButton里的label
       gtk_widget_modify_font(GTK_WIDGET(labelChild), font1);//设置label的字体, 这样这个GtkButton上面显示的字体就变了

    gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (button),	FALSE,FALSE, 0);
    g_signal_connect (button,
       			  "clicked",
       			  G_CALLBACK (show_view_delete_resource_cb),
       			 view);
    priv->deleteresourcebutton = button;

    //total duration display
	button = gtk_button_new_with_label("审计总时间无延迟");
	GdkColor color1;
	color1.red = 50000;
	color1.green = 20000;
	color1.blue = 15000;
	gtk_widget_modify_bg(button, GTK_STATE_INSENSITIVE, &color1);

	 // font1 = pango_font_description_from_string("Sans");//"Sans"字体名
	     //  pango_font_description_set_size(font1, fontSize * PANGO_SCALE);//设置字体大小
	     //  labelChild = gtk_bin_get_child(GTK_BIN(button));//取出GtkButton里的label
	       gtk_widget_modify_font(GTK_WIDGET(labelChild), font1);//设置label的字体, 这样这个GtkButton上面显示的字体就变了
	gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (button), FALSE,FALSE, 0);
	g_signal_connect(button, "clicked",
			G_CALLBACK (show_view_delete_resource_cb), view);
	priv->displaytotaldurationbutton = button;

    //GtkButton, go to next task
    button = gtk_button_new_with_label("执行下一审计任务");
    GdkColor color2;
    color2.red = 50000;
    color2.green = 10000;
    color2.blue = 10000;
    gtk_widget_modify_bg(button, GTK_STATE_INSENSITIVE, &color2);

   // font1 = pango_font_description_from_string("Sans");//"Sans"字体名
        // pango_font_description_set_size(font1, fontSize * PANGO_SCALE);//设置字体大小
        // labelChild = gtk_bin_get_child(GTK_BIN(button));//取出GtkButton里的label
         gtk_widget_modify_font(GTK_WIDGET(labelChild), font1);//设置label的字体, 这样这个GtkButton上面显示的字体就变了
    gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (button), FALSE,FALSE, 0);
    g_signal_connect (button,
    			  "clicked",
    			  G_CALLBACK (show_view_next_task_cb),
    			 view);
    priv->nextstepbutton = button;


    table = gtk_table_new(2, 2, FALSE);
    manulsettogglebutton = gtk_toggle_button_new_with_label("手动设置审计任务延迟");
    gtk_widget_set_size_request(manulsettogglebutton,5,7);



    font1 = pango_font_description_from_string("Sans");//"Sans"字体名
    pango_font_description_set_size(font1, fontSize * PANGO_SCALE);//设置字体大小
    labelChild = gtk_bin_get_child(GTK_BIN( manulsettogglebutton));//取出GtkButton里的label
    gtk_widget_modify_font(GTK_WIDGET(labelChild), font1);//设置label的字体, 这样这个GtkButton上面显示的字体就变了






    randomtogglebutton = gtk_toggle_button_new_with_label("随机设置审计任务延迟");

    font1 = pango_font_description_from_string("Sans");//"Sans"字体名
       pango_font_description_set_size(font1, fontSize * PANGO_SCALE);//设置字体大小
       labelChild = gtk_bin_get_child(GTK_BIN( randomtogglebutton));//取出GtkButton里的label
       gtk_widget_modify_font(GTK_WIDGET(labelChild), font1);//设置label的字体, 这样这个GtkButton上面显示的字体就变了

    deleteresourcetogglebutton = gtk_toggle_button_new_with_label("参审人员随机调整");
    font1 = pango_font_description_from_string("Sans");//"Sans"字体名
       pango_font_description_set_size(font1, fontSize * PANGO_SCALE);//设置字体大小
       labelChild = gtk_bin_get_child(GTK_BIN(  deleteresourcetogglebutton));//取出GtkButton里的label
       gtk_widget_modify_font(GTK_WIDGET(labelChild), font1);//设置label的字体, 这样这个GtkButton上面显示的字体就变了

    ganttcharttogglebutton = gtk_toggle_button_new_with_label("干特图路径选择");
    font1 = pango_font_description_from_string("Sans");//"Sans"字体名
       pango_font_description_set_size(font1, fontSize * PANGO_SCALE);//设置字体大小
       labelChild = gtk_bin_get_child(GTK_BIN( ganttcharttogglebutton));//取出GtkButton里的label
       gtk_widget_modify_font(GTK_WIDGET(labelChild), font1);//设置label的字体, 这样这个GtkButton上面显示的字体就变了


	gtk_table_set_row_spacings(GTK_TABLE(table), 2);
	gtk_table_set_col_spacings(GTK_TABLE(table), 2);
	gtk_table_attach_defaults(GTK_TABLE(table), manulsettogglebutton, 0, 1, 0,1);
	gtk_table_attach_defaults(GTK_TABLE(table), randomtogglebutton, 0, 1, 1, 2);
	gtk_table_attach_defaults(GTK_TABLE(table), deleteresourcetogglebutton, 1,
			2, 0, 1);
	gtk_table_attach_defaults(GTK_TABLE(table), ganttcharttogglebutton, 1, 2, 1,
			2);
	gtk_signal_connect(GTK_OBJECT(randomtogglebutton), "toggle",
				GTK_SIGNAL_FUNC(select_random_task), view);
	gtk_signal_connect(GTK_OBJECT(deleteresourcetogglebutton), "toggle",
			GTK_SIGNAL_FUNC(select_deleteresource), view);
	priv->manulsettogglebutton = manulsettogglebutton;
	priv->randomtogglebutton = randomtogglebutton;
	priv->deleteresourcetogglebutton = deleteresourcetogglebutton;
	priv->ganttcharttogglebutton = ganttcharttogglebutton;
	//gtk_table_attach_defaults(GTK_TABLE(table), labelprobability,1,2,2,3);
//   		   gtk_table_attach_defaults(GTK_TABLE(table), togglebutton,0,2,3,4);
	gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET (table), FALSE, FALSE, 0);
	//GtkButton, auto optimization
	button = gtk_button_new_with_label("Auto Optimization");



    sw = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
					GTK_POLICY_ALWAYS, GTK_POLICY_AUTOMATIC);
	gtk_container_add (GTK_CONTAINER (sw),
				    priv->gantt);
	gtk_box_pack_start(GTK_BOX (vbox2), GTK_WIDGET (sw), TRUE, TRUE,0);
	gtk_widget_set_size_request(progressbar,150,36);
	gtk_box_pack_start(GTK_BOX (vbox2), GTK_WIDGET (progressbar), FALSE, FALSE, 0);
	priv->progressbar = progressbar;
	//put the GtkHBox in the GtkFrame, put the GtkVBox and GtkScrollWindow in the GtkHBox
	hbox = gtk_hbox_new(FALSE, 0);
   gtk_box_pack_start(GTK_BOX (hbox), GTK_WIDGET (vbox), FALSE,TRUE, 0);
	gtk_box_pack_end(GTK_BOX (hbox), GTK_WIDGET (vbox2), TRUE, TRUE, 10);

	frame = gtk_frame_new (NULL);
	gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
	gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (hbox));

	//add the GtkFrame in the GtkVPaned
	gtk_paned_add2 (GTK_PANED (vpaned), frame);

	gtk_paned_set_position (GTK_PANED (vpaned), 250);

	g_signal_connect (tree,
			  "row_expanded",
			  G_CALLBACK (show_view_row_expanded),
			  priv->gantt);

	g_signal_connect (tree,
			  "row_collapsed",
			  G_CALLBACK (show_view_row_collapsed),
			  priv->gantt);

	gtk_tree_view_expand_all (GTK_TREE_VIEW (tree));





	return vpaned;

}
コード例 #19
0
ファイル: cvs.c プロジェクト: khorben/DeforaOS
static CVS * _cvs_init(BrowserPluginHelper * helper)
{
	CVS * cvs;
	PangoFontDescription * font;
	GtkSizeGroup * group;
	GtkSizeGroup * bgroup;
	GtkWidget * widget;

	if((cvs = object_new(sizeof(*cvs))) == NULL)
		return NULL;
	cvs->helper = helper;
	cvs->filename = NULL;
	cvs->source = 0;
	/* widgets */
	cvs->widget = gtk_vbox_new(FALSE, 4);
	font = pango_font_description_new();
	pango_font_description_set_weight(font, PANGO_WEIGHT_BOLD);
	group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
	bgroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
	/* label */
	cvs->name = gtk_label_new("");
	gtk_label_set_ellipsize(GTK_LABEL(cvs->name), PANGO_ELLIPSIZE_MIDDLE);
	gtk_misc_set_alignment(GTK_MISC(cvs->name), 0.0, 0.0);
	gtk_widget_modify_font(cvs->name, font);
	gtk_box_pack_start(GTK_BOX(cvs->widget), cvs->name, FALSE, TRUE, 0);
	cvs->status = gtk_label_new("");
	gtk_label_set_ellipsize(GTK_LABEL(cvs->status), PANGO_ELLIPSIZE_END);
	gtk_misc_set_alignment(GTK_MISC(cvs->status), 0.0, 0.0);
	gtk_box_pack_start(GTK_BOX(cvs->widget), cvs->status, FALSE, TRUE, 0);
	/* directory */
	cvs->directory = gtk_vbox_new(FALSE, 4);
	widget = _init_label(group, _("Root:"), &cvs->d_root);
	gtk_box_pack_start(GTK_BOX(cvs->directory), widget, FALSE, TRUE, 0);
	widget = _init_label(group, _("Repository:"), &cvs->d_repository);
	gtk_box_pack_start(GTK_BOX(cvs->directory), widget, FALSE, TRUE, 0);
	widget = _init_label(group, _("Tag:"), &cvs->d_tag);
	gtk_box_pack_start(GTK_BOX(cvs->directory), widget, FALSE, TRUE, 0);
	widget = _init_button(bgroup, GTK_STOCK_INDEX, _("Request diff"),
			G_CALLBACK(_cvs_on_diff), cvs);
	gtk_box_pack_start(GTK_BOX(cvs->directory), widget, FALSE, TRUE, 0);
	widget = _init_button(bgroup, GTK_STOCK_INDEX, _("Annotate"),
			G_CALLBACK(_cvs_on_annotate), cvs);
	gtk_box_pack_start(GTK_BOX(cvs->directory), widget, FALSE, TRUE, 0);
	widget = _init_button(bgroup, GTK_STOCK_INDEX, _("View log"),
			G_CALLBACK(_cvs_on_log), cvs);
	gtk_box_pack_start(GTK_BOX(cvs->directory), widget, FALSE, TRUE, 0);
	widget = _init_button(bgroup, GTK_STOCK_REFRESH, _("Update"),
			G_CALLBACK(_cvs_on_update), cvs);
	gtk_box_pack_start(GTK_BOX(cvs->directory), widget, FALSE, TRUE, 0);
	widget = _init_button(bgroup, GTK_STOCK_JUMP_TO, _("Commit"),
			G_CALLBACK(_cvs_on_commit), cvs);
	gtk_box_pack_start(GTK_BOX(cvs->directory), widget, FALSE, TRUE, 0);
	gtk_widget_show_all(cvs->directory);
	gtk_widget_set_no_show_all(cvs->directory, TRUE);
	gtk_box_pack_start(GTK_BOX(cvs->widget), cvs->directory, FALSE, TRUE,
			0);
	/* file */
	cvs->file = gtk_vbox_new(FALSE, 4);
	widget = _init_label(group, _("Revision:"), &cvs->f_revision);
	gtk_box_pack_start(GTK_BOX(cvs->file), widget, FALSE, TRUE, 0);
	widget = _init_button(bgroup, GTK_STOCK_INDEX, _("Request diff"),
			G_CALLBACK(_cvs_on_diff), cvs);
	gtk_box_pack_start(GTK_BOX(cvs->file), widget, FALSE, TRUE, 0);
	widget = _init_button(bgroup, GTK_STOCK_INDEX, _("Annotate"),
			G_CALLBACK(_cvs_on_annotate), cvs);
	gtk_box_pack_start(GTK_BOX(cvs->file), widget, FALSE, TRUE, 0);
	widget = _init_button(bgroup, GTK_STOCK_INDEX, _("View log"),
			G_CALLBACK(_cvs_on_log), cvs);
	gtk_box_pack_start(GTK_BOX(cvs->file), widget, FALSE, TRUE, 0);
	widget = _init_button(bgroup, GTK_STOCK_REFRESH, _("Update"),
			G_CALLBACK(_cvs_on_update), cvs);
	gtk_box_pack_start(GTK_BOX(cvs->file), widget, FALSE, TRUE, 0);
	widget = _init_button(bgroup, GTK_STOCK_JUMP_TO, _("Commit"),
			G_CALLBACK(_cvs_on_commit), cvs);
	gtk_box_pack_start(GTK_BOX(cvs->file), widget, FALSE, TRUE, 0);
	gtk_widget_show_all(cvs->file);
	gtk_widget_set_no_show_all(cvs->file, TRUE);
	gtk_box_pack_start(GTK_BOX(cvs->widget), cvs->file, FALSE, TRUE, 0);
	/* additional actions */
	cvs->add = _init_button(bgroup, GTK_STOCK_ADD, _("Add to repository"),
			G_CALLBACK(_cvs_on_add), cvs);
	gtk_box_pack_start(GTK_BOX(cvs->widget), cvs->add, FALSE, TRUE, 0);
	cvs->make = _init_button(bgroup, GTK_STOCK_EXECUTE, _("Run make"),
			G_CALLBACK(_cvs_on_make), cvs);
	gtk_box_pack_start(GTK_BOX(cvs->widget), cvs->make, FALSE, TRUE, 0);
	gtk_widget_show_all(cvs->widget);
	pango_font_description_free(font);
	/* tasks */
	cvs->tasks = NULL;
	cvs->tasks_cnt = 0;
	return cvs;
}
コード例 #20
0
ファイル: interface.c プロジェクト: BackupTheBerlios/hocr-svn
GtkWidget *
create_window1 (void)
{
	GtkWidget *vbox1;

	/* menu */
	GtkWidget *menubar1;
	GtkWidget *menuitem1;
	GtkWidget *menuitem1_menu;
	GtkWidget *open;
	GtkWidget *apply;
	GtkWidget *save;
	GtkWidget *separatormenuitem1;
	GtkWidget *save_picture;
	GtkWidget *save_picture_image;
	GtkWidget *xsane;
	GtkWidget *separatormenuitem2;
	GtkWidget *quit;
	GtkWidget *menuitem2;
	GtkWidget *menuitem2_menu;
	GtkWidget *font;
	GtkWidget *separator2;
	GtkWidget *spell_check;
	GtkWidget *separator3;
	GtkWidget *menuitem3;
	GtkWidget *menuitem3_menu;
	GtkWidget *zoom_in;
	GtkWidget *zoom_out;
	GtkWidget *normal_size;
	GtkWidget *menuitem4;
	GtkWidget *menuitem4_menu;
	GtkWidget *about;
	GtkAccelGroup *accel_group;

	/* toolbar */
	GtkWidget *toolbar;
	GtkIconSize tmp_toolbar_icon_size;
	GtkWidget *toolbutton_open;
	GtkWidget *toolbutton_apply;
	GtkWidget *toolbutton_save;
	GtkWidget *toolitem1;
	GtkWidget *vseparator1;
	GtkWidget *toolbutton_spell;
	GtkWidget *toolitem2;
	GtkWidget *vseparator2;
	GtkWidget *toolbutton_zoom_in;
	GtkWidget *toolbutton_zoom_out;
	GtkWidget *toolbutton_zoom_fit;

	/* image */
	GtkWidget *vpaned1;
	GtkWidget *scrolledwindow_image;

	/* text */
	GtkTooltips *tooltips;

	PangoFontDescription *font_desc;

	tooltips = gtk_tooltips_new ();
	accel_group = gtk_accel_group_new ();

	window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_widget_set_size_request (window1, 600, 300);
	gtk_window_maximize (GTK_WINDOW (window1));
	gtk_window_set_title (GTK_WINDOW (window1), _("hocr-gtk"));

	vbox1 = gtk_vbox_new (FALSE, 0);
	gtk_widget_show (vbox1);
	gtk_container_add (GTK_CONTAINER (window1), vbox1);

	/* menu */

	menubar1 = gtk_menu_bar_new ();
	gtk_widget_show (menubar1);
	gtk_box_pack_start (GTK_BOX (vbox1), menubar1, FALSE, FALSE, 0);

	menuitem1 = gtk_menu_item_new_with_mnemonic (_("_File"));
	gtk_widget_show (menuitem1);
	gtk_container_add (GTK_CONTAINER (menubar1), menuitem1);

	menuitem1_menu = gtk_menu_new ();
	gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem1), menuitem1_menu);

	open = gtk_image_menu_item_new_from_stock ("gtk-open", accel_group);
	gtk_widget_show (open);
	gtk_container_add (GTK_CONTAINER (menuitem1_menu), open);

	apply = gtk_image_menu_item_new_from_stock ("gtk-apply", accel_group);
	gtk_widget_show (apply);
	gtk_container_add (GTK_CONTAINER (menuitem1_menu), apply);

	save = gtk_image_menu_item_new_from_stock ("gtk-save", accel_group);
	gtk_widget_show (save);
	gtk_container_add (GTK_CONTAINER (menuitem1_menu), save);

	separatormenuitem1 = gtk_separator_menu_item_new ();
	gtk_widget_show (separatormenuitem1);
	gtk_container_add (GTK_CONTAINER (menuitem1_menu), separatormenuitem1);
	gtk_widget_set_sensitive (separatormenuitem1, FALSE);

	save_picture = gtk_image_menu_item_new_with_label (_("Save Picture"));
	save_picture_image =
		gtk_image_new_from_stock ("gtk-save", GTK_ICON_SIZE_MENU);
	gtk_widget_show (save_picture_image);
	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (save_picture),
				       save_picture_image);
	gtk_widget_show (save_picture);
	gtk_container_add (GTK_CONTAINER (menuitem1_menu), save_picture);

	xsane = gtk_menu_item_new_with_label (_("Xsane"));
	gtk_widget_show (xsane);
	gtk_container_add (GTK_CONTAINER (menuitem1_menu), xsane);
	
	separatormenuitem2 = gtk_separator_menu_item_new ();
	gtk_widget_show (separatormenuitem2);
	gtk_container_add (GTK_CONTAINER (menuitem1_menu), separatormenuitem2);
	gtk_widget_set_sensitive (separatormenuitem2, FALSE);

	quit = gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group);
	gtk_widget_show (quit);
	gtk_container_add (GTK_CONTAINER (menuitem1_menu), quit);

	menuitem2 = gtk_menu_item_new_with_mnemonic (_("_Edit"));
	gtk_widget_show (menuitem2);
	gtk_container_add (GTK_CONTAINER (menubar1), menuitem2);

	menuitem2_menu = gtk_menu_new ();
	gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem2), menuitem2_menu);

	font = gtk_image_menu_item_new_from_stock ("gtk-select-font",
						   accel_group);
	gtk_widget_show (font);
	gtk_container_add (GTK_CONTAINER (menuitem2_menu), font);

	separator2 = gtk_separator_menu_item_new ();
	gtk_widget_show (separator2);
	gtk_container_add (GTK_CONTAINER (menuitem2_menu), separator2);
	gtk_widget_set_sensitive (separator2, FALSE);

#ifdef WITH_GTKSPELL
	spell_check =
		gtk_image_menu_item_new_from_stock ("gtk-spell-check",
						    accel_group);
	gtk_widget_show (spell_check);
	gtk_container_add (GTK_CONTAINER (menuitem2_menu), spell_check);

	separator3 = gtk_separator_menu_item_new ();
	gtk_widget_show (separator3);
	gtk_container_add (GTK_CONTAINER (menuitem2_menu), separator3);
	gtk_widget_set_sensitive (separator3, FALSE);
#endif

	color_text_box =
		gtk_check_menu_item_new_with_mnemonic (_("Color boxes"));
	gtk_widget_show (color_text_box);
	gtk_container_add (GTK_CONTAINER (menuitem2_menu), color_text_box);
	gtk_tooltips_set_tip (tooltips, color_text_box, _("Color text boxes"),
			      NULL);
	gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (color_text_box),
					TRUE);

	color_misread =
		gtk_check_menu_item_new_with_mnemonic (_("Color misread"));
	gtk_widget_show (color_misread);
	gtk_container_add (GTK_CONTAINER (menuitem2_menu), color_misread);
	gtk_tooltips_set_tip (tooltips, color_misread, _("Color misread fonts"),
			      NULL);
	gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (color_misread),
					TRUE);

	clear_text = gtk_check_menu_item_new_with_mnemonic (_("Clear"));
	gtk_widget_show (clear_text);
	gtk_container_add (GTK_CONTAINER (menuitem2_menu), clear_text);
	gtk_tooltips_set_tip (tooltips, clear_text,
			      _("Clear text each time you ocr new scan"), NULL);
	gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (clear_text), TRUE);

	ocr = gtk_check_menu_item_new_with_mnemonic (_("Ocr"));
	gtk_widget_show (ocr);
	gtk_container_add (GTK_CONTAINER (menuitem2_menu), ocr);
	gtk_tooltips_set_tip (tooltips, ocr,
			      _("Try to recognize fonts in scaned text"), NULL);
	gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (ocr), TRUE);

	use_dict = gtk_check_menu_item_new_with_mnemonic (_("Use dictionary"));
	gtk_widget_show (use_dict);
	gtk_container_add (GTK_CONTAINER (menuitem2_menu), use_dict);
	gtk_tooltips_set_tip (tooltips, use_dict,
			      _
			      ("Try to guess unrecognized fonts in scaned text using internal dictionary"),
			      NULL);
	gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (use_dict), FALSE);

	use_nikud = gtk_check_menu_item_new_with_mnemonic (_("Use nikud"));
	gtk_widget_show (use_nikud);
	gtk_container_add (GTK_CONTAINER (menuitem2_menu), use_nikud);
	gtk_tooltips_set_tip (tooltips, use_nikud,
			      _("Try to guess nikud"), NULL);
	gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (use_nikud), TRUE);

	use_spaces = gtk_check_menu_item_new_with_mnemonic (_("Use spaces"));
	gtk_widget_show (use_spaces);
	gtk_container_add (GTK_CONTAINER (menuitem2_menu), use_spaces);
	gtk_tooltips_set_tip (tooltips, use_spaces,
			      _("Use spaces for tabs"), NULL);
	gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (use_spaces),
					FALSE);

	use_indent =
		gtk_check_menu_item_new_with_mnemonic (_("Use indentation"));
	gtk_widget_show (use_indent);
	gtk_container_add (GTK_CONTAINER (menuitem2_menu), use_indent);
	gtk_tooltips_set_tip (tooltips, use_indent,
			      _("Try to guess line indentation"), NULL);
	gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (use_indent),
					FALSE);

	menuitem3 = gtk_menu_item_new_with_mnemonic (_("_View"));
	gtk_widget_show (menuitem3);
	gtk_container_add (GTK_CONTAINER (menubar1), menuitem3);

	menuitem3_menu = gtk_menu_new ();
	gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem3), menuitem3_menu);

	zoom_in =
		gtk_image_menu_item_new_from_stock ("gtk-zoom-in", accel_group);
	gtk_widget_show (zoom_in);
	gtk_container_add (GTK_CONTAINER (menuitem3_menu), zoom_in);

	zoom_out =
		gtk_image_menu_item_new_from_stock ("gtk-zoom-out",
						    accel_group);
	gtk_widget_show (zoom_out);
	gtk_container_add (GTK_CONTAINER (menuitem3_menu), zoom_out);

	normal_size =
		gtk_image_menu_item_new_from_stock ("gtk-zoom-100",
						    accel_group);
	gtk_widget_show (normal_size);
	gtk_container_add (GTK_CONTAINER (menuitem3_menu), normal_size);

	menuitem4 = gtk_menu_item_new_with_mnemonic (_("_Help"));
	gtk_widget_show (menuitem4);
	gtk_container_add (GTK_CONTAINER (menubar1), menuitem4);

	menuitem4_menu = gtk_menu_new ();
	gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem4), menuitem4_menu);

	about = gtk_menu_item_new_with_mnemonic (_("_About"));
	gtk_widget_show (about);
	gtk_container_add (GTK_CONTAINER (menuitem4_menu), about);

	/* toolbar */
	toolbar = gtk_toolbar_new ();
	gtk_widget_show (toolbar);
	gtk_box_pack_start (GTK_BOX (vbox1), toolbar, FALSE, FALSE, 0);
	gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH);
	tmp_toolbar_icon_size =
		gtk_toolbar_get_icon_size (GTK_TOOLBAR (toolbar));

	toolbutton_open =
		(GtkWidget *) gtk_tool_button_new_from_stock ("gtk-open");
	gtk_widget_show (toolbutton_open);
	gtk_container_add (GTK_CONTAINER (toolbar), toolbutton_open);
	gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (toolbutton_open), tooltips,
				   _("Open a new picture for the OCR"), NULL);

	toolbutton_apply =
		(GtkWidget *) gtk_tool_button_new_from_stock ("gtk-apply");
	gtk_widget_show (toolbutton_apply);
	gtk_container_add (GTK_CONTAINER (toolbar), toolbutton_apply);
	gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (toolbutton_apply), tooltips,
				   _("Convert picture to text"), NULL);

	toolbutton_save =
		(GtkWidget *) gtk_tool_button_new_from_stock ("gtk-save");
	gtk_widget_show (toolbutton_save);
	gtk_container_add (GTK_CONTAINER (toolbar), toolbutton_save);
	gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (toolbutton_save), tooltips,
				   _("Save the text created by the OCR"), NULL);

	toolitem1 = (GtkWidget *) gtk_tool_item_new ();
	gtk_widget_show (toolitem1);
	gtk_container_add (GTK_CONTAINER (toolbar), toolitem1);
	vseparator1 = gtk_vseparator_new ();
	gtk_widget_show (vseparator1);
	gtk_container_add (GTK_CONTAINER (toolitem1), vseparator1);

#ifdef WITH_GTKSPELL
	toolbutton_spell =
		(GtkWidget *)
		gtk_tool_button_new_from_stock ("gtk-spell-check");
	gtk_widget_show (toolbutton_spell);
	gtk_container_add (GTK_CONTAINER (toolbar), toolbutton_spell);
	gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (toolbutton_spell), tooltips,
				   _("Spell check the text"), NULL);

	toolitem2 = (GtkWidget *) gtk_tool_item_new ();
	gtk_widget_show (toolitem2);
	gtk_container_add (GTK_CONTAINER (toolbar), toolitem2);
	vseparator2 = gtk_vseparator_new ();
	gtk_widget_show (vseparator2);
	gtk_container_add (GTK_CONTAINER (toolitem2), vseparator2);
#endif

	toolbutton_zoom_in =
		(GtkWidget *) gtk_tool_button_new_from_stock ("gtk-zoom-in");
	gtk_widget_show (toolbutton_zoom_in);
	gtk_container_add (GTK_CONTAINER (toolbar), toolbutton_zoom_in);

	toolbutton_zoom_out =
		(GtkWidget *) gtk_tool_button_new_from_stock ("gtk-zoom-out");
	gtk_widget_show (toolbutton_zoom_out);
	gtk_container_add (GTK_CONTAINER (toolbar), toolbutton_zoom_out);

	toolbutton_zoom_fit =
		(GtkWidget *) gtk_tool_button_new_from_stock ("gtk-zoom-fit");
	gtk_widget_show (toolbutton_zoom_fit);
	gtk_container_add (GTK_CONTAINER (toolbar), toolbutton_zoom_fit);

	/* image */
	vpaned1 = gtk_vpaned_new ();
	gtk_widget_show (vpaned1);
	gtk_container_add (GTK_CONTAINER (vbox1), vpaned1);

	scrolledwindow_image = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy ((GtkScrolledWindow *)
					scrolledwindow_image,
					GTK_POLICY_AUTOMATIC,
					GTK_POLICY_AUTOMATIC);
	gtk_widget_show (scrolledwindow_image);
	gtk_container_add (GTK_CONTAINER (vpaned1), scrolledwindow_image);

	viewport1 = gtk_viewport_new (NULL, NULL);
	gtk_widget_show (viewport1);
	gtk_container_add (GTK_CONTAINER (scrolledwindow_image), viewport1);

	image = gtk_image_new ();
	gtk_widget_show (image);
	gtk_container_add (GTK_CONTAINER (viewport1), image);

	/* text */
	scrolledwindow_text = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy ((GtkScrolledWindow *)
					scrolledwindow_text,
					GTK_POLICY_AUTOMATIC,
					GTK_POLICY_AUTOMATIC);
	gtk_widget_show (scrolledwindow_text);
	gtk_container_add (GTK_CONTAINER (vpaned1), scrolledwindow_text);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW
					     (scrolledwindow_text),
					     GTK_SHADOW_IN);

	textview = gtk_text_view_new ();
	gtk_widget_show (textview);
	gtk_container_add (GTK_CONTAINER (scrolledwindow_text), textview);
	font_desc = pango_font_description_from_string (font_name);
	gtk_widget_modify_font (textview, font_desc);

	font_name = g_strdup (TEXT_FONT_NAME);

	/* progress bar */
	hbox2 = gtk_hbox_new (FALSE, 0);
	gtk_widget_show (hbox2);
	gtk_box_pack_start (GTK_BOX (vbox1), hbox2, FALSE, FALSE, 0);

	pbar = gtk_progress_bar_new ();
	gtk_widget_show (pbar);
	gtk_box_pack_start (GTK_BOX (hbox2), pbar, FALSE, FALSE, 0);
	gtk_widget_set_size_request (pbar, 100, -1);

	statusbar1 = gtk_statusbar_new ();
	gtk_widget_show (statusbar1);
	gtk_box_pack_start (GTK_BOX (hbox2), statusbar1, TRUE, TRUE, 0);

	/* main window */
	g_signal_connect ((gpointer) window1, "delete_event",
			  G_CALLBACK (on_window1_delete_event), NULL);

	/* toolbar */
	g_signal_connect ((gpointer) toolbutton_open, "clicked",
			  G_CALLBACK (on_toolbutton_open_clicked), NULL);
	g_signal_connect ((gpointer) toolbutton_apply, "clicked",
			  G_CALLBACK (on_toolbutton_apply_clicked), NULL);
	g_signal_connect ((gpointer) toolbutton_save, "clicked",
			  G_CALLBACK (on_toolbutton_save_clicked), NULL);

	g_signal_connect ((gpointer) toolbutton_zoom_in, "clicked",
			  G_CALLBACK (on_toolbutton_zoom_in_clicked), NULL);
	g_signal_connect ((gpointer) toolbutton_zoom_out, "clicked",
			  G_CALLBACK (on_toolbutton_zoom_out_clicked), NULL);
	g_signal_connect ((gpointer) toolbutton_zoom_fit, "clicked",
			  G_CALLBACK (on_toolbutton_zoom_fit_clicked), NULL);

#ifdef WITH_GTKSPELL
	g_signal_connect ((gpointer) toolbutton_spell, "clicked",
			  G_CALLBACK (on_toolbutton_spell_clicked), NULL);
#endif

	/* menu */
	g_signal_connect ((gpointer) open, "activate",
			  G_CALLBACK (on_open_activate), NULL);
	g_signal_connect ((gpointer) apply, "activate",
			  G_CALLBACK (on_apply_activate), NULL);
	g_signal_connect ((gpointer) save, "activate",
			  G_CALLBACK (on_save_activate), NULL);
	g_signal_connect ((gpointer) save_picture, "activate",
			  G_CALLBACK (on_save_picture_activate), NULL);
	g_signal_connect ((gpointer) xsane, "activate",
			  G_CALLBACK (on_xsane_activate), NULL);
	g_signal_connect ((gpointer) quit, "activate",
			  G_CALLBACK (on_quit_activate), NULL);
	g_signal_connect ((gpointer) font, "activate",
			  G_CALLBACK (on_font_activate), NULL);
#ifdef WITH_GTKSPELL
	g_signal_connect ((gpointer) spell_check, "activate",
			  G_CALLBACK (on_spell_check_activate), NULL);
#endif
	g_signal_connect ((gpointer) zoom_in, "activate",
			  G_CALLBACK (on_zoom_in_activate), NULL);
	g_signal_connect ((gpointer) zoom_out, "activate",
			  G_CALLBACK (on_zoom_out_activate), NULL);
	g_signal_connect ((gpointer) normal_size, "activate",
			  G_CALLBACK (on_normal_size_activate), NULL);
	g_signal_connect ((gpointer) about, "activate",
			  G_CALLBACK (on_about_activate), NULL);

	gtk_window_add_accel_group (GTK_WINDOW (window1), accel_group);

	return window1;
}
コード例 #21
0
ファイル: alertpanel.c プロジェクト: eworm-de/claws-mail
static void alertpanel_create(const gchar *title,
			      const gchar *message,
			      const gchar *button1_label,
			      const gchar *button2_label,
			      const gchar *button3_label,
						AlertFocus   focus,
			      gboolean	   can_disable,
			      GtkWidget   *custom_widget,
			      gint	   alert_type)
{
	static PangoFontDescription *font_desc;
	GtkWidget *image;
	GtkWidget *label;
	GtkWidget *hbox;
	GtkWidget *vbox;
	GtkWidget *disable_checkbtn;
	GtkWidget *confirm_area;
	GtkWidget *button1;
	GtkWidget *button2;
	GtkWidget *button3;
	GtkWidget *focusbutton;
	const gchar *label2;
	const gchar *label3;
	gchar *tmp = title?g_markup_printf_escaped("%s", title)
			:g_strdup("");
	gchar *title_full = g_strdup_printf("<span weight=\"bold\" "
				"size=\"larger\">%s</span>",
				tmp);
	g_free(tmp);
	debug_print("Creating alert panel dialog...\n");

	dialog = gtk_dialog_new();
	gtk_window_set_title(GTK_WINDOW(dialog), title);
	gtk_window_set_resizable(GTK_WINDOW(dialog), TRUE);

	gtk_window_set_default_size(GTK_WINDOW(dialog), 375, 100);
	
	gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
	g_signal_connect(G_OBJECT(dialog), "delete_event",
			 G_CALLBACK(alertpanel_deleted),
			 (gpointer)G_ALERTCANCEL);
	g_signal_connect(G_OBJECT(dialog), "key_press_event",
			 G_CALLBACK(alertpanel_close),
			 (gpointer)G_ALERTCANCEL);

	/* for title icon, label and message */
	hbox = gtk_hbox_new(FALSE, 12);
	gtk_container_set_border_width(GTK_CONTAINER(hbox), 12);
	gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),
			   hbox, FALSE, FALSE, 0);

	/* title icon */
	switch (alert_type) {
	case ALERT_QUESTION:
		image = gtk_image_new_from_stock
			(GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
		break;
	case ALERT_WARNING:
		image = gtk_image_new_from_stock
			(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
		break;
	case ALERT_ERROR:
		image = gtk_image_new_from_stock
			(GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG);
		break;
	case ALERT_NOTICE:
	default:
		image = gtk_image_new_from_stock
			(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
		break;
	}
	gtk_misc_set_alignment(GTK_MISC(image), 0.5, 0.0);
	gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);

	vbox = gtk_vbox_new (FALSE, 12);
	gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
	gtk_widget_show (vbox);
	
	label = gtk_label_new(title_full);
	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
	gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
	gtk_label_set_use_markup(GTK_LABEL (label), TRUE);
	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
	gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
	if (!font_desc) {
		gint size;

		size = pango_font_description_get_size
			(gtk_widget_get_style(label)->font_desc);
		font_desc = pango_font_description_new();
		pango_font_description_set_weight
			(font_desc, PANGO_WEIGHT_BOLD);
		pango_font_description_set_size
			(font_desc, size * PANGO_SCALE_LARGE);
	}
	if (font_desc)
		gtk_widget_modify_font(label, font_desc);
	g_free(title_full);
	
	label = gtk_label_new(message);
	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
	gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
	gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
	gtk_label_set_selectable(GTK_LABEL(label), TRUE);
	gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
	gtk_widget_set_can_focus(label, FALSE);
	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
	gtk_widget_show(label);
		
	/* Claws: custom widget */
	if (custom_widget) {
		gtk_box_pack_start(GTK_BOX(vbox), custom_widget, FALSE,
				   FALSE, 0);
	}

	if (can_disable) {
		hbox = gtk_hbox_new(FALSE, 0);
		gtk_box_pack_start(GTK_BOX(
			gtk_dialog_get_content_area(GTK_DIALOG(dialog))), hbox,
				   FALSE, FALSE, 0);

		disable_checkbtn = gtk_check_button_new_with_label
			(_("Show this message next time"));
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(disable_checkbtn),
					     TRUE);
		gtk_box_pack_start(GTK_BOX(hbox), disable_checkbtn,
				   FALSE, FALSE, 12);
		g_signal_connect(G_OBJECT(disable_checkbtn), "toggled",
				 G_CALLBACK(alertpanel_button_toggled),
				 GUINT_TO_POINTER(G_ALERTDISABLE));
	}

	/* for button(s) */
	if (!button1_label)
		button1_label = GTK_STOCK_OK;
	label2 = button2_label;
	label3 = button3_label;

	gtkut_stock_button_set_create(&confirm_area,
				      &button1, button1_label,
				      button2_label ? &button2 : NULL, label2,
				      button3_label ? &button3 : NULL, label3);

	gtk_box_pack_end(GTK_BOX(gtk_dialog_get_action_area(GTK_DIALOG(dialog))),
			 confirm_area, FALSE, FALSE, 0);
	gtk_container_set_border_width(GTK_CONTAINER(confirm_area), 5);

	/* Set focus on correct button as requested. */
	focusbutton = button1;
	switch (focus) {
		case ALERTFOCUS_SECOND:
			if (button2_label != NULL)
				focusbutton = button2;
			break;
		case ALERTFOCUS_THIRD:
			if (button3_label != NULL)
				focusbutton = button3;
			break;
		case ALERTFOCUS_FIRST:
		default:
			focusbutton = button1;
			break;
	}
	gtk_widget_grab_default(focusbutton);
	gtk_widget_grab_focus(focusbutton);

	g_signal_connect(G_OBJECT(button1), "clicked",
			 G_CALLBACK(alertpanel_button_clicked),
			 GUINT_TO_POINTER(G_ALERTDEFAULT));
	if (button2_label)
		g_signal_connect(G_OBJECT(button2), "clicked",
				 G_CALLBACK(alertpanel_button_clicked),
				 GUINT_TO_POINTER(G_ALERTALTERNATE));
	if (button3_label)
		g_signal_connect(G_OBJECT(button3), "clicked",
				 G_CALLBACK(alertpanel_button_clicked),
				 GUINT_TO_POINTER(G_ALERTOTHER));

	gtk_widget_show_all(dialog);
}
コード例 #22
0
static void
file_list_ready_cb (GList *files,
                    gpointer user_data)
{
    CajaFileConflictDialog *fcd = user_data;
    CajaFile *src, *dest, *dest_dir;
    time_t src_mtime, dest_mtime;
    GtkDialog *dialog;
    gboolean source_is_dir,	dest_is_dir, should_show_type;
    CajaFileConflictDialogDetails *details;
    char *primary_text, *message, *secondary_text;
    const gchar *message_extra;
    char *src_name, *dest_name, *dest_dir_name, *edit_name;
    char *label_text;
    char *size, *date, *type = NULL;
    GdkPixbuf *pixbuf;
    GtkWidget *label;
    GString *str;
    PangoFontDescription *desc;

    dialog = GTK_DIALOG (fcd);
    details = fcd->details;

    details->handle = NULL;

    dest_dir = g_list_nth_data (files, 0);
    dest = g_list_nth_data (files, 1);
    src = g_list_nth_data (files, 2);

    src_mtime = caja_file_get_mtime (src);
    dest_mtime = caja_file_get_mtime (dest);

    src_name = caja_file_get_display_name (src);
    dest_name = caja_file_get_display_name (dest);
    dest_dir_name = caja_file_get_display_name (dest_dir);

    source_is_dir = caja_file_is_directory (src);
    dest_is_dir = caja_file_is_directory (dest);

    type = caja_file_get_mime_type (dest);
    should_show_type = !caja_file_is_mime_type (src, type);

    g_free (type);
    type = NULL;

    /* Set up the right labels */
    if (dest_is_dir)
    {
        if (source_is_dir)
        {
            primary_text = g_strdup_printf
                           (_("Merge folder \"%s\"?"),
                            dest_name);

            message_extra =
                _("Merging will ask for confirmation before replacing any files in "
                  "the folder that conflict with the files being copied.");

            if (src_mtime > dest_mtime)
            {
                message = g_strdup_printf (
                              _("An older folder with the same name already exists in \"%s\"."),
                              dest_dir_name);
            }
            else if (src_mtime < dest_mtime)
            {
                message = g_strdup_printf (
                              _("A newer folder with the same name already exists in \"%s\"."),
                              dest_dir_name);
            }
            else
            {
                message = g_strdup_printf (
                              _("Another folder with the same name already exists in \"%s\"."),
                              dest_dir_name);
            }
        }
        else
        {
            message_extra =
                _("Replacing it will remove all files in the folder.");
            primary_text = g_strdup_printf
                           (_("Replace folder \"%s\"?"), dest_name);
            message = g_strdup_printf
                      (_("A folder with the same name already exists in \"%s\"."),
                       dest_dir_name);
        }
    }
    else
    {
        primary_text = g_strdup_printf
                       (_("Replace file \"%s\"?"), dest_name);

        message_extra = _("Replacing it will overwrite its content.");

        if (src_mtime > dest_mtime)
        {
            message = g_strdup_printf (
                          _("An older file with the same name already exists in \"%s\"."),
                          dest_dir_name);
        }
        else if (src_mtime < dest_mtime)
        {
            message = g_strdup_printf (
                          _("A newer file with the same name already exists in \"%s\"."),
                          dest_dir_name);
        }
        else
        {
            message = g_strdup_printf (
                          _("Another file with the same name already exists in \"%s\"."),
                          dest_dir_name);
        }
    }

    secondary_text = g_strdup_printf ("%s\n%s", message, message_extra);
    g_free (message);

    label = gtk_label_new (primary_text);
    gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
    gtk_label_set_line_wrap_mode (GTK_LABEL (label), PANGO_WRAP_WORD_CHAR);
    gtk_widget_set_size_request (label, 350, -1);
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    gtk_box_pack_start (GTK_BOX (details->titles_vbox),
                        label, FALSE, FALSE, 0);
    gtk_widget_modify_font (label, NULL);
    desc = pango_font_description_new ();
    pango_font_description_set_weight (desc, PANGO_WEIGHT_BOLD);
    pango_font_description_set_size (desc,
                                     pango_font_description_get_size (gtk_widget_get_style (label)->font_desc) * PANGO_SCALE_LARGE);
    gtk_widget_modify_font (label, desc);
    pango_font_description_free (desc);
    gtk_widget_show (label);

    label = gtk_label_new (secondary_text);
    gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
    gtk_widget_set_size_request (label, 350, -1);
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    gtk_box_pack_start (GTK_BOX (details->titles_vbox),
                        label, FALSE, FALSE, 0);
    gtk_widget_show (label);
    g_free (primary_text);
    g_free (secondary_text);

    /* Set up file icons */
    pixbuf = caja_file_get_icon_pixbuf (dest,
                                        CAJA_ICON_SIZE_LARGE,
                                        TRUE,
                                        CAJA_FILE_ICON_FLAGS_USE_THUMBNAILS);
    details->dest_image = gtk_image_new_from_pixbuf (pixbuf);
    gtk_box_pack_start (GTK_BOX (details->first_hbox),
                        details->dest_image, FALSE, FALSE, 0);
    gtk_widget_show (details->dest_image);
    g_object_unref (pixbuf);

    pixbuf = caja_file_get_icon_pixbuf (src,
                                        CAJA_ICON_SIZE_LARGE,
                                        TRUE,
                                        CAJA_FILE_ICON_FLAGS_USE_THUMBNAILS);
    details->src_image = gtk_image_new_from_pixbuf (pixbuf);
    gtk_box_pack_start (GTK_BOX (details->second_hbox),
                        details->src_image, FALSE, FALSE, 0);
    gtk_widget_show (details->src_image);
    g_object_unref (pixbuf);

    /* Set up labels */
    label = gtk_label_new (NULL);
    date = caja_file_get_string_attribute (dest,
                                           "date_modified");
    size = caja_file_get_string_attribute (dest, "size");

    if (should_show_type)
    {
        type = caja_file_get_string_attribute (dest, "type");
    }

    str = g_string_new (NULL);
    g_string_append_printf (str, "<b>%s</b>\n", _("Original file"));
    g_string_append_printf (str, "<i>%s</i> %s\n", _("Size:"), size);

    if (should_show_type)
    {
        g_string_append_printf (str, "<i>%s</i> %s\n", _("Type:"), type);
    }

    g_string_append_printf (str, "<i>%s</i> %s", _("Last modified:"), date);

    label_text = str->str;
    gtk_label_set_markup (GTK_LABEL (label),
                          label_text);
    gtk_box_pack_start (GTK_BOX (details->first_hbox),
                        label, FALSE, FALSE, 0);
    gtk_widget_show (label);

    g_free (size);
    g_free (type);
    g_free (date);
    g_string_erase (str, 0, -1);

    /* Second label */
    label = gtk_label_new (NULL);
    date = caja_file_get_string_attribute (src,
                                           "date_modified");
    size = caja_file_get_string_attribute (src, "size");

    if (should_show_type)
    {
        type = caja_file_get_string_attribute (src, "type");
    }

    g_string_append_printf (str, "<b>%s</b>\n", _("Replace with"));
    g_string_append_printf (str, "<i>%s</i> %s\n", _("Size:"), size);

    if (should_show_type)
    {
        g_string_append_printf (str, "<i>%s</i> %s\n", _("Type:"), type);
    }

    g_string_append_printf (str, "<i>%s</i> %s", _("Last modified:"), date);
    label_text = g_string_free (str, FALSE);

    gtk_label_set_markup (GTK_LABEL (label),
                          label_text);
    gtk_box_pack_start (GTK_BOX (details->second_hbox),
                        label, FALSE, FALSE, 0);
    gtk_widget_show (label);

    g_free (size);
    g_free (date);
    g_free (type);
    g_free (label_text);

    /* Populate the entry */
    edit_name = caja_file_get_edit_name (dest);
    details->conflict_name = edit_name;

    gtk_entry_set_text (GTK_ENTRY (details->entry), edit_name);

    if (source_is_dir && dest_is_dir)
    {
        gtk_button_set_label (GTK_BUTTON (details->replace_button),
                              _("Merge"));
    }

    /* If meld is installed, and source and destination arent binary
     * files, show the diff button
     */
    gtk_widget_hide (details->diff_button);
    if (!source_is_dir && !dest_is_dir)
    {
        if (g_find_program_in_path ("meld")) {

            gboolean src_is_binary;
            gboolean dest_is_binary;

            src_is_binary = caja_file_is_binary (details->source);
            dest_is_binary = caja_file_is_binary (details->destination);

            if (!src_is_binary && !dest_is_binary)
                gtk_widget_show (details->diff_button);
        }
    }

    caja_file_monitor_add (src, fcd, CAJA_FILE_ATTRIBUTES_FOR_ICON);
    caja_file_monitor_add (dest, fcd, CAJA_FILE_ATTRIBUTES_FOR_ICON);

    details->src_handler_id = g_signal_connect (src, "changed",
                              G_CALLBACK (file_icons_changed), fcd);
    details->dest_handler_id = g_signal_connect (dest, "changed",
                               G_CALLBACK (file_icons_changed), fcd);
}
コード例 #23
0
ファイル: data_view.c プロジェクト: tuxdna/anjuta
static void
dma_data_view_create_widget (DmaDataView *view)
{
	GtkAdjustment *adj;
	GtkWidget* wid;
	PangoFontDescription *font_desc;

	wid = GTK_WIDGET (view);

	gtk_widget_set_has_window (wid, FALSE);
	gtk_widget_set_can_focus (wid, TRUE);
	gtk_widget_set_redraw_on_allocate (wid, FALSE); 	
	
	view->char_by_byte = 2;
	view->bytes_by_line = 16;
	view->line_by_page = 16;
	
	view->hadjustment = NULL;
	view->vadjustment = NULL;
	
	view->shadow_type = GTK_SHADOW_IN;

	view->goto_window = NULL;
	view->goto_entry = NULL;
	
	font_desc = pango_font_description_from_string ("Monospace 10");
	
	view->buffer_range = GTK_ADJUSTMENT (gtk_adjustment_new (0,
											 dma_data_buffer_get_lower (view->buffer),
											 dma_data_buffer_get_upper (view->buffer)
											 ,1,4,4));
	g_signal_connect (view->buffer_range, "value_changed",
                        G_CALLBACK (dma_data_view_value_changed), view);
	
	gtk_widget_push_composite_child ();
	
	wid = gtk_vscrollbar_new (view->buffer_range);
	g_object_ref (wid);
	view->range = wid;
	gtk_widget_set_parent (wid, GTK_WIDGET (view));
	adj = view->view_range;
	gtk_widget_show (wid);

	wid = dma_chunk_view_new ();
	g_object_ref (wid);
	gtk_widget_modify_font (wid, font_desc);
	gtk_widget_set_parent (wid, GTK_WIDGET (view));
	gtk_widget_set_size_request (wid, -1, 0);
	gtk_widget_show (wid);
	gtk_text_view_set_editable (GTK_TEXT_VIEW (wid), FALSE);
	view->ascii = wid;
	view->ascii_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (wid));
	dma_chunk_view_set_scroll_adjustment (DMA_CHUNK_VIEW (wid), view->buffer_range);
	g_signal_connect (wid, "populate_popup",
                        G_CALLBACK (dma_data_view_populate_popup), view);
	
	wid = dma_chunk_view_new ();
	g_object_ref (wid);
	gtk_widget_modify_font (wid, font_desc);
	gtk_widget_set_parent (wid, GTK_WIDGET (view));
	gtk_widget_set_size_request (wid, -1, 0);
	gtk_widget_show (wid);
	gtk_text_view_set_editable (GTK_TEXT_VIEW (wid), FALSE);
	view->data = wid;
	view->data_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (wid));
	dma_chunk_view_set_scroll_adjustment (DMA_CHUNK_VIEW (wid), view->buffer_range);
	g_signal_connect (wid, "populate_popup",
                        G_CALLBACK (dma_data_view_populate_popup), view);

	wid = dma_chunk_view_new ();
	g_object_ref (wid);
	gtk_widget_modify_font (wid, font_desc);
	gtk_widget_set_parent (wid, GTK_WIDGET (view));
	gtk_widget_set_size_request (wid, -1, 0);
	gtk_widget_show (wid);
	gtk_text_view_set_editable (GTK_TEXT_VIEW (wid), FALSE);
	view->address = wid;
	view->adr_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (wid));
	dma_chunk_view_set_scroll_adjustment (DMA_CHUNK_VIEW (wid), view->buffer_range);
	g_signal_connect (wid, "populate_popup",
                        G_CALLBACK (dma_data_view_populate_popup), view);
	
	gtk_widget_pop_composite_child ();
	pango_font_description_free (font_desc);
}
コード例 #24
0
ファイル: statistics.c プロジェクト: TiNkU-dArsHan/subsurface
static void init_tree()
{
	GtkCellRenderer *renderer;
	GtkTreeViewColumn *column;
	GtkTreeStore *store;
	int i;
	PangoFontDescription *font_desc = pango_font_description_from_string(prefs.divelist_font);

	gtk_widget_modify_font(yearly_tree, font_desc);
	pango_font_description_free(font_desc);

	renderer = gtk_cell_renderer_text_new ();
	/* don't use empty strings "" - they confuse gettext */
	char *columnstop[] = { N_("Year"), N_("#"), N_("Duration"), " ", " ", " ", N_("Depth"), " ", " ", N_("SAC"), " ", " ", N_("Temperature"), " ", " " };
	const char *columnsbot[15];
	columnsbot[0] = C_("Stats", " > Month");
	columnsbot[1] = " ";
	columnsbot[2] = C_("Duration","Total");
	columnsbot[3] = C_("Duration","Average");
	columnsbot[4] = C_("Duration","Shortest");
	columnsbot[5] = C_("Duration","Longest");
	columnsbot[6] = C_("Depth", "Average");
	columnsbot[7] = C_("Depth","Minimum");
	columnsbot[8] = C_("Depth","Maximum");
	columnsbot[9] = C_("SAC","Average");
	columnsbot[10]= C_("SAC","Minimum");
	columnsbot[11]= C_("SAC","Maximum");
	columnsbot[12]= C_("Temp","Average");
	columnsbot[13]= C_("Temp","Minimum");
	columnsbot[14]= C_("Temp","Maximum");

	/* Add all the columns to the tree view */
	for (i = 0; i < N_COLUMNS; ++i) {
		char buf[256];
		column = gtk_tree_view_column_new();
		snprintf(buf, sizeof(buf), "%s\n%s", _(columnstop[i]), columnsbot[i]);
		gtk_tree_view_column_set_title(column, buf);
		gtk_tree_view_append_column(GTK_TREE_VIEW(yearly_tree), column);
		renderer = gtk_cell_renderer_text_new();
		gtk_tree_view_column_pack_start(column, renderer, TRUE);
		gtk_tree_view_column_add_attribute(column, renderer, "text", i);
		gtk_tree_view_column_set_resizable(column, TRUE);
	}

	/* Field types */
	store = gtk_tree_store_new (
			N_COLUMNS,	// Columns in structure
			G_TYPE_STRING,	// Period (year or month)
			G_TYPE_STRING,	// Number of dives
			G_TYPE_STRING,	// Total duration
			G_TYPE_STRING,	// Average dive duation
			G_TYPE_STRING,	// Shortest dive
			G_TYPE_STRING,	// Longest dive
			G_TYPE_STRING,	// Average depth
			G_TYPE_STRING,	// Shallowest dive
			G_TYPE_STRING,	// Deepest dive
			G_TYPE_STRING,	// Average air consumption (SAC)
			G_TYPE_STRING,	// Minimum SAC
			G_TYPE_STRING,	// Maximum SAC
			G_TYPE_STRING,	// Average temperature
			G_TYPE_STRING,	// Minimum temperature
			G_TYPE_STRING	// Maximum temperature
			);

	gtk_tree_view_set_model (GTK_TREE_VIEW (yearly_tree), GTK_TREE_MODEL (store));
	g_object_unref (store);
}
コード例 #25
0
ファイル: divelist.c プロジェクト: johslarsen/subsurface
void set_divelist_font(const char *font)
{
	PangoFontDescription *font_desc = pango_font_description_from_string(font);
	gtk_widget_modify_font(dive_list.tree_view, font_desc);
	pango_font_description_free(font_desc);
}
コード例 #26
0
/*
  Refresh gadget's background if needed
*/
gboolean
refresh_background (block_notes_core_s *core)
{	
  GdkColor color;
  cairo_t *cr;
  double x0      = 5.0;
  double y0      = 12.0;
  double rect_width  = core->width - 10;
  double rect_height = core->height - 12;
  double radius = 40;
  double x1,y1;

  cr = gdk_cairo_create (core->window->window);

  /* Set gadget's background transparent */
  cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.0);
  cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
  cairo_paint (cr);

  x1 = x0 + rect_width;
  y1 = y0 + rect_height;

  if (!rect_width || !rect_height)
    return;

  cairo_move_to  (cr, x0, (y0 + y1)/2);
  cairo_curve_to (cr, x0 ,y0, x0, y0, (x0 + x1)/2, y0);
  cairo_curve_to (cr, x1, y0, x1, y0, x1, (y0 + y1)/2);
  cairo_curve_to (cr, x1, y1, x1, y1, (x1 + x0)/2, y1);
  cairo_curve_to (cr, x0, y1, x0, y1, x0, (y0 + y1)/2);

  cairo_close_path (cr);

  cairo_set_source_rgba (cr,
                         (float) core->gadget.red / 65535.0,
                         (float) core->gadget.green / 65535.0,
                         (float) core->gadget.blue / 65535.0,
                         1.0);
	
  cairo_fill_preserve (cr);
	
  cairo_set_source_rgba (cr,
                         (float) core->border.red / 65535.0,
                         (float) core->border.green / 65535.0,
                         (float) core->border.blue / 65535.0,
                         core->border_transparency);

  cairo_set_line_width (cr, 3.0);
  cairo_stroke (cr);
  cairo_destroy (cr);


  gtk_widget_modify_base (core->view, GTK_STATE_NORMAL, &core->gadget);

  /* Reset textview font */
  gtk_widget_modify_font (core->view, core->font_pango);

  /* Reset font color */
  gtk_widget_modify_text (core->view, GTK_STATE_NORMAL, &core->text);

  /* Resize window */
  gtk_window_resize (GTK_WINDOW(core->window), core->width, core->height);

  /* Reset buttons */
  gtk_fixed_move (GTK_FIXED(core->fixed), core->button_setting, core->width - 40, 0);
  gtk_fixed_move (GTK_FIXED(core->fixed), core->button_move, core->width - 30, 0);
  gtk_fixed_move (GTK_FIXED(core->fixed), core->button_close, core->width - 20, 0);
  gtk_widget_set_size_request (core->view, core->width - 27, core->height - 30);

  return FALSE;
}
コード例 #27
0
ファイル: uosrbsw_r.c プロジェクト: zaharchuktv/linuxbuh
int uosrbsw_r(class uosrbsw_data *datark,GtkWidget *wpredok)
{
char strsql[512];
iceb_u_str repl;
class uosrbsw_r_data data;
data.rk=datark;

data.window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_modal(GTK_WINDOW(data.window),TRUE);
gtk_window_set_position( GTK_WINDOW(data.window),ICEB_POS_CENTER);
gtk_window_set_default_size (GTK_WINDOW  (data.window),400,-1);

sprintf(strsql,"%s %s",name_system,gettext("Расчёт балансовой стоимости по мат.ответственным и счетам учёта"));

//sprintf(strsql,"%s %s",name_system,gettext("Распечатка ведомости аморт-отчислений для налогового учёта"));
gtk_window_set_title(GTK_WINDOW(data.window),strsql);

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

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

GtkWidget *vbox=gtk_vbox_new(FALSE, 2);

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

data.label=gtk_label_new(gettext("Ждите !!!"));

gtk_box_pack_start(GTK_BOX(vbox),data.label,FALSE,FALSE,0);

repl.plus(gettext("Расчёт балансовой стоимости по мат.ответственным и счетам учёта"));

sprintf(strsql,"%s:%s %s\n",gettext("База данных"),imabaz,organ);
repl.ps_plus(strsql);

GtkWidget *label=gtk_label_new(repl.ravno_toutf());

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

data.view=gtk_text_view_new();
gtk_widget_set_usize(GTK_WIDGET(data.view),450,300);

gtk_text_view_set_editable(GTK_TEXT_VIEW(data.view),FALSE); //Запрет на редактирование текста
//PangoFontDescription *font_pango=pango_font_description_from_string("Nimbus Mono L, Bold 12");
PangoFontDescription *font_pango=pango_font_description_from_string(shrift_ravnohir.ravno());
gtk_widget_modify_font(GTK_WIDGET(data.view),font_pango);
pango_font_description_free(font_pango);

data.buffer=gtk_text_view_get_buffer(GTK_TEXT_VIEW(data.view));

GtkWidget *sw=gtk_scrolled_window_new(NULL,NULL);
//gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),GTK_SHADOW_ETCHED_IN);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
//gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),GTK_POLICY_ALWAYS,GTK_POLICY_ALWAYS);
gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
gtk_container_add(GTK_CONTAINER(sw),data.view);


data.bar=gtk_progress_bar_new();

gtk_progress_bar_set_bar_style(GTK_PROGRESS_BAR(data.bar),GTK_PROGRESS_CONTINUOUS);

gtk_progress_bar_set_orientation(GTK_PROGRESS_BAR(data.bar),GTK_PROGRESS_LEFT_TO_RIGHT);

gtk_box_pack_start (GTK_BOX (vbox), data.bar, FALSE, FALSE, 2);



sprintf(strsql,"F10 %s",gettext("Выход"));
data.knopka=gtk_button_new_with_label(strsql);
GtkTooltips *tooltops=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltops,data.knopka,gettext("Завершение работы в этом окне"),NULL);
gtk_signal_connect(GTK_OBJECT(data.knopka),"clicked",GTK_SIGNAL_FUNC(uosrbsw_r_v_knopka),&data);
gtk_object_set_user_data(GTK_OBJECT(data.knopka),(gpointer)0);
gtk_box_pack_start (GTK_BOX (vbox), data.knopka, FALSE, FALSE, 2);

gtk_widget_set_sensitive(GTK_WIDGET(data.knopka),FALSE);//Недоступна

gtk_widget_show_all(data.window);


//gtk_window_set_decorated(GTK_WINDOW(data.window),FALSE); //Убирает рамку вокруг окна

//gtk_widget_set_sensitive(GTK_WIDGET(data.knopka),FALSE);//Недоступна

gtk_idle_add((GtkFunction)uosrbsw_r1,&data);

gtk_main();

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

return(data.voz);
}
コード例 #28
0
ファイル: help.c プロジェクト: insidevivek/GCompris
void gc_help_start (GcomprisBoard *gcomprisBoard)
{

  gchar *item_id = "#UP";
  GooCanvasItem *item;
  gint y = 0;
  gint y_start = 0;
  gint x_start = 0;
  gchar   *name = NULL;
  gchar   *text_to_display = NULL;

  if(rootitem)
    return;

  gc_board_pause(TRUE);

  caller_cursor = gc_cursor_get();
  gc_cursor_set(GCOMPRIS_DEFAULT_CURSOR);

  item_selected = NULL;
  item_selected_text = NULL;

  name = gcomprisBoard->title;
  gc_help_has_board(gcomprisBoard);

  rootitem = goo_canvas_group_new (goo_canvas_get_root_item(gc_get_canvas()),
				   NULL);

  item = goo_canvas_svg_new (rootitem,
			     gc_skin_rsvg_get(),
			     "svg-id", "#DIALOG",
			     "pointer-events", GOO_CANVAS_EVENTS_NONE,
			     NULL);

  GooCanvasBounds bounds;
  guint pixmap_width = 40;
  goo_canvas_item_get_bounds(item, &bounds);
  x_start = bounds.x1;
  y_start = bounds.y1;

  y = bounds.y2 - 26;

  y_start += 15;
  if(gcomprisBoard->section && gcomprisBoard->name) {
    text_to_display = g_strdup_printf("%s/%s", gcomprisBoard->section, gcomprisBoard->name);
     goo_canvas_text_new (rootitem,
			  text_to_display,
			  BOARDWIDTH*0.10,
			  y_start,
			  -1,
			  GTK_ANCHOR_NW,
			  "font", gc_skin_font_board_tiny,
			  "fill-color-rgba", gc_skin_color_title,
			  NULL);
    g_free(text_to_display);
  }

  y_start += 30;
  goo_canvas_text_new (rootitem,
		       name,
		       BOARDWIDTH/2,
		       y_start,
		       -1,
		       GTK_ANCHOR_CENTER,
		       "font", gc_skin_font_title,
		       "fill-color-rgba", gc_skin_color_title,
		       NULL);


  y_start += 80;

  // Prerequisite Button
  if(prerequisite)
    {
      item_prerequisite = goo_canvas_svg_new (rootitem,
					      gc_skin_rsvg_get(),
					      "svg-id", item_id,
					      NULL);
      SET_ITEM_LOCATION(item_prerequisite,
			(BOARDWIDTH*0.2) - pixmap_width/2,
			y_start  - 10)

      g_signal_connect(item_prerequisite, "button_press_event",
			 (GCallback) item_event_help,
			 "prerequisite");
      gc_item_focus_init(item_prerequisite, NULL);

      item_prerequisite_text = \
	goo_canvas_text_new (rootitem,
			     _("Prerequisite"),
			     BOARDWIDTH*0.20,
			     y_start   + GAP_TO_BUTTON,
			     -1,
			     GTK_ANCHOR_CENTER,
			     "font", gc_skin_font_content,
			     "fill-color-rgba", gc_skin_get_color("gcompris/helpunselect"),
			     NULL);
      g_signal_connect(item_prerequisite_text, "button_press_event",
			 (GCallback) item_event_help,
			 "prerequisite");
    }

  // Goal Button
  if(goal)
    {
      item_goal = goo_canvas_svg_new (rootitem,
				      gc_skin_rsvg_get(),
				      "svg-id", item_id,
				      NULL);
      SET_ITEM_LOCATION(item_goal,
			(BOARDWIDTH*0.4) - pixmap_width/2,
			y_start  - 10);

      g_signal_connect(item_goal, "button_press_event",
			 (GCallback) item_event_help,
			 "goal");
      gc_item_focus_init(item_goal, NULL);

      item_goal_text = goo_canvas_text_new (rootitem,
					    _("Goal"),
					    BOARDWIDTH*0.4,
					    y_start   + GAP_TO_BUTTON,
					    -1,
					    GTK_ANCHOR_CENTER,
					    "font", gc_skin_font_content,
					    "fill-color-rgba", gc_skin_get_color("gcompris/helpunselect"),
					    NULL);
      g_signal_connect(item_goal_text, "button_press_event",
			 (GCallback) item_event_help,
			 "goal");
    }

  // Manual Button
  if(manual)
    {
      item_manual = goo_canvas_svg_new (rootitem,
					gc_skin_rsvg_get(),
					"svg-id", item_id,
					NULL);
      SET_ITEM_LOCATION(item_manual,
			(BOARDWIDTH*0.6) - pixmap_width/2,
			y_start  - 10);

      g_signal_connect(item_manual, "button_press_event",
			 (GCallback) item_event_help,
			 "manual");
      gc_item_focus_init(item_manual, NULL);

      item_manual_text = goo_canvas_text_new (rootitem,
					      _("Manual"),
					      BOARDWIDTH*0.6,
					      y_start   + GAP_TO_BUTTON,
					      -1,
					      GTK_ANCHOR_CENTER,
					      "font", gc_skin_font_content,
					      "fill-color-rgba", gc_skin_get_color("gcompris/helpunselect"),
					      NULL);
      g_signal_connect(item_manual_text, "button_press_event",
			 (GCallback) item_event_help,
			 "manual");
    }

  // Credit Button
  if(credit)
    {
      item_credit = goo_canvas_svg_new (rootitem,
					gc_skin_rsvg_get(),
					"svg-id", item_id,
					NULL);
      SET_ITEM_LOCATION(item_credit,
			(BOARDWIDTH*0.8) - pixmap_width/2,
			y_start  - 10);

      g_signal_connect(item_credit, "button_press_event",
			 (GCallback) item_event_help,
			 "credit");
      gc_item_focus_init(item_credit, NULL);

      item_credit_text = goo_canvas_text_new (rootitem,
					      _("Credit"),
					      BOARDWIDTH*0.8,
					      y_start   + GAP_TO_BUTTON,
					      -1,
					      GTK_ANCHOR_CENTER,
					      "font", gc_skin_font_content,
					      "fill-color-rgba", gc_skin_get_color("gcompris/helpunselect"),
					      NULL);
      g_signal_connect(item_credit_text, "button_press_event",
			 (GCallback) item_event_help,
			 "credit");
    }

  // CONTENT

  // default text to display

  if(prerequisite)
    {
      text_to_display = prerequisite;
      select_item(item_prerequisite, item_prerequisite_text);
    }
  else if(goal)
    {
      text_to_display = goal;
      select_item(item_goal, item_goal_text);
    }
  else if(manual)
    {
      text_to_display = manual;
      select_item(item_manual, item_manual_text);
    }
  else if(credit)
    {
      text_to_display = credit;
      select_item(item_credit, item_credit_text);
    }

  y_start += 45;

  /* Create a scrolled area for the text content */
  GtkWidget *view;
  GtkWidget *sw;
  view = gtk_text_view_new ();
  gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD);
  gtk_text_view_set_editable(GTK_TEXT_VIEW (view), FALSE);
  gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW (view), FALSE);

  g_signal_connect(GTK_OBJECT(view), "button-press-event",
		   (GCallback) event_disable_right_click_popup, NULL);

  PangoFontDescription *font_desc;
  font_desc = pango_font_description_from_string (gc_skin_font_content);
  gtk_widget_modify_font (view, font_desc);
  pango_font_description_free (font_desc);

  GdkColor fg_color;
  GdkColor bg_color;
  gc_skin_get_gdkcolor("gcompris/helpfg", &fg_color);
  gc_skin_get_gdkcolor("gcompris/helpbg", &bg_color);
  gtk_widget_modify_base(view, GTK_STATE_NORMAL, &bg_color);
  gtk_widget_modify_text(view, GTK_STATE_NORMAL, &fg_color);

  buffer_content = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
  sw = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
				  GTK_POLICY_AUTOMATIC,
				  GTK_POLICY_AUTOMATIC);
  gtk_container_add (GTK_CONTAINER (sw), view);

  goo_canvas_widget_new (rootitem,
			 sw,
			 x_start + 40,
			 y_start,
			 618.0,
			 280.0,
			 NULL);
  gtk_widget_show_all (sw);

  set_content(text_to_display);
  // OK
  gc_util_button_text_svg(rootitem,
			  BOARDWIDTH * 0.5,
			  y,
			  "#BUTTON_TEXT",
			  _("OK"),
			  (GCallback) item_event_help,
			  "ok");

  gc_bar_hide(TRUE);

  help_displayed = TRUE;
}
コード例 #29
0
ファイル: imageheader.c プロジェクト: DINKIN/nip2
static void
imageheader_build( GtkWidget *widget )
{
	Imageheader *imageheader = IMAGEHEADER( widget );
	iDialog *idlg = IDIALOG( widget );
	GtkCellRenderer *renderer;
	GtkTreeViewColumn *column;

	GtkWidget *top;
	GtkWidget *label;
	GtkWidget *swin;
	GtkWidget *pane;
	GtkWidget *vbox;
	PangoFontDescription *font_desc;

#ifdef DEBUG
	printf( "imageheader_build: %s\n", IWINDOW( imageheader )->title );
#endif /*DEBUG*/

	/* Call all builds in superclasses.
	 */
	if( IWINDOW_CLASS( imageheader_parent_class )->build )
		(*IWINDOW_CLASS( imageheader_parent_class )->build)( widget );

	pane = gtk_vpaned_new();
        gtk_box_pack_start( GTK_BOX( idlg->work ), pane, TRUE, TRUE, 2 );

	vbox = gtk_vbox_new( FALSE, 2 );
	gtk_paned_pack1( GTK_PANED( pane ), vbox, TRUE, FALSE );

	top = gtk_hbox_new( FALSE, 12 );
        gtk_box_pack_start( GTK_BOX( vbox ), top, FALSE, FALSE, 2 );

	imageheader->entry = gtk_entry_new();
        gtk_signal_connect( GTK_OBJECT( imageheader->entry ), "changed", 
		GTK_SIGNAL_FUNC( imageheader_entry_changed_cb ), 
		imageheader );
	gtk_box_pack_end( GTK_BOX( top ), 
		imageheader->entry, FALSE, FALSE, 2 );

	label = gtk_image_new_from_stock( GTK_STOCK_FIND, GTK_ICON_SIZE_MENU );
	gtk_box_pack_end( GTK_BOX( top ), label, FALSE, FALSE, 0 );

	swin = gtk_scrolled_window_new( NULL, NULL );
        gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( swin ),
		GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
        gtk_box_pack_start( GTK_BOX( vbox ), swin, TRUE, TRUE, 2 );

	imageheader->store = gtk_list_store_new( N_COLUMNS, 
		G_TYPE_STRING, 
		G_TYPE_STRING );

	imageheader->filter = gtk_tree_model_filter_new( 
		GTK_TREE_MODEL( imageheader->store ), NULL );
	gtk_tree_model_filter_set_visible_func( 
		GTK_TREE_MODEL_FILTER( imageheader->filter ), 
		imageheader_visible_func, imageheader, NULL );

	imageheader->tree = gtk_tree_view_new_with_model( 
		GTK_TREE_MODEL( imageheader->filter ) );
	gtk_tree_view_set_rules_hint( GTK_TREE_VIEW( imageheader->tree ),
		TRUE );
	gtk_container_add( GTK_CONTAINER( swin ), imageheader->tree );

	renderer = gtk_cell_renderer_text_new();
	column = gtk_tree_view_column_new_with_attributes( _( "Field" ),
		   renderer, "text", NAME_COLUMN, NULL );
	gtk_tree_view_column_set_resizable( column, TRUE );
	gtk_tree_view_append_column( GTK_TREE_VIEW( imageheader->tree ), 
		column );

	renderer = gtk_cell_renderer_text_new();
	column = gtk_tree_view_column_new_with_attributes( _( "Value" ),
		   renderer, "text", VALUE_COLUMN, NULL );
	gtk_tree_view_column_set_resizable( column, TRUE );
	gtk_tree_view_append_column( GTK_TREE_VIEW( imageheader->tree ), 
		column );

	vbox = gtk_vbox_new( FALSE, 2 );
	gtk_paned_pack2( GTK_PANED( pane ), vbox, TRUE, FALSE );
	label = gtk_label_new( _( "Image history" ) );
	gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 );
        gtk_box_pack_start( GTK_BOX( vbox ), label, FALSE, FALSE, 2 );
	swin = gtk_scrolled_window_new( NULL, NULL );
	gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( swin ),
		GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
        gtk_box_pack_end( GTK_BOX( vbox ), swin, TRUE, TRUE, 2 );
	imageheader->history = gtk_text_view_new();
	gtk_text_view_set_editable( GTK_TEXT_VIEW( imageheader->history ), 
		FALSE );
	gtk_text_view_set_cursor_visible( GTK_TEXT_VIEW( imageheader->history ),
		FALSE );
	font_desc = pango_font_description_from_string( "Monospace" );
	gtk_widget_modify_font( imageheader->history, font_desc );
	pango_font_description_free( font_desc );
	gtk_container_add( GTK_CONTAINER( swin ), imageheader->history );

	imageheader_refresh( imageheader );

        gtk_window_set_default_size( GTK_WINDOW( imageheader ), 550, 550 );
	gtk_paned_set_position( GTK_PANED( pane ), 350 );

	gtk_widget_show_all( idlg->work );
}
コード例 #30
0
ファイル: progress.c プロジェクト: DeforaOS/Accessories
static int _progress(Prefs * prefs, char * argv[])
{
	Progress p;
	struct stat st;
	GtkWidget * vbox;
	GtkWidget * hbox;
	GtkSizeGroup * left;
	GtkSizeGroup * right;
	GtkWidget * widget;
	PangoFontDescription * bold;
	char const * q;
	unsigned long id;
  
	memset(&p, 0, sizeof(p));
	p.prefs = prefs;
	if(prefs->bufsiz == 0)
		errno = EINVAL;
	if(prefs->bufsiz == 0 || (p.buf = malloc(prefs->bufsiz)) == NULL)
		return _progress_error(&p, "malloc", 1);
	p.bufsiz = prefs->bufsiz;
	if(pipe(p.fds) != 0)
		return _progress_error(&p, "pipe", 1);
	if((p.pid = fork()) == -1)
	{
		close(p.fds[0]);
		close(p.fds[1]);
		return _progress_error(&p, "fork", 1);
	}
	if(p.pid != 0)
		return _progress_exec(&p, argv);
	close(p.fds[0]);
	if(gettimeofday(&p.tv, NULL) != 0)
		return _progress_error(&p, "gettimeofday", 1);
	if(prefs->filename == NULL)
		prefs->filename = _("Standard input");
	else if((p.fd = open(prefs->filename, O_RDONLY)) < 0)
		return _progress_error(&p, prefs->filename, 1);
	else if(fstat(p.fd, &st) == 0 && S_ISREG(st.st_mode))
		prefs->length = st.st_size;
	p.in_channel = g_io_channel_unix_new(p.fd);
	g_io_channel_set_encoding(p.in_channel, NULL, NULL);
	p.in_id = 0;
	g_idle_add(_progress_idle_in, &p);
	p.out_channel = g_io_channel_unix_new(p.fds[1]);
	g_io_channel_set_encoding(p.out_channel, NULL, NULL);
	p.out_id = 0;
	/* graphical interface */
	if((prefs->flags & PREFS_x) == 0)
	{
		p.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
#if GTK_CHECK_VERSION(3, 0, 0) && !GTK_CHECK_VERSION(3, 14, 0)
		gtk_window_set_has_resize_grip(GTK_WINDOW(p.window), FALSE);
#endif
		gtk_window_set_title(GTK_WINDOW(p.window), prefs->title != NULL
				? prefs->title : _("Progress"));
		g_signal_connect_swapped(p.window, "delete-event", G_CALLBACK(
					_progress_closex), p.window);
	}
	else
	{
		p.window = gtk_plug_new(0);
		g_signal_connect_swapped(p.window, "embedded", G_CALLBACK(
					_progress_embedded), &p);
	}
#if GTK_CHECK_VERSION(3, 0, 0)
	vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
	hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
#else
	vbox = gtk_vbox_new(FALSE, 0);
	hbox = gtk_hbox_new(FALSE, 0);
#endif
	left = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
	right = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
	/* file */
	widget = gtk_label_new(_("File: "));
	bold = pango_font_description_new();
	pango_font_description_set_weight(bold, PANGO_WEIGHT_BOLD);
#if GTK_CHECK_VERSION(3, 0, 0)
	gtk_widget_override_font(widget, bold);
	g_object_set(widget, "halign", GTK_ALIGN_START, NULL);
#else
	gtk_widget_modify_font(widget, bold);
	gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
#endif
	gtk_size_group_add_widget(left, widget);
	gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0);
	if((q = g_filename_to_utf8(prefs->filename, -1, NULL, NULL, NULL))
			== NULL)
		q = prefs->filename;
	widget = gtk_label_new(q);
	gtk_label_set_ellipsize(GTK_LABEL(widget), PANGO_ELLIPSIZE_MIDDLE);
#if GTK_CHECK_VERSION(3, 0, 0)
	g_object_set(widget, "halign", GTK_ALIGN_START, NULL);
#else
	gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
#endif
	gtk_size_group_add_widget(right, widget);
	gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
	/* done */
#if GTK_CHECK_VERSION(3, 0, 0)
	hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
#else
	hbox = gtk_hbox_new(FALSE, 0);
#endif
	widget = gtk_label_new(_("Done: "));
#if GTK_CHECK_VERSION(3, 0, 0)
	gtk_widget_override_font(widget, bold);
	g_object_set(widget, "halign", GTK_ALIGN_START, NULL);
#else
	gtk_widget_modify_font(widget, bold);
	gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
#endif
	gtk_size_group_add_widget(left, widget);
	gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0);
	p.done = gtk_label_new(_("0.0 kB"));
#if GTK_CHECK_VERSION(3, 0, 0)
	g_object_set(p.done, "halign", GTK_ALIGN_START, NULL);
#else
	gtk_misc_set_alignment(GTK_MISC(p.done), 0.0, 0.5);
#endif
	gtk_size_group_add_widget(right, p.done);
	gtk_box_pack_start(GTK_BOX(hbox), p.done, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 4);
	/* remaining */
#if GTK_CHECK_VERSION(3, 0, 0)
	hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
#else
	hbox = gtk_hbox_new(FALSE, 0);
#endif
	widget = gtk_label_new(_("Remaining: "));
#if GTK_CHECK_VERSION(3, 0, 0)
	gtk_widget_override_font(widget, bold);
	g_object_set(widget, "halign", GTK_ALIGN_START, NULL);
#else
	gtk_widget_modify_font(widget, bold);
	gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
#endif
	gtk_size_group_add_widget(left, widget);
	gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0);
	p.remaining = gtk_label_new("");
	g_timeout_add(250, _progress_timeout, &p);
#if GTK_CHECK_VERSION(3, 0, 0)
	g_object_set(p.remaining, "halign", GTK_ALIGN_START, NULL);
#else
	gtk_misc_set_alignment(GTK_MISC(p.remaining), 0.0, 0.5);
#endif
	gtk_size_group_add_widget(right, p.remaining);
	gtk_box_pack_start(GTK_BOX(hbox), p.remaining, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 4);
	/* progress */
	p.progress = gtk_progress_bar_new();
	p.pulse = 0;
	if(prefs->prefix != NULL)
	{
#if GTK_CHECK_VERSION(3, 0, 0)
		hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
#else
		hbox = gtk_hbox_new(FALSE, 0);
#endif
		widget = gtk_label_new(prefs->prefix);
#if GTK_CHECK_VERSION(3, 0, 0)
		g_object_set(widget, "halign", GTK_ALIGN_START, NULL);
#else
		gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
#endif
		gtk_size_group_add_widget(left, widget);
		gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0);
		gtk_size_group_add_widget(right, p.progress);
		gtk_box_pack_start(GTK_BOX(hbox), p.progress, TRUE, TRUE, 0);
		gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 4);
	}
	else
		gtk_box_pack_start(GTK_BOX(vbox), p.progress, TRUE, TRUE, 4);
	/* cancel */
#if GTK_CHECK_VERSION(3, 0, 0)
	hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
#else
	hbox = gtk_hbox_new(FALSE, 0);
#endif
#if GTK_CHECK_VERSION(3, 10, 0)
	widget = gtk_button_new_with_label(_("Cancel"));
	gtk_button_set_image(GTK_BUTTON(widget),
			gtk_image_new_from_icon_name(GTK_STOCK_CANCEL,
				GTK_ICON_SIZE_BUTTON));
#else
	widget = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
#endif
	g_signal_connect(G_OBJECT(widget), "clicked", G_CALLBACK(
				_progress_cancel), NULL);
	gtk_box_pack_end(GTK_BOX(hbox), widget, FALSE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
	gtk_container_add(GTK_CONTAINER(p.window), vbox);
	gtk_container_set_border_width(GTK_CONTAINER(p.window), 4);
	gtk_widget_show_all(vbox);
	if((prefs->flags & PREFS_x) == 0)
		/* show the window */
		gtk_widget_show(p.window);
	else
	{
		/* print the window ID and force a flush */
		id = gtk_plug_get_id(GTK_PLUG(p.window));
		printf("%lu\n", id);
		fclose(stdout);
	}
	gtk_main();
	close(p.fd);
	close(p.fds[1]);
	return p.ret;
}