static void
logview_filter_manager_init (LogviewFilterManager *manager)
{
  GtkWidget *table;
  GtkWidget *scrolled_window;
  GtkTreeViewColumn *column;
  GtkCellRenderer *text_renderer;
  LogviewFilterManagerPrivate *priv;

  manager->priv = LOGVIEW_FILTER_MANAGER_GET_PRIVATE (manager);
  priv = manager->priv;

  priv->builder = gtk_builder_new ();
  g_object_ref (priv->builder);
  priv->prefs = logview_prefs_get ();

  gtk_dialog_add_button (GTK_DIALOG(manager),
                         GTK_STOCK_CLOSE,
                         GTK_RESPONSE_CLOSE);
  gtk_window_set_modal (GTK_WINDOW (manager),
                        TRUE);

  priv->model = GTK_TREE_MODEL (gtk_list_store_new (N_COLUMNS,
                                                    G_TYPE_STRING,
                                                    G_TYPE_OBJECT));
  logview_filter_manager_update_model (manager);

  table = gtk_table_new (3, 2, FALSE);
  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_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
                                       GTK_SHADOW_ETCHED_IN);
  priv->tree = gtk_tree_view_new_with_model (priv->model);
  gtk_widget_set_size_request (priv->tree, 150, 200);
  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->tree), FALSE);
  gtk_container_add (GTK_CONTAINER (scrolled_window), priv->tree);

  text_renderer = gtk_cell_renderer_text_new ();

  column = gtk_tree_view_column_new();
  gtk_tree_view_column_pack_start (column, text_renderer, TRUE);
  gtk_tree_view_column_set_attributes (column,
                                       text_renderer,
                                       "text", COLUMN_NAME,
                                       NULL);
  gtk_tree_view_append_column (GTK_TREE_VIEW (priv->tree),
                               column);

  priv->add_button = gtk_button_new_from_stock (GTK_STOCK_ADD);
  priv->edit_button = gtk_button_new_from_stock (GTK_STOCK_PROPERTIES);
  priv->remove_button = gtk_button_new_from_stock (GTK_STOCK_REMOVE);

  gtk_window_set_title (GTK_WINDOW (manager),
                        _("Filters"));

  g_signal_connect (priv->add_button, "clicked", 
                    G_CALLBACK (on_add_clicked), manager);
  g_signal_connect (priv->edit_button, "clicked", 
                    G_CALLBACK (on_edit_clicked), manager);
  g_signal_connect (priv->remove_button, "clicked", 
                    G_CALLBACK (on_remove_clicked), manager);

  gtk_widget_set_sensitive (priv->edit_button, FALSE);
  gtk_widget_set_sensitive (priv->remove_button, FALSE);

  g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree)),
                    "changed", G_CALLBACK (on_tree_selection_changed),
                    manager);

  gtk_table_attach_defaults (GTK_TABLE (table),
                             scrolled_window,
                             0, 1, 0, 3);
  gtk_table_attach (GTK_TABLE (table),
                    priv->add_button,
                    1, 2, 0, 1, GTK_FILL, 0, 5, 5);
  gtk_table_attach (GTK_TABLE (table),
                    priv->edit_button,
                    1, 2, 1, 2, GTK_FILL, 0, 5, 5);
  gtk_table_attach (GTK_TABLE (table),
                    priv->remove_button,
                    1, 2, 2, 3, GTK_FILL, 0, 5, 5);
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (manager))),
                      table, TRUE, TRUE, 5);
  gtk_widget_show_all (GTK_WIDGET (manager));
}
Esempio n. 2
0
void
DictMngr::CreateDictMngrDialog()
{
    GtkWidget *dialog, *selector;
    GtkCellRenderer *renderer;
    HildonTouchSelectorColumn *column;
    GtkTreeModel *tree_model;
    GtkTreeIter iter;
    gboolean iter_valid = TRUE;
    std::list < std::string > all_dict_list;
    std::list < std::string > selected_dict_list;
    GtkListStore *dict_list = NULL;
    const gint RESPONSE_REORDER = 1;
    gint response;

    dict_list = gtk_list_store_new(N_DICT_INFO_COLUMNS,
				   G_TYPE_STRING,	/* bookname */
				   G_TYPE_STRING);	/* filename */

    /* create dialog */
    dialog = gtk_dialog_new();
    gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
    gtk_window_set_title(GTK_WINDOW(dialog), _("Dictionaries"));
    gtk_dialog_add_button(GTK_DIALOG(dialog), _("Reorder"), RESPONSE_REORDER);
    gtk_dialog_add_button(GTK_DIALOG(dialog), "OK", GTK_RESPONSE_ACCEPT);
    gtk_window_set_default_size(GTK_WINDOW(dialog), -1, 400);

    /* dictionary selector */
    selector = hildon_touch_selector_new();
    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), selector);

    renderer = gtk_cell_renderer_text_new();
    g_object_set(G_OBJECT(renderer),
		 "xpad", 10,
		 "ellipsize", PANGO_ELLIPSIZE_END,
		 "ellipsize-set", TRUE,
		 NULL);

    column =
	hildon_touch_selector_append_column(HILDON_TOUCH_SELECTOR
					    (selector),
					    GTK_TREE_MODEL(dict_list),
					    renderer, "text", BOOKNAME_DICT_INFO_COLUMN, NULL);
    hildon_touch_selector_column_set_text_column(column, 0);

    /* fill list with all available dictionaries */
    GetAllDictionaryList(all_dict_list);
    for (std::list < std::string >::iterator i = all_dict_list.begin();
	 i != all_dict_list.end(); ++i) {
	DictInfo dictinfo;

	dictinfo.load_from_ifo_file(i->c_str(), 0);
	gtk_list_store_append(dict_list, &iter);
	gtk_list_store_set(dict_list, &iter,
			   BOOKNAME_DICT_INFO_COLUMN,
			   dictinfo.bookname.c_str(), FILENAME_DICT_INFO_COLUMN, i->c_str(), -1);
    }
    g_object_unref(dict_list);

    /* set selector mode to multiple */
    hildon_touch_selector_set_column_selection_mode(HILDON_TOUCH_SELECTOR
						    (selector),
						    HILDON_TOUCH_SELECTOR_SELECTION_MODE_MULTIPLE);
    hildon_touch_selector_unselect_all(HILDON_TOUCH_SELECTOR(selector), BOOKNAME_DICT_INFO_COLUMN);

    /* select all load dictionaries */
    tree_model =
	hildon_touch_selector_get_model(HILDON_TOUCH_SELECTOR(selector), BOOKNAME_DICT_INFO_COLUMN);
    for (iter_valid = gtk_tree_model_get_iter_first(tree_model, &iter);
	 iter_valid; iter_valid = gtk_tree_model_iter_next(tree_model, &iter)) {
	const gchar *bookname;

	gtk_tree_model_get(tree_model, &iter, BOOKNAME_DICT_INFO_COLUMN, &bookname, -1);
	for (size_t iLib = 0; iLib < oStarDict->oLibs->query_dictmask.size(); iLib++) {
	    if (!strcmp(oStarDict->oLibs->dict_name(iLib).c_str(), bookname)) {
		hildon_touch_selector_select_iter(HILDON_TOUCH_SELECTOR
						  (selector),
						  BOOKNAME_DICT_INFO_COLUMN, &iter, FALSE);
		break;
	    }
	}
    }

    /* show dialog */
    gtk_widget_show_all(GTK_WIDGET(dialog));

    /* run the dialog */
    response = gtk_dialog_run(GTK_DIALOG(dialog));
    if (response == GTK_RESPONSE_ACCEPT || response == RESPONSE_REORDER) {
	GList *selected_dicts = NULL;

	selected_dicts =
	    hildon_touch_selector_get_selected_rows(HILDON_TOUCH_SELECTOR
						    (selector), BOOKNAME_DICT_INFO_COLUMN);
	if (selected_dicts) {
	    GList *dict = selected_dicts;
	    const gchar *filename;

	    while (dict) {
		gtk_tree_model_get_iter(GTK_TREE_MODEL(tree_model), &iter,
					(GtkTreePath *) (dict->data));
		gtk_tree_model_get(GTK_TREE_MODEL(tree_model), &iter,
				   FILENAME_DICT_INFO_COLUMN, &filename, -1);
		selected_dict_list.push_back(std::string(filename));
		dict = dict->next;
	    }
	    g_list_foreach(selected_dicts, (GFunc) gtk_tree_path_free, NULL);
	    g_list_free(selected_dicts);
	}

	if (oStarDict->oConf->SetStringList("/apps/maemo/mstardict/dict_list", selected_dict_list)) {
	    /* reload dictionaries */
	    ReLoadDictionaries(selected_dict_list);
	}
    }
    gtk_widget_destroy(GTK_WIDGET(dialog));
    if (response == RESPONSE_REORDER) {
        CreateReorderDialog();
    }
}
Esempio n. 3
0
gint main(gint argc, gchar * argv[]){
  GtkWidget *colorseldlg;
  GdkColor color;
  GtkColorSelection *colorsel;
  gint response;
  gint r, g, b;
  guint16 alpha=65535;
  float f;

  self = argv[0];
  gtk_init(&argc, &argv);

  if(argc == 2){
    g = 0;
    b = 0;
    if(argv[1][0] == 'r'){
      if(argv[1][3] == 'a'){
	//rgba(...)
	sscanf(argv[1], "rgba(%d, %d, %d, %f)", &r, &g, &b, &f);
	color.red = r * 256;
	color.green = g * 256;
	color.blue = b * 256;
	alpha = f * 65535;
      }else if(argv[1][3] == '('){
	//rgb(...)
	sscanf(argv[1], "rgb(%d, %d, %d)", &r, &g, &b);
	color.red = r * 256;
	color.green = g * 256;
	color.blue = b * 256;
      }else{
	usage();
	return 2;
      }
      goto option_ok;
    }
    if(argv[1][0] == '#'){
      b = 1;
    }
    for(r=b; r<b+6; r++){
      if(!isxdigit(argv[1][r])){
	usage();
	return 2;
      }
    }
    if(b){
      /* # 开头 */
      argv[1] = (char*)((int)argv[1] + 1);
    }
    sscanf(argv[1], "%2x%2x%2x", &r, &g, &b);
    color.red = r * 256;
    color.green = g * 256;
    color.blue = b * 256;
  }else if(argc == 1){
    color.red = 0xffff;
    color.green = 0xffff;
    color.blue = 0xffff;
  }else{
    usage();
    return 2;
  }

option_ok:
  colorseldlg = gtk_color_selection_dialog_new("Select color");
  colorsel = GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(colorseldlg)->colorsel);
  gtk_color_selection_set_current_color(colorsel, &color);
  gtk_color_selection_set_has_palette(colorsel, TRUE);
  gtk_color_selection_set_has_opacity_control(colorsel, TRUE);
  gtk_color_selection_set_current_alpha(colorsel, alpha);
  gtk_window_set_position(GTK_WINDOW(colorseldlg), GTK_WIN_POS_MOUSE);
  gtk_window_set_keep_above(GTK_WINDOW(colorseldlg), TRUE);

  response = gtk_dialog_run(GTK_DIALOG(colorseldlg));
  if(response == GTK_RESPONSE_OK){
    gtk_color_selection_get_current_color(colorsel, &color);
    r = color.red / 256;
    g = color.green / 256;
    b = color.blue / 256;
    alpha = gtk_color_selection_get_current_alpha(colorsel);
    alpha /= 256;
    if(alpha == 255)
      printf("#%02x%02x%02x\n", r, g, b);
    else
      printf("rgba(%d, %d, %d, %.2f\n)", r, g, b, (float)alpha/256);
  }else
    /* 取消了 */
    return 1;

  return 0;
}
Esempio n. 4
0
static void delete_button_clicked(GtkButton *button, gpointer user_data)
{
    dt_lib_module_t *self = (dt_lib_module_t *)user_data;
    dt_lib_tagging_t *d = (dt_lib_tagging_t *)self->data;

    int res = GTK_RESPONSE_YES;

    guint tagid;
    GtkTreeIter iter;
    GtkTreeModel *model = NULL;
    GtkTreeView *view = d->related;
    GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
    if(!gtk_tree_selection_get_selected(selection, &model, &iter)) return;
    gtk_tree_model_get(model, &iter, DT_LIB_TAGGING_COL_ID, &tagid, -1);

    // First check how many images are affected by the remove
    int count = dt_tag_remove(tagid, FALSE);
    if(count > 0 && dt_conf_get_bool("plugins/lighttable/tagging/ask_before_delete_tag"))
    {
        GtkWidget *dialog;
        GtkWidget *win = dt_ui_main_window(darktable.gui->ui);
        gchar *tagname = dt_tag_get_name(tagid);
        dialog = gtk_message_dialog_new(
                     GTK_WINDOW(win), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
                     ngettext("do you really want to delete the tag `%s'?\n%d image is assigned this tag!",
                              "do you really want to delete the tag `%s'?\n%d images are assigned this tag!", count),
                     tagname, count);
        gtk_window_set_title(GTK_WINDOW(dialog), _("delete tag?"));
        res = gtk_dialog_run(GTK_DIALOG(dialog));
        gtk_widget_destroy(dialog);
        free(tagname);
    }
    if(res != GTK_RESPONSE_YES) return;

    GList *tagged_images = NULL;
    sqlite3_stmt *stmt;
    DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "select imgid from tagged_images where tagid=?1",
                                -1, &stmt, NULL);
    DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, tagid);
    while(sqlite3_step(stmt) == SQLITE_ROW)
    {
        tagged_images = g_list_append(tagged_images, GINT_TO_POINTER(sqlite3_column_int(stmt, 0)));
    }
    sqlite3_finalize(stmt);

    dt_tag_remove(tagid, TRUE);

    GList *list_iter;
    if((list_iter = g_list_first(tagged_images)) != NULL)
    {
        do
        {
            dt_image_synch_xmp(GPOINTER_TO_INT(list_iter->data));
        } while((list_iter = g_list_next(list_iter)) != NULL);
    }
    g_list_free(g_list_first(tagged_images));

    update(self, 0);
    update(self, 1);

    dt_control_signal_raise(darktable.signals, DT_SIGNAL_TAG_CHANGED);
}
Esempio n. 5
0
// sets up the file chooser dialog
static void create_file_chooser_dialog()
{
    GtkWidget *parent = get_widget_checked("ssv_main_window");

    browse_widget = gtk_file_chooser_dialog_new(
        "Open Image File", GTK_WINDOW(parent),
        GTK_FILE_CHOOSER_ACTION_OPEN,
        GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, //Cancel button
        GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,   //Open button
        NULL);

    // we need to extract the buttons, so we can connect them to our
    // button handlers, above
    GtkHButtonBox *box =
        (GtkHButtonBox*)(((GtkDialog*)browse_widget)->action_area);
    GList *buttons = box->button_box.box.children;

    GtkWidget *cancel_btn = ((GtkBoxChild*)buttons->data)->widget;
    GtkWidget *ok_btn = ((GtkBoxChild*)buttons->next->data)->widget;

    g_signal_connect((gpointer)cancel_btn, "clicked",
        G_CALLBACK(new_cancel_clicked), NULL);
    g_signal_connect((gpointer)ok_btn, "clicked",
        G_CALLBACK(new_ok_clicked), NULL);
    g_signal_connect(browse_widget, "destroy",
        G_CALLBACK(browse_widget_destroy), NULL);
    g_signal_connect(browse_widget, "destroy_event",
        G_CALLBACK(browse_widget_destroy), NULL);
    g_signal_connect(browse_widget, "delete_event",
        G_CALLBACK(browse_widget_destroy), NULL);

    // add the filters
    GtkFileFilter *D_filt = gtk_file_filter_new();
    gtk_file_filter_set_name(D_filt, "CEOS Data Files (*.D)");
    gtk_file_filter_add_pattern(D_filt, "*.D");
    gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(browse_widget), D_filt);

    GtkFileFilter *alos2_filt = gtk_file_filter_new();
    gtk_file_filter_set_name(alos2_filt, "ALOS Image Files (IMG-*)");
    gtk_file_filter_add_pattern(alos2_filt, "IMG-*");
    gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(browse_widget), alos2_filt);

    GtkFileFilter *img_filt = gtk_file_filter_new();
    gtk_file_filter_set_name(img_filt, "ASF Internal Files (*.img)");
    gtk_file_filter_add_pattern(img_filt, "*.img");
    gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(browse_widget), img_filt);

    GtkFileFilter *airsar_filt = gtk_file_filter_new();
    gtk_file_filter_set_name(airsar_filt, "AirSAR Files");
    gtk_file_filter_add_pattern(airsar_filt, "*.vvi2");
    gtk_file_filter_add_pattern(airsar_filt, "*.demi2");
    gtk_file_filter_add_pattern(airsar_filt, "*.corgr");
    gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(browse_widget), airsar_filt);

    GtkFileFilter *tiff_filt = gtk_file_filter_new();
    gtk_file_filter_set_name(tiff_filt, "GeoTIFF Image Files (*.tif)");
    gtk_file_filter_add_pattern(tiff_filt, "*.tif");
    gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(browse_widget), tiff_filt);

    GtkFileFilter *tsx_filt = gtk_file_filter_new();
    gtk_file_filter_set_name(tsx_filt, "TerraSAR-X Files (*.xml)");
    gtk_file_filter_add_pattern(tsx_filt, "*.xml");
    gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(browse_widget), tsx_filt);

    GtkFileFilter *jpg_filt = gtk_file_filter_new();
    gtk_file_filter_set_name(jpg_filt, "JPEG Image Files (*.jpg)");
    gtk_file_filter_add_pattern(jpg_filt, "*.jpg");
    gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(browse_widget), jpg_filt);

    GtkFileFilter *png_filt = gtk_file_filter_new();
    gtk_file_filter_set_name(png_filt, "PNG Image Files (*.png)");
    gtk_file_filter_add_pattern(png_filt, "*.png");
    gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(browse_widget), png_filt);

    GtkFileFilter *pgm_filt = gtk_file_filter_new();
    gtk_file_filter_set_name(pgm_filt, "PGM Image Files (*.pgm)");
    gtk_file_filter_add_pattern(pgm_filt, "*.pgm");
    gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(browse_widget), pgm_filt);

    GtkFileFilter *envi_filt = gtk_file_filter_new();
    gtk_file_filter_set_name(envi_filt, "ENVI Files (*.hdr)");
    gtk_file_filter_add_pattern(envi_filt, "*.hdr");
    gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(browse_widget), envi_filt);

    GtkFileFilter *roipac_filt = gtk_file_filter_new();
    gtk_file_filter_set_name(roipac_filt, "ROI_PAC Files (*.rsc)");
    gtk_file_filter_add_pattern(roipac_filt, "*.rsc");
    gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(browse_widget), roipac_filt);

    //GtkFileFilter *ppm_filt = gtk_file_filter_new();
    //gtk_file_filter_set_name(ppm_filt, "PPM Image Files (*.ppm)");
    //gtk_file_filter_add_pattern(ppm_filt, "*.ppm");
    //gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(browse_widget), ppm_filt);

    GtkFileFilter *all_filt = gtk_file_filter_new();
    gtk_file_filter_set_name(all_filt, "All Files (*.*)");
    gtk_file_filter_add_pattern(all_filt, "*");
    gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(browse_widget), all_filt);

    // allow multi-select
    gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(browse_widget), TRUE);

    // we need to make these modal -- if the user opens multiple "open"
    // dialogs, we'll get confused on the callbacks
    gtk_window_set_modal(GTK_WINDOW(browse_widget), TRUE);
    gtk_window_set_destroy_with_parent(GTK_WINDOW(browse_widget), TRUE);
    gtk_dialog_set_default_response(GTK_DIALOG(browse_widget),
                                    GTK_RESPONSE_OK);
}
GtkWidget *create_dialog1 (void)
{
  GtkWidget *dialog1;
  GtkWidget *dialog_vbox1;
  GtkWidget *table1;
  GtkWidget *label1;
  GtkWidget *label2;
  GtkWidget *label3;
  GtkWidget *label4;
  GtkWidget *label5;
  GtkWidget *label6;
  GtkWidget *label7;
  GtkWidget *label8;
  GtkObject *spinbuttonTreshold_adj;
  GtkWidget *spinbuttonTreshold;
  GtkObject *spinbuttonNoise_adj;
  GtkWidget *spinbuttonNoise;
  GtkObject *spinbuttonIdentical_adj;
  GtkWidget *spinbuttonIdentical;
  GtkWidget *checkbuttonShow;
  GtkWidget *dialog_action_area1;
  GtkWidget *cancelbutton1;
  GtkWidget *okbutton1;
  GtkTooltips *tooltips;

  tooltips = gtk_tooltips_new ();

  dialog1 = gtk_dialog_new ();
  gtk_window_set_title (GTK_WINDOW (dialog1), _("Blend removal / Hard pulldown removal"));
  gtk_window_set_type_hint (GTK_WINDOW (dialog1), GDK_WINDOW_TYPE_HINT_DIALOG);

  dialog_vbox1 = GTK_DIALOG (dialog1)->vbox;
  gtk_widget_show (dialog_vbox1);

  table1 = gtk_table_new (4, 3, FALSE);
  gtk_widget_show (table1);
  gtk_box_pack_start (GTK_BOX (dialog_vbox1), table1, TRUE, TRUE, 0);

  label1 = gtk_label_new (_("%"));
  gtk_widget_show (label1);
  gtk_table_attach (GTK_TABLE (table1), label1, 2, 3, 0, 1,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label1), 0, 0.5);

  label2 = gtk_label_new (_("%"));
  gtk_widget_show (label2);
  gtk_table_attach (GTK_TABLE (table1), label2, 2, 3, 1, 2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label2), 0, 0.5);

  label3 = gtk_label_new (_("%"));
  gtk_widget_show (label3);
  gtk_table_attach (GTK_TABLE (table1), label3, 2, 3, 2, 3,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label3), 0, 0.5);

  label4 = gtk_label_new (_(" "));
  gtk_widget_show (label4);
  gtk_table_attach (GTK_TABLE (table1), label4, 2, 3, 3, 4,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label4), 0, 0.5);

  label5 = gtk_label_new (_("Threshold :"));
  gtk_widget_show (label5);
  gtk_table_attach (GTK_TABLE (table1), label5, 0, 1, 0, 1,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label5), 0, 0.5);

  label6 = gtk_label_new (_("Noise threshold :"));
  gtk_widget_show (label6);
  gtk_table_attach (GTK_TABLE (table1), label6, 0, 1, 1, 2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label6), 0, 0.5);

  label7 = gtk_label_new (_("Identical threshold :"));
  gtk_widget_show (label7);
  gtk_table_attach (GTK_TABLE (table1), label7, 0, 1, 2, 3,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label7), 0, 0.5);

  label8 = gtk_label_new (_("Show metrics"));
  gtk_widget_show (label8);
  gtk_table_attach (GTK_TABLE (table1), label8, 0, 1, 3, 4,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label8), 0, 0.5);

  spinbuttonTreshold_adj = gtk_adjustment_new (1, 1, 99, 1, 10, 10);
  spinbuttonTreshold = gtk_spin_button_new (GTK_ADJUSTMENT (spinbuttonTreshold_adj), 1, 0);
  gtk_widget_show (spinbuttonTreshold);
  gtk_table_attach (GTK_TABLE (table1), spinbuttonTreshold, 1, 2, 0, 1,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_tooltips_set_tip (tooltips, spinbuttonTreshold, _("If the image is closer than treshold, is it considered valid, smaller means more false detection"), NULL);
  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbuttonTreshold), TRUE);

  spinbuttonNoise_adj = gtk_adjustment_new (1, 1, 99, 1, 10, 10);
  spinbuttonNoise = gtk_spin_button_new (GTK_ADJUSTMENT (spinbuttonNoise_adj), 1, 0);
  gtk_widget_show (spinbuttonNoise);
  gtk_table_attach (GTK_TABLE (table1), spinbuttonNoise, 1, 2, 1, 2,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_tooltips_set_tip (tooltips, spinbuttonNoise, _("If pixels are closer than noise threshold, they are considered identical"), NULL);
  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbuttonNoise), TRUE);

  spinbuttonIdentical_adj = gtk_adjustment_new (1, 1, 99, 1, 10, 10);
  spinbuttonIdentical = gtk_spin_button_new (GTK_ADJUSTMENT (spinbuttonIdentical_adj), 1, 0);
  gtk_widget_show (spinbuttonIdentical);
  gtk_table_attach (GTK_TABLE (table1), spinbuttonIdentical, 1, 2, 2, 3,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_tooltips_set_tip (tooltips, spinbuttonIdentical, _("If the picture are less than identical threshold, they are considered identical"), NULL);
  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbuttonIdentical), TRUE);

  checkbuttonShow = gtk_check_button_new_with_mnemonic ("");
  gtk_widget_show (checkbuttonShow);
  gtk_table_attach (GTK_TABLE (table1), checkbuttonShow, 1, 2, 3, 4,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_tooltips_set_tip (tooltips, checkbuttonShow, _("Show metrics in picture (debug only)"), NULL);

  dialog_action_area1 = GTK_DIALOG (dialog1)->action_area;
  gtk_widget_show (dialog_action_area1);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);

  cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel");
  gtk_widget_show (cancelbutton1);
  gtk_dialog_add_action_widget (GTK_DIALOG (dialog1), cancelbutton1, GTK_RESPONSE_CANCEL);
  GTK_WIDGET_SET_FLAGS (cancelbutton1, GTK_CAN_DEFAULT);

  okbutton1 = gtk_button_new_from_stock ("gtk-ok");
  gtk_widget_show (okbutton1);
  gtk_dialog_add_action_widget (GTK_DIALOG (dialog1), okbutton1, GTK_RESPONSE_OK);
  GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (dialog1, dialog1, "dialog1");
  GLADE_HOOKUP_OBJECT_NO_REF (dialog1, dialog_vbox1, "dialog_vbox1");
  GLADE_HOOKUP_OBJECT (dialog1, table1, "table1");
  GLADE_HOOKUP_OBJECT (dialog1, label1, "label1");
  GLADE_HOOKUP_OBJECT (dialog1, label2, "label2");
  GLADE_HOOKUP_OBJECT (dialog1, label3, "label3");
  GLADE_HOOKUP_OBJECT (dialog1, label4, "label4");
  GLADE_HOOKUP_OBJECT (dialog1, label5, "label5");
  GLADE_HOOKUP_OBJECT (dialog1, label6, "label6");
  GLADE_HOOKUP_OBJECT (dialog1, label7, "label7");
  GLADE_HOOKUP_OBJECT (dialog1, label8, "label8");
  GLADE_HOOKUP_OBJECT (dialog1, spinbuttonTreshold, "spinbuttonTreshold");
  GLADE_HOOKUP_OBJECT (dialog1, spinbuttonNoise, "spinbuttonNoise");
  GLADE_HOOKUP_OBJECT (dialog1, spinbuttonIdentical, "spinbuttonIdentical");
  GLADE_HOOKUP_OBJECT (dialog1, checkbuttonShow, "checkbuttonShow");
  GLADE_HOOKUP_OBJECT_NO_REF (dialog1, dialog_action_area1, "dialog_action_area1");
  GLADE_HOOKUP_OBJECT (dialog1, cancelbutton1, "cancelbutton1");
  GLADE_HOOKUP_OBJECT (dialog1, okbutton1, "okbutton1");
  GLADE_HOOKUP_OBJECT_NO_REF (dialog1, tooltips, "tooltips");

  return dialog1;
}
static SCM
gnc_style_sheet_new (StyleSheetDialog * ssd)
{
    SCM              make_ss   = scm_c_eval_string("gnc:make-html-style-sheet");
    SCM              templates = scm_c_eval_string("(gnc:get-html-templates)");
    SCM              t_name = scm_c_eval_string("gnc:html-style-sheet-template-name");
    SCM              new_ss = SCM_BOOL_F;
    GtkWidget        * template_combo;
    GtkTreeModel     * template_model;
    GtkWidget        * name_entry;
    gint             dialog_retval;
    GList *template_names = NULL;

    /* get the new name for the style sheet */
    GladeXML *xml = gnc_glade_xml_new ("report.glade",
                                       "New Style Sheet Dialog");
    GtkWidget * dlg = glade_xml_get_widget (xml, "New Style Sheet Dialog");
    template_combo = glade_xml_get_widget (xml, "template_combobox");
    name_entry     = glade_xml_get_widget (xml, "name_entry");

    g_assert(ssd);

    /* Erase the initial dummy entry. */
    template_model = gtk_combo_box_get_model(GTK_COMBO_BOX(template_combo));
    gtk_list_store_clear(GTK_LIST_STORE(template_model));

    /* put in the list of style sheet type names */
    for (; !scm_is_null(templates); templates = SCM_CDR(templates))
    {
        char * str;
        const char* orig_name;

        SCM t = SCM_CAR(templates);
        scm_dynwind_begin (0); 
        str = scm_to_locale_string (scm_call_1(t_name, t));
        orig_name = g_strdup (str);
        scm_dynwind_free (str); 
        scm_dynwind_end (); 

        /* Store the untranslated names for lookup later */
        template_names = g_list_prepend (template_names, (gpointer)orig_name);

        /* The displayed name should be translated */
        gtk_combo_box_prepend_text(GTK_COMBO_BOX(template_combo),
                                   _(orig_name));
    }
    gtk_combo_box_set_active(GTK_COMBO_BOX(template_combo), 0);

    /* get the name */
    gtk_window_set_transient_for (GTK_WINDOW(dlg), GTK_WINDOW(ssd->toplevel));
    dialog_retval = gtk_dialog_run(GTK_DIALOG(dlg));

    if (dialog_retval == GTK_RESPONSE_OK)
    {
        gint choice = gtk_combo_box_get_active (GTK_COMBO_BOX(template_combo));
        const char *template_str = g_list_nth_data (template_names, choice);
        const char *name_str     = gtk_entry_get_text(GTK_ENTRY(name_entry));
        if (name_str && strlen(name_str) == 0)
        {
            /* If the name is empty, we display an error dialog but
             * refuse to create the new style sheet. */
            gnc_error_dialog (ssd->toplevel, "%s", _("You must provide a name for the new style sheet."));
            name_str = NULL;
        }
        if (template_str && name_str)
        {
            new_ss = scm_call_2(make_ss,
                                scm_makfrom0str(template_str),
                                scm_makfrom0str(name_str));
        }
    }

    g_list_free (template_names);
    gtk_widget_destroy(dlg);
    return(new_ss);
}
Esempio n. 8
0
int main( int   argc, char *argv[] )
{

	#ifdef	__HYPHYMPI__
		  int 		   rank, 
		  			   size;
		  			   			   			 
		  MPI_Init	   (&argc, &argv);
		  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
		  MPI_Comm_size(MPI_COMM_WORLD, &size);
		  
		  _hy_mpi_node_rank = rank;
		  
		  setParameter  (mpiNodeID, (_Parameter)rank);
		  setParameter	(mpiNodeCount, (_Parameter)size);
		  
		  if (rank == 0)
	#endif
   
	gtk_init (&argc, &argv);

	/* set up globals */
	
	char curWd[4096];
	getcwd (curWd,4096);

	_String baseDir (curWd);
	baseDir=baseDir&'/';

	pathNames&& &baseDir;
	baseDirectory = baseDir;
	for (long i=1; i<argc;i++)
	{
		_String thisArg (argv[i]);
		if (thisArg.beginswith ("BASEPATH="))
		{
			baseDirectory = thisArg.Cut(9,-1);
			if (baseDirectory.sLength)
			{
				if (baseDirectory.sData[baseDirectory.sLength-1]!='/')
					baseDirectory = baseDirectory&"/";
			}
		}
		else
			if (thisArg.beginswith ("USEPATH="))
			{
				_String		baseArgDir 			(thisArg,8,-1);
				errorFileName					= baseArgDir & errorFileName;
				messageFileName					= baseArgDir & messageFileName;
				pathNames.Delete				(0);
				pathNames&&						&baseDir;
			}
			else
				if (thisArg.beginswith ("CPU="))
				{
					#ifdef __MP__
					_String cpus = thisArg.Cut(4,-1);
					systemCPUCount = cpus.toNum();
					if (systemCPUCount<1)
						systemCPUCount = 1;
					#ifdef __MP2__
						pthread_setconcurrency (systemCPUCount+1);
					#endif
					#endif
				}
				#ifdef	__HYPHYMPI__
					else
						if (thisArg == _String("MPIOPTIMIZER"))
						{
							mpiParallelOptimizer = true;
							setParameter	(mpiNodeCount, 0.0);
						}
						else
							if (thisArg == _String("MPIPARTITIONS"))
							{
								mpiPartitionOptimizer = true;
								setParameter	(mpiNodeCount, 0.0);
							}
				#endif
	}
	
	#ifdef	__HYPHYMPI__
	if (rank == 0)
	#endif
	{
		baseDir = baseDirectory & "GTKResources";
		_List scanRes;
		ScanDirectoryForFileNames(baseDir,scanRes,false);
		if (scanRes.lLength == 0)
		{
			GtkWidget * noRez = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "HYPHY_GTK was unable to find a required GTKResources directory in %s. Please use BASEPATH= command line option to specify where the installation directory of HyPhy can be found.", baseDirectory.sData);
			gtk_dialog_run (GTK_DIALOG (noRez));
			gtk_widget_destroy (noRez);
			return 1;
		}
		_String rcPath = baseDir & "/theme/theme.rc";
		//printf ("Loading res files from %s\n", rcPath.sData);
		gtk_rc_parse (rcPath.sData);
	}
	
 	GlobalStartup();

	#ifdef	__HYPHYMPI__
	if (rank == 0)
	{
	#endif
	GdkDisplay * defDisplay = gdk_screen_get_display (gdk_screen_get_default());
	hSizeCursor = gdk_cursor_new_for_display (defDisplay,GDK_SB_H_DOUBLE_ARROW);
	pickUpCursor = gdk_cursor_new_for_display (defDisplay,GDK_TARGET);
	dropOffCursor = gdk_cursor_new_for_display (defDisplay,GDK_TCROSS);
	
	screenPContext = gdk_pango_context_get_for_screen (gdk_screen_get_default());
	tablePDMenuIcon = (GdkPixbuf*)ProcureIconResource(4020);
		
	/*{
		GdkScreen * defD = gdk_screen_get_default();
		fontConversionFactor = 72.27 / (gdk_screen_get_height (defD) *25.4 / gdk_screen_get_height_mm(defD)); 
		printf ("Pango conversion factor computed at: %g\n", fontConversionFactor);
	}*/

		
	ReadInTemplateFiles ();
		
	hyphyConsoleWindow = new _HYConsoleWindow ("HYPHY Console");
	ReadPreferences		();
	SetStatusLine ("None","Idle","00:00:00");
	while (gtk_events_pending())
		gtk_main_iteration();

	SetPreferences		();
	ReadGeneticCodes	();	
	ReadModelTemplates	();
	ReadTreeProcessors ();
	MoveConsoleWindow  (consolePositionRectangle);
	StringToConsole (hyphyCiteString);
	hyphyConsoleWindow->BringToFront();

	#ifdef __HYPHYMPI__ 
	{
		char statBuffer[1024];
		sprintf (statBuffer,"MPI version of HyPhy running on %d nodes (a master and %d compute nodes) in %s mode\n",
							 size, 
							 size-1,
							 mpiPartitionOptimizer?"partition":(mpiParallelOptimizer?"rate heterogeneity":"normal"));
		BufferToConsole (statBuffer);
	}
	#endif
		
	g_timeout_add  (100,GlobalQueueTimer,nil);
	g_timeout_add  (1000,progressTimerFunction,nil);
	gtk_main ();

	WritePreferences();
	#ifdef	__HYPHYMPI__
	}
	else // slave node
	{
		if (mpiParallelOptimizer || mpiPartitionOptimizer)
			mpiOptimizerLoop (rank, size);
		else
			mpiNormalLoop (rank, size, baseDir);
	}
	#endif

	GlobalShutdown();
    return 0;
}
static void
ppg_add_instrument_dialog_init (PpgAddInstrumentDialog *dialog)
{
	PpgAddInstrumentDialogPrivate *priv;
	GtkWidget *content_area;
	GtkWidget *vbox;
	GtkWidget *hbox;
	GtkWidget *l;
	GtkWidget *scroller;

	priv = G_TYPE_INSTANCE_GET_PRIVATE(dialog, PPG_TYPE_ADD_INSTRUMENT_DIALOG,
	                                   PpgAddInstrumentDialogPrivate);
	dialog->priv = priv;

	g_object_set(dialog,
	             "border-width", 6,
	             "default-width", 350,
	             "default-height", 400,
#if !GTK_CHECK_VERSION(2, 91, 0)
	             "has-separator", FALSE,
#endif
	             "title", _("Add Instrument"),
	             NULL);

	content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));

	vbox = g_object_new(GTK_TYPE_VBOX,
	                    "border-width", 6,
	                    "spacing", 12,
	                    "visible", TRUE,
	                    NULL);
	gtk_container_add(GTK_CONTAINER(content_area), vbox);

	l = g_object_new(GTK_TYPE_LABEL,
	                 "justify", GTK_JUSTIFY_CENTER,
	                 "label", _("Choose one or more instruments to\n"
	                            "add to your session."),
	                 "visible", TRUE,
	                 "wrap", TRUE,
	                 NULL);
	gtk_container_add_with_properties(GTK_CONTAINER(vbox), l,
	                                  "expand", FALSE,
	                                  NULL);

	hbox = g_object_new(GTK_TYPE_HBOX,
	                    "spacing", 12,
	                    "visible", TRUE,
	                    NULL);
	gtk_container_add_with_properties(GTK_CONTAINER(vbox), hbox,
	                                  "expand", FALSE,
	                                  NULL);

	priv->entry = g_object_new(GTK_TYPE_ENTRY,
	                           "activates-default", TRUE,
	                           "visible", TRUE,
	                           NULL);
	gtk_container_add_with_properties(GTK_CONTAINER(hbox), priv->entry,
	                                  "position", 1,
	                                  NULL);
	g_signal_connect(priv->entry,
	                 "changed",
	                 G_CALLBACK(ppg_add_instrument_dialog_entry_changed),
	                 dialog);

	l = g_object_new(GTK_TYPE_LABEL,
	                 "label", _("_Search:"),
	                 "mnemonic-widget", priv->entry,
	                 "use-underline", TRUE,
	                 "visible", TRUE,
	                 NULL);
	gtk_container_add_with_properties(GTK_CONTAINER(hbox), l,
	                                  "expand", FALSE,
	                                  "position", 0,
	                                  NULL);

	scroller = g_object_new(GTK_TYPE_SCROLLED_WINDOW,
	                        "hscrollbar-policy", GTK_POLICY_AUTOMATIC,
	                        "shadow-type", GTK_SHADOW_IN,
	                        "visible", TRUE,
	                        "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
	                        NULL);
	gtk_container_add(GTK_CONTAINER(vbox), scroller);

	priv->model = ppg_instruments_store_new();
	priv->filter = g_object_new(GTK_TYPE_TREE_MODEL_FILTER,
	                            "child-model", priv->model,
	                            NULL);
	gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(priv->filter),
	                                       ppg_add_instrument_dialog_filter_func,
	                                       dialog, NULL);

	priv->icon_view = g_object_new(GTK_TYPE_ICON_VIEW,
	                               "model", priv->filter,
	                               "pixbuf-column", PPG_INSTRUMENTS_STORE_COLUMN_PIXBUF,
	                               "visible", TRUE,
	                               "text-column", PPG_INSTRUMENTS_STORE_COLUMN_TITLE,
	                               NULL);
	gtk_container_add(GTK_CONTAINER(scroller), priv->icon_view);
	g_signal_connect(priv->icon_view,
	                 "selection-changed",
	                 G_CALLBACK(ppg_add_instrument_dialog_selection_changed),
	                 dialog);
	g_signal_connect(priv->icon_view,
	                 "item-activated",
	                 G_CALLBACK(ppg_add_instrument_dialog_item_activated),
	                 dialog);

	gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CLOSE,
	                      GTK_RESPONSE_CLOSE);
	priv->add_button = gtk_dialog_add_button(GTK_DIALOG(dialog),
	                                         GTK_STOCK_ADD,
	                                         GTK_RESPONSE_OK);
	gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);

	g_object_set(priv->add_button, "sensitive", FALSE, NULL);

	g_signal_connect(dialog,
	                 "response",
	                 G_CALLBACK(ppg_add_instrument_dialog_response),
	                 NULL);
}
Esempio n. 10
0
/**
 * Shows a dialog to edit the given connection (or create a new one,
 * if conn is NULL)
 */
static void
edit_connection (gpointer *parent, StrongswanConnection *conn)
{
	GtkWidget *dialog;
	dialog = gtk_dialog_new_with_buttons (
							conn ? "Edit Connection" : "New Connection",
							GTK_WINDOW (parent),
							GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR,
							GTK_STOCK_CANCEL,
							GTK_RESPONSE_CANCEL,
							GTK_STOCK_SAVE,
							GTK_RESPONSE_OK,
							NULL);
	GtkWidget *vbox = GTK_DIALOG (dialog)->vbox;
	GtkSizeGroup *group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);

	GtkWidget *name = hildon_entry_new (HILDON_SIZE_AUTO);
	hildon_gtk_entry_set_placeholder_text (GTK_ENTRY (name), "Connection Name");
	hildon_gtk_entry_set_input_mode (GTK_ENTRY (name),
									 HILDON_GTK_INPUT_MODE_AUTOCAP |
									 HILDON_GTK_INPUT_MODE_ALPHA |
									 HILDON_GTK_INPUT_MODE_NUMERIC);
	GtkWidget *ncap = hildon_caption_new (group,
										  "Name",
										  name,
										  NULL,
										  HILDON_CAPTION_OPTIONAL);
	gtk_box_pack_start (GTK_BOX (vbox), ncap, TRUE, TRUE, 0);

	GtkWidget *host = hildon_entry_new (HILDON_SIZE_AUTO);
	hildon_gtk_entry_set_placeholder_text (GTK_ENTRY (host), "Hostname / IP");
	hildon_gtk_entry_set_input_mode (GTK_ENTRY (host),
									 HILDON_GTK_INPUT_MODE_FULL);
	GtkWidget *hcap = hildon_caption_new (group,
										  "Host",
										  host,
										  NULL,
										  HILDON_CAPTION_OPTIONAL);
	gtk_box_pack_start (GTK_BOX (vbox), hcap, TRUE, TRUE, 0);

	GtkWidget *cert = hildon_button_new (HILDON_SIZE_FINGER_HEIGHT |
										 HILDON_SIZE_AUTO_WIDTH,
										 HILDON_BUTTON_ARRANGEMENT_VERTICAL);
	hildon_button_set_text (HILDON_BUTTON (cert),
							"Host or CA Certificate",
							"None");
	hildon_button_set_alignment (HILDON_BUTTON (cert), 0, 0.5, 1, 1);
	g_signal_connect (cert, "clicked", G_CALLBACK (select_cert), dialog);
	GtkWidget *ccap = hildon_caption_new (group,
										  "Certificate",
										  cert,
										  NULL,
										  HILDON_CAPTION_OPTIONAL);
	gtk_box_pack_start (GTK_BOX (vbox), ccap, TRUE, TRUE, 0);

	GtkWidget *user = hildon_entry_new (HILDON_SIZE_AUTO);
	hildon_gtk_entry_set_placeholder_text (GTK_ENTRY (user), "Username");
	hildon_gtk_entry_set_input_mode (GTK_ENTRY (user),
									 HILDON_GTK_INPUT_MODE_FULL);
	GtkWidget *ucap = hildon_caption_new (group,
										  "Username",
										  user,
										  NULL,
										  HILDON_CAPTION_OPTIONAL);
	gtk_box_pack_start (GTK_BOX (vbox), ucap, TRUE, TRUE, 0);

	if (conn)
	{
		gchar *c_name, *c_host, *c_cert, *c_user;
		g_object_get (conn,
					  "name", &c_name,
					  "host", &c_host,
					  "cert", &c_cert,
					  "user", &c_user,
					  NULL);
		gtk_entry_set_text (GTK_ENTRY (name), c_name);
		gtk_entry_set_text (GTK_ENTRY (host), c_host);
		hildon_button_set_value (HILDON_BUTTON (cert),
								 c_cert ? c_cert : "None");
		gtk_entry_set_text (GTK_ENTRY (user), c_user);
		g_free (c_name);
		g_free (c_host);
		g_free (c_cert);
		g_free (c_user);
	}

	gtk_widget_show_all (dialog);

	gint retval = gtk_dialog_run (GTK_DIALOG (dialog));
	if (retval == GTK_RESPONSE_OK)
	{
		const gchar *c_name, *c_cert;
		c_name = gtk_entry_get_text (GTK_ENTRY (name));
		if (!conn)
		{
			conn = strongswan_connection_new (c_name);
		}
		c_cert = hildon_button_get_value (HILDON_BUTTON (cert));
		c_cert = strcmp (c_cert, "None") ? c_cert : NULL;
		g_object_set (conn,
					  "name", c_name,
					  "host", gtk_entry_get_text (GTK_ENTRY (host)),
					  "cert", c_cert,
					  "user", gtk_entry_get_text (GTK_ENTRY (user)),
					  NULL);
		strongswan_connections_save_connection (ListDialog.conns, conn);
	}
	gtk_widget_destroy (dialog);
}
Esempio n. 11
0
void
prop_cb (GtkAction    *action,
				 ProgressData *battstat)
{
  GtkBuilder *builder;
  GtkWidget *combo_ptr, *spin_ptr;
  GtkListStore *liststore;
  GtkCellRenderer *renderer;
  GtkTreeIter iter;

  if (DEBUG) g_print("prop_cb()\n");

   if (battstat->prop_win) { 
     gtk_window_set_screen (GTK_WINDOW (battstat->prop_win),
			    gtk_widget_get_screen (battstat->applet));
     gtk_window_present (GTK_WINDOW (battstat->prop_win));
     return;
   } 

  builder = gtk_builder_new ();
  gtk_builder_add_from_file (builder, GTK_BUILDERDIR"/battstat_applet.ui", NULL);

  battstat->prop_win = GTK_DIALOG (gtk_builder_get_object (builder, 
  				   "battstat_properties"));
  gtk_window_set_screen (GTK_WINDOW (battstat->prop_win),
			 gtk_widget_get_screen (battstat->applet));

  g_signal_connect (G_OBJECT (battstat->prop_win), "delete_event",
		  G_CALLBACK (gtk_true), NULL);
  
  battstat->lowbatt_toggle = GTK_WIDGET (gtk_builder_get_object (builder, "lowbatt_toggle"));
  g_signal_connect (G_OBJECT (battstat->lowbatt_toggle), "toggled",
  		    G_CALLBACK (lowbatt_toggled), battstat);

  if (!g_settings_is_writable (battstat->settings,
			  "low-battery-notification"))
  {
	  hard_set_sensitive (battstat->lowbatt_toggle, FALSE);
  }

  battstat->hbox_ptr = GTK_WIDGET (gtk_builder_get_object (builder, "hbox_ptr"));
  hard_set_sensitive (battstat->hbox_ptr, battstat->lowbattnotification);

  combo_ptr = GTK_WIDGET (gtk_builder_get_object (builder, "combo_ptr"));
  g_signal_connect (G_OBJECT (combo_ptr), "changed",
		  G_CALLBACK (combo_ptr_cb), battstat);

  liststore = gtk_list_store_new (1, G_TYPE_STRING);
  gtk_combo_box_set_model (GTK_COMBO_BOX (combo_ptr),
		  GTK_TREE_MODEL (liststore));
  gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo_ptr));
  renderer = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_ptr),
		  renderer, TRUE);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_ptr),
		  renderer,
		  "text", 0,
		  NULL);
  gtk_list_store_append (liststore, &iter);
  /* TRANSLATOR: this is a selectable item in a drop-down menu to end
   * this sentence:
   *   "Warn when battery charge drops to: [XX] percent".
   */
  gtk_list_store_set (liststore, &iter, 0, _("Percent"), -1);
  gtk_list_store_append (liststore, &iter);
  /* TRANSLATOR: this is a selectable item in a drop-down menu to end
   * this sentence:
   *   "Warn when battery charge drops to: [XX] minutes remaining"
   */
  gtk_list_store_set (liststore, &iter, 0, _("Minutes Remaining"), -1);

  spin_ptr = GTK_WIDGET (gtk_builder_get_object (builder, "spin_ptr"));
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin_ptr),
		  battstat->red_val);
  g_signal_connect (G_OBJECT (spin_ptr), "value-changed",
		  G_CALLBACK (spin_ptr_cb), battstat);

  if (battstat->red_value_is_time)
	  gtk_combo_box_set_active (GTK_COMBO_BOX (combo_ptr), 1);
  else
	  gtk_combo_box_set_active (GTK_COMBO_BOX (combo_ptr), 0);

  battstat->full_toggle = GTK_WIDGET (gtk_builder_get_object (builder, "full_toggle"));
  g_signal_connect (G_OBJECT (battstat->full_toggle), "toggled",
  		    G_CALLBACK (full_toggled), battstat);

  if (!g_settings_is_writable (battstat->settings,
			  "full-battery-notification"))
  {
	  hard_set_sensitive (battstat->full_toggle, FALSE);
  }
  if (battstat->fullbattnot)
  {
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (battstat->full_toggle),
		     TRUE);
  }
  if (battstat->lowbattnotification)
  {
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (battstat->lowbatt_toggle),
		    TRUE);
  }

  battstat->radio_traditional_battery = GTK_WIDGET (gtk_builder_get_object (builder,
		  "battery_view_2"));
  g_signal_connect (G_OBJECT (battstat->radio_traditional_battery), "toggled",
  		    G_CALLBACK (radio_traditional_toggled), battstat);

  if (!g_settings_is_writable (battstat->settings, "show-battery"))
	  hard_set_sensitive (battstat->radio_traditional_battery, FALSE);
  
  if (battstat->showbattery)
  {
    gtk_toggle_button_set_active (
		    GTK_TOGGLE_BUTTON (battstat->radio_traditional_battery),
		    TRUE);
  }
  
  battstat->radio_ubuntu_battery = GTK_WIDGET (gtk_builder_get_object (builder,
		  "battery_view"));
  g_signal_connect (G_OBJECT (battstat->radio_ubuntu_battery), "toggled",
  		    G_CALLBACK (radio_ubuntu_toggled), battstat);

  if (!g_settings_is_writable (battstat->settings, "show-status"))
	  hard_set_sensitive (battstat->radio_ubuntu_battery, FALSE);
	
  if (battstat->showstatus)
  {
    gtk_toggle_button_set_active (
		    GTK_TOGGLE_BUTTON (battstat->radio_ubuntu_battery), TRUE);
  }

  battstat->radio_text_1 = GTK_WIDGET (gtk_builder_get_object (builder, "show_text_radio"));
  battstat->radio_text_2 = GTK_WIDGET (gtk_builder_get_object (builder,
		  "show_text_radio_2"));
  battstat->check_text = GTK_WIDGET (gtk_builder_get_object (builder,
		  "show_text_remaining"));

  g_object_unref (builder);
  
  g_signal_connect (G_OBJECT (battstat->radio_text_1), "toggled",
		  G_CALLBACK (show_text_toggled), battstat);
  g_signal_connect (G_OBJECT (battstat->radio_text_2), "toggled",
		  G_CALLBACK (show_text_toggled), battstat);
  g_signal_connect (G_OBJECT (battstat->check_text), "toggled",
		  G_CALLBACK (show_text_toggled), battstat);
  
  if (!g_settings_is_writable (battstat->settings, "show-text"))
  {
	  hard_set_sensitive (battstat->check_text, FALSE);
	  hard_set_sensitive (battstat->radio_text_1, FALSE);
	  hard_set_sensitive (battstat->radio_text_2, FALSE);
  }

  if (battstat->showtext == APPLET_SHOW_PERCENT)
  {
	  gtk_toggle_button_set_active (
			  GTK_TOGGLE_BUTTON (battstat->check_text), TRUE);
	  gtk_toggle_button_set_active (
			  GTK_TOGGLE_BUTTON (battstat->radio_text_2), TRUE);
	  gtk_widget_set_sensitive (GTK_WIDGET (battstat->radio_text_1),
			  TRUE);
	  gtk_widget_set_sensitive (GTK_WIDGET (battstat->radio_text_2),
			  TRUE);
  }
  else if (battstat->showtext == APPLET_SHOW_TIME)
  {
	  gtk_toggle_button_set_active (
			  GTK_TOGGLE_BUTTON (battstat->check_text),
			  TRUE);
	  gtk_toggle_button_set_active (
			  GTK_TOGGLE_BUTTON (battstat->radio_text_1),
			  TRUE);
	  gtk_widget_set_sensitive (GTK_WIDGET (battstat->radio_text_1),
			  TRUE);
	  gtk_widget_set_sensitive (GTK_WIDGET (battstat->radio_text_2),
			  TRUE);
  }
  else /* APPLET_SHOW_NONE */
  {
	  gtk_toggle_button_set_active (
			  GTK_TOGGLE_BUTTON (battstat->check_text), FALSE);
	  gtk_widget_set_sensitive (GTK_WIDGET (battstat->radio_text_1),
			  FALSE);
	  gtk_widget_set_sensitive (GTK_WIDGET (battstat->radio_text_2),
			  FALSE);
  }

   gtk_dialog_set_default_response (GTK_DIALOG (battstat->prop_win),
		   GTK_RESPONSE_CLOSE);
   gtk_window_set_resizable (GTK_WINDOW (battstat->prop_win), FALSE);
   gtk_dialog_set_has_separator (GTK_DIALOG (battstat->prop_win), FALSE);
   
   g_signal_connect (G_OBJECT (battstat->prop_win), "response",
   		     G_CALLBACK (response_cb), battstat);
   gtk_widget_show_all (GTK_WIDGET (battstat->prop_win));
}
Esempio n. 12
0
/**
 * Callback if no certificate should be selected
 */
void no_certificate(HildonButton *button, gpointer user_data)
{
	gtk_dialog_response (GTK_DIALOG (user_data), GTK_RESPONSE_REJECT);
}
Esempio n. 13
0
/**
 * main callback for control panel plugins
 */
osso_return_t execute(osso_context_t *osso, gpointer data,
					  gboolean user_activated)
{
	gint response;

	create_list_dialog (data);

	if (!user_activated)
	{
		/* load state */
	}

	do
	{
		gchar *selected;
		response = gtk_dialog_run (GTK_DIALOG (ListDialog.dialog));
		switch (response)
		{
			case RESPONSE_NEW:
			{
				edit_connection (data, NULL);
				break;
			}
			case RESPONSE_EDIT:
			{
				StrongswanConnection *conn;
				selected = get_selected ();
				conn = strongswan_connections_get_connection (ListDialog.conns,
															  selected);
				if (conn)
				{
					edit_connection (data, conn);
				}
				else
				{
					hildon_banner_show_information (NULL, NULL,
												"Select a connection first");
				}
				g_free (selected);
				break;
			}
			case RESPONSE_DELETE:
			{
				GtkWidget *confirm;
				gint retval;
				gchar *msg;
				selected = get_selected ();
				if (!selected)
				{
					hildon_banner_show_information (NULL, NULL,
												"Select a connection first");
					break;
				}
				msg = g_strdup_printf ("Delete connection?\n%s", selected);
				confirm = hildon_note_new_confirmation (data, msg);
				retval = gtk_dialog_run (GTK_DIALOG (confirm));
				if (retval == GTK_RESPONSE_OK)
				{
					strongswan_connections_remove_connection (ListDialog.conns,
															  selected);
				}
				gtk_widget_destroy (confirm);
				g_free (msg);
				g_free (selected);
				break;
			}
			default:
				break;
		}
	}
	while (response > 0);

	gtk_widget_destroy (ListDialog.dialog);
	g_object_unref (ListDialog.conns);
	return OSSO_OK;
}
Esempio n. 14
0
static void
do_simple_message_box(ESD_TYPE_E type, gboolean *notagain,
                      const char *secondary_msg, const char *msg_format,
                      va_list ap)
{
  GtkMessageType  gtk_message_type;
  gchar          *message;
  GtkWidget      *msg_dialog;
  GtkWidget      *checkbox = NULL;

  if (notagain != NULL) {
    if (*notagain) {
      /*
       * The user had checked the "Don't show this message again" checkbox
       * in the past; don't bother showing it.
       */
      return;
    }
  }

  switch (type) {

  case ESD_TYPE_INFO:
    gtk_message_type = GTK_MESSAGE_INFO;
    break;

  case ESD_TYPE_WARN:
    gtk_message_type = GTK_MESSAGE_WARNING;
    break;

  case ESD_TYPE_ERROR:
    gtk_message_type = GTK_MESSAGE_ERROR;
    break;

  default:
    g_assert_not_reached();
    gtk_message_type = GTK_MESSAGE_INFO;
    break;
  }

  /* Format the message. */
  message = g_strdup_vprintf(msg_format, ap);
  msg_dialog = gtk_message_dialog_new(GTK_WINDOW(top_level),
                                      (GtkDialogFlags)(GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT),
                                      gtk_message_type,
                                      GTK_BUTTONS_OK,
                                      "%s", message);
  g_free(message);
  if (secondary_msg != NULL)
    gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(msg_dialog),
                                             "%s", secondary_msg);

  if (notagain != NULL) {
    checkbox = gtk_check_button_new_with_label("Don't show this message again.");
    gtk_container_set_border_width(GTK_CONTAINER(checkbox), 12);
    gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(msg_dialog))),
                       checkbox, TRUE, TRUE, 0);
    gtk_widget_show(checkbox);
  }

  gtk_dialog_run(GTK_DIALOG(msg_dialog));
  if (notagain != NULL) {
    /*
     * OK, did they check the checkbox?
     */
    *notagain = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbox));
  }
  gtk_widget_destroy(msg_dialog);
}
Esempio n. 15
0
static void
set_dialog_properties (GtkAppChooserDialog *self)
{
  gchar *name;
  gchar *extension;
  gchar *description;
  gchar *string;
  gboolean unknown;
  gchar *title;
  gchar *subtitle;
  gboolean use_header;
  GtkWidget *header;

  name = NULL;
  extension = NULL;
  description = NULL;
  unknown = TRUE;

  if (self->priv->gfile != NULL)
    {
      name = g_file_get_basename (self->priv->gfile);
      extension = get_extension (name);
    }

  if (self->priv->content_type)
    {
      description = g_content_type_get_description (self->priv->content_type);
      unknown = g_content_type_is_unknown (self->priv->content_type);
    }

  if (name != NULL)
    {
      title = g_strdup (_("Select Application"));
      /* Translators: %s is a filename */
      subtitle = g_strdup_printf (_("Opening “%s”."), name);
      string = g_strdup_printf (_("No applications found for “%s”"), name);
    }
  else
    {
      title = g_strdup (_("Select Application"));
      /* Translators: %s is a file type description */
      subtitle = g_strdup_printf (_("Opening “%s” files."), 
                                  unknown ? self->priv->content_type : description);
      string = g_strdup_printf (_("No applications found for “%s” files"),
                                unknown ? self->priv->content_type : description);
    }

  g_object_get (self, "use-header-bar", &use_header, NULL); 
  if (use_header)
    {
      header = gtk_dialog_get_header_bar (GTK_DIALOG (self));
      gtk_header_bar_set_title (GTK_HEADER_BAR (header), title);
      gtk_header_bar_set_subtitle (GTK_HEADER_BAR (header), subtitle);
    }
  else
    {
      gtk_window_set_title (GTK_WINDOW (self), _("Select Application"));
    }

  if (self->priv->heading != NULL)
    {
      gtk_label_set_markup (GTK_LABEL (self->priv->label), self->priv->heading);
      gtk_widget_show (self->priv->label);
    }
  else
    {
      gtk_widget_hide (self->priv->label);
    }

  gtk_app_chooser_widget_set_default_text (GTK_APP_CHOOSER_WIDGET (self->priv->app_chooser_widget),
                                           string);

  g_free (title);
  g_free (subtitle);
  g_free (name);
  g_free (extension);
  g_free (description);
  g_free (string);
}
Esempio n. 16
0
static PidginLogViewer *display_log_viewer(struct log_viewer_hash_t *ht, GList *logs,
						const char *title, GtkWidget *icon, int log_size)
{
	PidginLogViewer *lv;
	GtkWidget *title_box;
	char *text;
	GtkWidget *pane;
	GtkWidget *sw;
	GtkCellRenderer *rend;
	GtkTreeViewColumn *col;
	GtkTreeSelection *sel;
	GtkWidget *vbox;
	GtkWidget *frame;
	GtkWidget *hbox;
	GtkWidget *find_button;
	GtkWidget *size_label;

	if (logs == NULL)
	{
		/* No logs were found. */
		const char *log_preferences = NULL;

		if (ht == NULL) {
			if (!purple_prefs_get_bool("/purple/logging/log_system"))
				log_preferences = _("System events will only be logged if the \"Log all status changes to system log\" preference is enabled.");
		} else {
			if (ht->type == PURPLE_LOG_IM) {
				if (!purple_prefs_get_bool("/purple/logging/log_ims"))
					log_preferences = _("Instant messages will only be logged if the \"Log all instant messages\" preference is enabled.");
			} else if (ht->type == PURPLE_LOG_CHAT) {
				if (!purple_prefs_get_bool("/purple/logging/log_chats"))
					log_preferences = _("Chats will only be logged if the \"Log all chats\" preference is enabled.");
			}
			g_free(ht->buddyname);
			g_free(ht);
		}

		if(icon != NULL)
			gtk_widget_destroy(icon);

		purple_notify_info(NULL, title, _("No logs were found"), log_preferences);
		return NULL;
	}

	lv = g_new0(PidginLogViewer, 1);
	lv->logs = logs;

	if (ht != NULL)
		g_hash_table_insert(log_viewers, ht, lv);

	/* Window ***********/
	lv->window = gtk_dialog_new_with_buttons(title, NULL, 0,
					     GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
#ifdef _WIN32
	/* Steal the "HELP" response and use it to trigger browsing to the logs folder */
	gtk_dialog_add_button(GTK_DIALOG(lv->window), _("_Browse logs folder"), GTK_RESPONSE_HELP);
#endif
	gtk_container_set_border_width (GTK_CONTAINER(lv->window), PIDGIN_HIG_BOX_SPACE);
	gtk_dialog_set_has_separator(GTK_DIALOG(lv->window), FALSE);
	gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(lv->window)->vbox), 0);
	g_signal_connect(G_OBJECT(lv->window), "response",
					 G_CALLBACK(destroy_cb), ht);
	gtk_window_set_role(GTK_WINDOW(lv->window), "log_viewer");

	/* Icon *************/
	if (icon != NULL) {
		title_box = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
		gtk_container_set_border_width(GTK_CONTAINER(title_box), PIDGIN_HIG_BOX_SPACE);
		gtk_box_pack_start(GTK_BOX(GTK_DIALOG(lv->window)->vbox), title_box, FALSE, FALSE, 0);

		gtk_box_pack_start(GTK_BOX(title_box), icon, FALSE, FALSE, 0);
	} else
		title_box = GTK_DIALOG(lv->window)->vbox;

	/* Label ************/
	lv->label = gtk_label_new(NULL);

	text = g_strdup_printf("<span size='larger' weight='bold'>%s</span>", title);

	gtk_label_set_markup(GTK_LABEL(lv->label), text);
	gtk_misc_set_alignment(GTK_MISC(lv->label), 0, 0);
	gtk_box_pack_start(GTK_BOX(title_box), lv->label, FALSE, FALSE, 0);
	g_free(text);

	/* Pane *************/
	pane = gtk_hpaned_new();
	gtk_container_set_border_width(GTK_CONTAINER(pane), PIDGIN_HIG_BOX_SPACE);
	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(lv->window)->vbox), pane, TRUE, TRUE, 0);

	/* List *************/
	sw = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
	gtk_paned_add1(GTK_PANED(pane), sw);
	lv->treestore = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
	lv->treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (lv->treestore));
	g_object_unref(G_OBJECT(lv->treestore));
	rend = gtk_cell_renderer_text_new();
	col = gtk_tree_view_column_new_with_attributes ("time", rend, "markup", 0, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW(lv->treeview), col);
	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (lv->treeview), FALSE);
	gtk_container_add (GTK_CONTAINER (sw), lv->treeview);

	populate_log_tree(lv);

	sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (lv->treeview));
	g_signal_connect (G_OBJECT (sel), "changed",
			G_CALLBACK (log_select_cb),
			lv);
	g_signal_connect (G_OBJECT(lv->treeview), "row-activated",
			G_CALLBACK(log_row_activated_cb),
			lv);
	pidgin_set_accessible_label(lv->treeview, lv->label);

	g_signal_connect(lv->treeview, "button-press-event", G_CALLBACK(log_button_press_cb), lv);
	g_signal_connect(lv->treeview, "popup-menu", G_CALLBACK(log_popup_menu_cb), lv);

	/* Log size ************/
	if(log_size) {
		char *sz_txt = purple_str_size_to_units(log_size);
		text = g_strdup_printf("<span weight='bold'>%s</span> %s", _("Total log size:"), sz_txt);
		size_label = gtk_label_new(NULL);
		gtk_label_set_markup(GTK_LABEL(size_label), text);
		/*		gtk_paned_add1(GTK_PANED(pane), size_label); */
		gtk_misc_set_alignment(GTK_MISC(size_label), 0, 0);
		gtk_box_pack_end(GTK_BOX(GTK_DIALOG(lv->window)->vbox), size_label, FALSE, FALSE, 0);
		g_free(sz_txt);
		g_free(text);
	}

	/* A fancy little box ************/
	vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
	gtk_paned_add2(GTK_PANED(pane), vbox);

	/* Viewer ************/
	frame = pidgin_create_imhtml(FALSE, &lv->imhtml, NULL, NULL);
	gtk_widget_set_name(lv->imhtml, "pidgin_log_imhtml");
	gtk_widget_set_size_request(lv->imhtml, 320, 200);
	gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
	gtk_widget_show(frame);

	/* Search box **********/
	hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
	lv->entry = gtk_entry_new();
	gtk_box_pack_start(GTK_BOX(hbox), lv->entry, TRUE, TRUE, 0);
	find_button = gtk_button_new_from_stock(GTK_STOCK_FIND);
	gtk_box_pack_start(GTK_BOX(hbox), find_button, FALSE, FALSE, 0);
	g_signal_connect(GTK_ENTRY(lv->entry), "activate", G_CALLBACK(search_cb), lv);
	g_signal_connect(GTK_BUTTON(find_button), "clicked", G_CALLBACK(search_cb), lv);

	select_first_log(lv);

	gtk_widget_show_all(lv->window);

	return lv;
}
Esempio n. 17
0
/**
 * vdpdbg_window_show(): Show the VDP Layer Options window.
 * @param parent Parent window.
 */
void MDP_FNCALL vdpdbg_window_show(void *parent)
{
    if (vdpdbg_window)
    {
        // VDP Debugger window is already visible. Set focus.
        gtk_widget_grab_focus(vdpdbg_window);
        return;
    }

    // Initialize VDP Data.
    vdpdbg_data_init();

    // Clear previous CRam buffer.
    memset(prev_CRam, 0, sizeof(prev_CRam));

    // Create the window.
    vdpdbg_window = gtk_dialog_new();
    gtk_container_set_border_width(GTK_CONTAINER(vdpdbg_window), 4);
    gtk_window_set_title(GTK_WINDOW(vdpdbg_window), "VDP Debugger");
    gtk_window_set_position(GTK_WINDOW(vdpdbg_window), GTK_WIN_POS_CENTER);
    gtk_window_set_resizable(GTK_WINDOW(vdpdbg_window), FALSE);
    gtk_window_set_type_hint(GTK_WINDOW(vdpdbg_window), GDK_WINDOW_TYPE_HINT_DIALOG);
    gtk_dialog_set_has_separator(GTK_DIALOG(vdpdbg_window), FALSE);

    // Callbacks for if the window is closed.
    g_signal_connect((gpointer)vdpdbg_window, "delete_event",
                     G_CALLBACK(vdpdbg_window_callback_close), NULL);
    g_signal_connect((gpointer)vdpdbg_window, "destroy_event",
                     G_CALLBACK(vdpdbg_window_callback_close), NULL);

    // Dialog response callback.
    g_signal_connect((gpointer)vdpdbg_window, "response",
                     G_CALLBACK(vdpdbg_window_callback_response), NULL);

    // Get the dialog VBox.
    GtkWidget *vboxDialog = gtk_bin_get_child(GTK_BIN(vdpdbg_window));
    gtk_box_set_spacing(GTK_BOX(vboxDialog), 8);
    gtk_widget_show(vboxDialog);

    // Create the CRam image. (each color will be 16x16)
    pbufCRam = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 16*16, 4*16);
    imgCRam = gtk_image_new_from_pixbuf(pbufCRam);
    gtk_widget_show(imgCRam);
    gtk_box_pack_start(GTK_BOX(vboxDialog), imgCRam, FALSE, FALSE, 0);

    // Clear the pixel buffer.
    uint32_t *pixels = (uint32_t*)gdk_pixbuf_get_pixels(pbufCRam);
    int rowstride = gdk_pixbuf_get_rowstride(pbufCRam);
    int n_channels = gdk_pixbuf_get_n_channels(pbufCRam);
    int px_count = ((rowstride * 63) + (16*16*n_channels)) / 4;

    for (; px_count != 0; px_count -= 4)
    {
        *pixels = 0xFF000000U;
        *(pixels + 1) = 0xFF000000U;
        *(pixels + 2) = 0xFF000000U;
        *(pixels + 3) = 0xFF000000U;
        pixels += 4;
    }


    // Create the GtkTreeView for the register listing.
    vdpdbg_window_create_lstRegList(vboxDialog);

    // Create the dialog buttons.
    gtk_dialog_add_buttons(GTK_DIALOG(vdpdbg_window),
                           "gtk-close", GTK_RESPONSE_CLOSE,
                           NULL);

    // Set the window as modal to the main application window.
    if (parent)
        gtk_window_set_transient_for(GTK_WINDOW(vdpdbg_window), GTK_WINDOW(parent));

    // Update the window.
    vdpdbg_window_update();

    // Show the window.
    gtk_widget_show_all(vdpdbg_window);

    // Register the window with MDP Host Services.
    vdpdbg_host_srv->window_register(&mdp, vdpdbg_window);
}
Esempio n. 18
0
VectorsImportDialog *
vectors_import_dialog_new (GimpImage *image,
                           GtkWidget *parent,
                           gboolean   merge_vectors,
                           gboolean   scale_vectors)
{
  VectorsImportDialog *dialog;
  GtkWidget           *vbox;
  GtkWidget           *button;
  GtkFileFilter       *filter;

  g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
  g_return_val_if_fail (GTK_IS_WIDGET (parent), NULL);

  dialog = g_slice_new0 (VectorsImportDialog);

  dialog->image         = image;
  dialog->merge_vectors = merge_vectors;
  dialog->scale_vectors = scale_vectors;

  dialog->dialog =
    gtk_file_chooser_dialog_new (_("Import Paths from SVG"), NULL,
                                 GTK_FILE_CHOOSER_ACTION_OPEN,

                                 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                 GTK_STOCK_OPEN,   GTK_RESPONSE_OK,

                                 NULL);

  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog->dialog),
                                           GTK_RESPONSE_OK,
                                           GTK_RESPONSE_CANCEL,
                                           -1);

  gtk_window_set_screen (GTK_WINDOW (dialog->dialog),
                         gtk_widget_get_screen (parent));

  gtk_window_set_role (GTK_WINDOW (dialog->dialog), "gimp-vectors-import");
  gtk_window_set_position (GTK_WINDOW (dialog->dialog), GTK_WIN_POS_MOUSE);

  gtk_dialog_set_default_response (GTK_DIALOG (dialog->dialog),
                                   GTK_RESPONSE_OK);

  g_object_weak_ref (G_OBJECT (dialog->dialog),
                     (GWeakNotify) vectors_import_dialog_free, dialog);

  g_signal_connect_object (image, "disconnect",
                           G_CALLBACK (gtk_widget_destroy),
                           dialog->dialog, 0);

  g_signal_connect (dialog->dialog, "delete-event",
                    G_CALLBACK (gtk_true),
                    NULL);

  filter = gtk_file_filter_new ();
  gtk_file_filter_set_name (filter, _("All files (*.*)"));
  gtk_file_filter_add_pattern (filter, "*");
  gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog->dialog), filter);

  filter = gtk_file_filter_new ();
  gtk_file_filter_set_name (filter, _("Scalable SVG image (*.svg)"));
  gtk_file_filter_add_pattern (filter, "*.[Ss][Vv][Gg]");
  gtk_file_filter_add_mime_type (filter, "image/svg+xml");
  gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog->dialog), filter);

  gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog->dialog), filter);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
  gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog->dialog), vbox);
  gtk_widget_show (vbox);

  button = gtk_check_button_new_with_mnemonic (_("_Merge imported paths"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
                                dialog->merge_vectors);
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
  gtk_widget_show (button);

  g_signal_connect (button, "toggled",
                    G_CALLBACK (gimp_toggle_button_update),
                    &dialog->merge_vectors);

  button = gtk_check_button_new_with_mnemonic (_("_Scale imported paths "
                                                 "to fit image"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
                                dialog->scale_vectors);
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
  gtk_widget_show (button);

  g_signal_connect (button, "toggled",
                    G_CALLBACK (gimp_toggle_button_update),
                    &dialog->scale_vectors);

  return dialog;
}
GtkWidget*  create_dialog1 (void)
{
  GtkWidget *dialog1;
  GtkWidget *dialog_vbox1;
  GtkWidget *vbox1;
  GtkWidget *hbox2;
  GtkWidget *vbox3;
  GtkWidget *vbox4;
  GtkWidget *label1;
  GtkWidget *vbox5;
  GtkWidget *vbox2;
  GtkWidget *dialog_action_area1;
  GtkWidget *hbox1;
  GtkWidget *button_ok;
  GtkWidget *button_cancel;
  GtkWidget *button_update;

  dialog1 = gtk_dialog_new (); 
  gtk_object_set_data (GTK_OBJECT (dialog1), "dialog1", dialog1);
  gtk_window_set_title (GTK_WINDOW (dialog1), "Rotate");
  gtk_window_set_policy (GTK_WINDOW (dialog1), TRUE, TRUE, FALSE);

  dialog_vbox1 = GTK_DIALOG (dialog1)->vbox;
  gtk_object_set_data (GTK_OBJECT (dialog1), "dialog_vbox1", dialog_vbox1);
  gtk_widget_show (dialog_vbox1);

  vbox1 = gtk_vbox_new (FALSE, 0);
  gtk_widget_ref (vbox1);
  gtk_object_set_data_full (GTK_OBJECT (dialog1), "vbox1", vbox1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (vbox1);
  gtk_box_pack_start (GTK_BOX (dialog_vbox1), vbox1, TRUE, TRUE, 0);

  hbox2 = gtk_hbox_new (FALSE, 0);
  gtk_widget_ref (hbox2);
  gtk_object_set_data_full (GTK_OBJECT (dialog1), "hbox2", hbox2,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbox2);
  gtk_box_pack_start (GTK_BOX (vbox1), hbox2, TRUE, TRUE, 0);

  vbox3 = gtk_vbox_new (FALSE, 0);
  gtk_widget_ref (vbox3);
  gtk_object_set_data_full (GTK_OBJECT (dialog1), "vbox3", vbox3,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (vbox3);
  gtk_box_pack_start (GTK_BOX (hbox2), vbox3, TRUE, TRUE, 0);

  vbox4 = gtk_vbox_new (FALSE, 0);
  gtk_widget_ref (vbox4);
  gtk_object_set_data_full (GTK_OBJECT (dialog1), "vbox4", vbox4,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (vbox4);
  gtk_box_pack_start (GTK_BOX (vbox3), vbox4, TRUE, TRUE, 0);

  label1 = gtk_label_new ("Angle");
  gtk_widget_ref (label1);
  gtk_object_set_data_full (GTK_OBJECT (dialog1), "label1", label1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (label1);
  gtk_box_pack_start (GTK_BOX (vbox4), label1, FALSE, FALSE, 0);

  // angle  _______________________________________________________________
  adj_angle=gtk_adjustment_new (0.0, 0.0, 360.0, 90.0, 90.0, 90.0);
  hscale2 = gtk_hscale_new (GTK_ADJUSTMENT (adj_angle));
  gtk_widget_ref (hscale2);
  gtk_object_set_data_full (GTK_OBJECT (dialog1), "hscale2", hscale2,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hscale2);
  gtk_box_pack_start (GTK_BOX (vbox4), hscale2, TRUE, TRUE, 0);

  vbox5 = gtk_vbox_new (FALSE, 0);
  gtk_widget_ref (vbox5);
  gtk_object_set_data_full (GTK_OBJECT (dialog1), "vbox5", vbox5,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (vbox5);
  gtk_box_pack_start (GTK_BOX (vbox3), vbox5, TRUE, TRUE, 0);

//  gtk_box_pack_start (GTK_BOX (vbox5), hscale3, TRUE, TRUE, 0);
//  gtk_scale_set_digits (GTK_SCALE (hscale3), 0);

  vbox2 = gtk_vbox_new (FALSE, 0);
  gtk_widget_ref (vbox2);
  gtk_object_set_data_full (GTK_OBJECT (dialog1), "vbox2", vbox2,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (vbox2);
  gtk_box_pack_start (GTK_BOX (hbox2), vbox2, TRUE, TRUE, 0);

  drawing = gtk_drawing_area_new ();
  gtk_widget_ref (drawing);
  gtk_object_set_data_full (GTK_OBJECT (dialog1), "drawing", drawing,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (drawing);
  gtk_box_pack_start (GTK_BOX (vbox1), drawing, TRUE, TRUE, 0);

  dialog_action_area1 = GTK_DIALOG (dialog1)->action_area;
  gtk_object_set_data (GTK_OBJECT (dialog1), "dialog_action_area1", dialog_action_area1);
  gtk_widget_show (dialog_action_area1);
  gtk_container_set_border_width (GTK_CONTAINER (dialog_action_area1), 10);

  hbox1 = gtk_hbox_new (FALSE, 0);
  gtk_widget_ref (hbox1);
  gtk_object_set_data_full (GTK_OBJECT (dialog1), "hbox1", hbox1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbox1);
  gtk_box_pack_start (GTK_BOX (dialog_action_area1), hbox1, TRUE, TRUE, 0);

  button_ok = gtk_button_new_with_label ("Ok");
  gtk_widget_ref (button_ok);
  gtk_object_set_data_full (GTK_OBJECT (dialog1), "button_ok", button_ok,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (button_ok);
  gtk_box_pack_start (GTK_BOX (hbox1), button_ok, FALSE, FALSE, 0);

  button_cancel = gtk_button_new_with_label ("Cancel");
  gtk_widget_ref (button_cancel);
  gtk_object_set_data_full (GTK_OBJECT (dialog1), "button_cancel", button_cancel,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (button_cancel);
  gtk_box_pack_start (GTK_BOX (hbox1), button_cancel, FALSE, FALSE, 0);

  button_update = gtk_button_new_with_label ("Update");
  gtk_widget_ref (button_update);
  gtk_object_set_data_full (GTK_OBJECT (dialog1), "button_update", button_update,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (button_update);
  gtk_box_pack_start (GTK_BOX (hbox1), button_update, FALSE, FALSE, 0);

//-------------------------------------------  
  gtk_signal_connect (GTK_OBJECT (button_ok), "clicked",
                      GTK_SIGNAL_FUNC (gui_ok),
                      (void *)1);
  gtk_signal_connect (GTK_OBJECT (button_cancel), "clicked",
                      GTK_SIGNAL_FUNC (gui_ok),
                      (void *)0);

  gtk_signal_connect (GTK_OBJECT (button_update), "clicked",
                      GTK_SIGNAL_FUNC (gui_update),
                      NULL);

  gtk_signal_connect(GTK_OBJECT(drawing), "expose_event",
		       GTK_SIGNAL_FUNC(gui_draw),
		       NULL);


  /*gtk_signal_connect(GTK_OBJECT(hscale3), "drag_data_received",
		       GTK_SIGNAL_FUNC(gui_update), NULL);*/
  gtk_signal_connect(GTK_OBJECT(hscale2), "drag_data_received",
		       GTK_SIGNAL_FUNC(gui_update), NULL);

  /*gtk_signal_connect(GTK_OBJECT(hscale3), "drag_motion",
		       GTK_SIGNAL_FUNC(gui_update), NULL);*/
  gtk_signal_connect(GTK_OBJECT(hscale2), "drag_motion",
		       GTK_SIGNAL_FUNC(gui_update), NULL);

  /*gtk_signal_connect(GTK_OBJECT(hscale3), "drag_data_get",
		       GTK_SIGNAL_FUNC(gui_update), NULL);*/
  gtk_signal_connect(GTK_OBJECT(hscale2), "drag_data_get",
		       GTK_SIGNAL_FUNC(gui_update), NULL);

  /*gtk_signal_connect(GTK_OBJECT(hscale3), "drag_begin",
		       GTK_SIGNAL_FUNC(gui_update), NULL);*/
  gtk_signal_connect(GTK_OBJECT(hscale2), "drag_begin",
		       GTK_SIGNAL_FUNC(gui_update), NULL);

  gtk_signal_connect(GTK_OBJECT(adj_angle), "value_changed",
		       GTK_SIGNAL_FUNC(gui_update), (void *) (NULL));



  return dialog1;
}
Esempio n. 20
0
static gboolean
dialog (void)
{
  /* Missing options: Color-dialogs? / own curl layer ? / transparency
     to original drawable / Warp-curl (unsupported yet) */

  GtkWidget *dialog;
  GtkWidget *hbox;
  GtkWidget *vbox;
  GtkWidget *table;
  GtkWidget *frame;
  GtkWidget *button;
  GtkWidget *combo;
  GtkObject *adjustment;
  gboolean   run;

  gimp_ui_init (PLUG_IN_BINARY, FALSE);

  dialog = gimp_dialog_new (_("Pagecurl Effect"), PLUG_IN_BINARY,
                            NULL, 0,
			    gimp_standard_help_func, PLUG_IN_PROC,

			    GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
			    GTK_STOCK_OK,     GTK_RESPONSE_OK,

			    NULL);

  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
                                           GTK_RESPONSE_OK,
                                           GTK_RESPONSE_CANCEL,
                                           -1);

  gimp_window_set_transient (GTK_WINDOW (dialog));

  vbox = gtk_vbox_new (FALSE, 12);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
                      vbox, TRUE, TRUE, 0);
  gtk_widget_show (vbox);

  frame = gimp_frame_new (_("Curl Location"));
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);

  table = gtk_table_new (3, 2, TRUE);
  gtk_table_set_col_spacings (GTK_TABLE (table), 6);
  gtk_table_set_row_spacings (GTK_TABLE (table), 6);
  gtk_container_add (GTK_CONTAINER (frame), table);

  curl_image = gtk_image_new ();

  gtk_table_attach (GTK_TABLE (table), curl_image, 0, 2, 1, 2,
                    GTK_SHRINK, GTK_SHRINK, 0, 0);
  gtk_widget_show (curl_image);

  curl_pixbuf_update ();

  {
    static const gchar *name[] =
    {
      N_("Lower right"),
      N_("Lower left"),
      N_("Upper left"),
      N_("Upper right")
    };
    gint i;

    button = NULL;
    for (i = CURL_EDGE_FIRST; i <= CURL_EDGE_LAST; i++)
      {
        button =
          gtk_radio_button_new_with_label (button == NULL ?
                                           NULL :
                                           gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
                                           gettext (name[i - CURL_EDGE_FIRST]));

        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
                                      curl.edge == i);

        g_object_set_data (G_OBJECT (button),
                           "gimp-item-data", GINT_TO_POINTER (i));

        gtk_table_attach (GTK_TABLE (table), button,
                          CURL_EDGE_LEFT  (i) ? 0 : 1,
                          CURL_EDGE_LEFT  (i) ? 1 : 2,
                          CURL_EDGE_UPPER (i) ? 0 : 2,
                          CURL_EDGE_UPPER (i) ? 1 : 3,
                          GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0);
        gtk_widget_show (button);

        g_signal_connect (button, "toggled",
                          G_CALLBACK (gimp_radio_button_update),
                          &curl.edge);

        g_signal_connect (button, "toggled",
                          G_CALLBACK (curl_pixbuf_update),
                           NULL);
      }
  }

  gtk_widget_show (table);
  gtk_widget_show (frame);

  frame = gimp_frame_new (_("Curl Orientation"));
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);

  hbox = gtk_hbox_new (TRUE, 6);
  gtk_container_add (GTK_CONTAINER (frame), hbox);

  {
    static const gchar *name[] =
    {
      N_("_Vertical"),
      N_("_Horizontal")
    };
    gint i;

    button = NULL;
    for (i = 0; i <= CURL_ORIENTATION_LAST; i++)
      {
        button = gtk_radio_button_new_with_mnemonic (button == NULL ?
                                                     NULL :
                                                     gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
                                                     gettext (name[i]));

        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
                                      curl.orientation == i);

        g_object_set_data (G_OBJECT (button),
                           "gimp-item-data", GINT_TO_POINTER (i));

        gtk_box_pack_end (GTK_BOX (hbox), button, TRUE, TRUE, 0);
        gtk_widget_show (button);

        g_signal_connect (button, "toggled",
                          G_CALLBACK (gimp_radio_button_update),
                          &curl.orientation);

        g_signal_connect (button, "toggled",
                          G_CALLBACK (curl_pixbuf_update),
                          NULL);
      }
  }

  gtk_widget_show (hbox);
  gtk_widget_show (frame);

  button = gtk_check_button_new_with_mnemonic (_("_Shade under curl"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), curl.shade);
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
  gtk_widget_show (button);

  g_signal_connect (button, "toggled",
                    G_CALLBACK (gimp_toggle_button_update),
                    &curl.shade);

  combo = g_object_new (GIMP_TYPE_INT_COMBO_BOX, NULL);

  gimp_int_combo_box_prepend (GIMP_INT_COMBO_BOX (combo),
                              GIMP_INT_STORE_VALUE,    CURL_COLORS_GRADIENT_REVERSE,
                              GIMP_INT_STORE_LABEL,    _("Current gradient (reversed)"),
                              GIMP_INT_STORE_STOCK_ID, GIMP_STOCK_GRADIENT,
                              -1);
  gimp_int_combo_box_prepend (GIMP_INT_COMBO_BOX (combo),
                              GIMP_INT_STORE_VALUE,    CURL_COLORS_GRADIENT,
                              GIMP_INT_STORE_LABEL,    _("Current gradient"),
                              GIMP_INT_STORE_STOCK_ID, GIMP_STOCK_GRADIENT,
                              -1);
  gimp_int_combo_box_prepend (GIMP_INT_COMBO_BOX (combo),
                              GIMP_INT_STORE_VALUE,    CURL_COLORS_FG_BG,
                              GIMP_INT_STORE_LABEL,    _("Foreground / background colors"),
                              GIMP_INT_STORE_STOCK_ID, GIMP_STOCK_DEFAULT_COLORS,
                              -1);

  gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0);
  gtk_widget_show (combo);

  gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
                              curl.colors,
                              G_CALLBACK (gimp_int_combo_box_get_active),
                              &curl.colors);

  gtk_widget_show (dialog);

  table = gtk_table_new (1, 3, FALSE);
  gtk_table_set_col_spacings (GTK_TABLE (table), 6);
  gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
  gtk_widget_show (table);

  adjustment = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
                                     _("_Opacity:"), 100, 0,
                                     curl.opacity * 100.0, 0.0, 100.0,
                                     1.0, 1.0, 0.0,
                                     TRUE, 0, 0,
                                     NULL, NULL);
  g_signal_connect (adjustment, "value-changed",
                    G_CALLBACK (dialog_scale_update),
                    &curl.opacity);

  run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);

  gtk_widget_destroy (dialog);

  return run;
}
Esempio n. 21
0
GtkWidget*
create_dialog1 (void)
{
  GtkWidget *dialog1;
  GtkWidget *dialog_vbox1;
  GtkWidget *vbox1;
  GtkWidget *table1;
  GtkWidget *label1;
  GtkWidget *comboboxOrder;
  GtkWidget *label2;
  GtkWidget *comboboxInterpolate;
  GtkWidget *label3;
  GtkWidget *comboboxType;
  GtkWidget *label4;
  GtkWidget *comboboxMnt;
  GtkWidget *label7;
  GtkWidget *checkbuttonChroma;
  GtkWidget *label8;
  GtkWidget *checkbuttonTryweave;
  GtkWidget *label10;
  GtkWidget *checkbuttonDenoise;
  GtkWidget *label9;
  GtkWidget *combobox5;
  GtkWidget *label5;
  GtkWidget *checkbuttonSharp;
  GtkWidget *label16;
  GtkWidget *checkbuttonFull;
  GtkWidget *label6;
  GtkWidget *combobox6;
  GtkWidget *table2;
  GtkWidget *label11;
  GtkWidget *label12;
  GtkObject *spinbuttonmthreshL_adj;
  GtkWidget *spinbuttonmthreshL;
  GtkObject *spinbuttonmthreshC_adj;
  GtkWidget *spinbuttonmthreshC;
  GtkWidget *label13;
  GtkObject *spinbuttoncthresh_adj;
  GtkWidget *spinbuttoncthresh;
  GtkWidget *label14;
  GtkObject *spinbuttonMI_adj;
  GtkWidget *spinbuttonMI;
  GtkWidget *label15;
  GtkObject *spinbuttonAP_adj;
  GtkWidget *spinbuttonAP;
  GtkWidget *dialog_action_area1;
  GtkWidget *cancelbutton1;
  GtkWidget *okbutton1;

  dialog1 = gtk_dialog_new ();
  gtk_window_set_title (GTK_WINDOW (dialog1), _("TDeint param"));
  gtk_window_set_type_hint (GTK_WINDOW (dialog1), GDK_WINDOW_TYPE_HINT_DIALOG);

  dialog_vbox1 = GTK_DIALOG (dialog1)->vbox;
  gtk_widget_show (dialog_vbox1);

  vbox1 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox1);
  gtk_box_pack_start (GTK_BOX (dialog_vbox1), vbox1, TRUE, TRUE, 0);

  table1 = gtk_table_new (11, 2, FALSE);
  gtk_widget_show (table1);
  gtk_box_pack_start (GTK_BOX (vbox1), table1, TRUE, TRUE, 0);

  label1 = gtk_label_new (_("Field Order :"));
  gtk_widget_show (label1);
  gtk_table_attach (GTK_TABLE (table1), label1, 0, 1, 0, 1,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label1), 0, 0.5);

  comboboxOrder = gtk_combo_box_new_text ();
  gtk_widget_show (comboboxOrder);
  gtk_table_attach (GTK_TABLE (table1), comboboxOrder, 1, 2, 0, 1,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);
  gtk_combo_box_append_text (GTK_COMBO_BOX (comboboxOrder), _("Bottom Field First"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (comboboxOrder), _("Top Field First"));

  label2 = gtk_label_new (_("Interpolate :"));
  gtk_widget_show (label2);
  gtk_table_attach (GTK_TABLE (table1), label2, 0, 1, 1, 2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label2), 0, 0.5);

  comboboxInterpolate = gtk_combo_box_new_text ();
  gtk_widget_show (comboboxInterpolate);
  gtk_table_attach (GTK_TABLE (table1), comboboxInterpolate, 1, 2, 1, 2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);
  gtk_combo_box_append_text (GTK_COMBO_BOX (comboboxInterpolate), _("Top field (keep bottom)"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (comboboxInterpolate), _("Bottom field (keep top)"));

  label3 = gtk_label_new (_("Type"));
  gtk_widget_show (label3);
  gtk_table_attach (GTK_TABLE (table1), label3, 0, 1, 2, 3,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label3), 0, 0.5);

  comboboxType = gtk_combo_box_new_text ();
  gtk_widget_show (comboboxType);
  gtk_table_attach (GTK_TABLE (table1), comboboxType, 1, 2, 2, 3,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);
  gtk_combo_box_append_text (GTK_COMBO_BOX (comboboxType), _("Cubic Interpolation"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (comboboxType), _("Modified ELA"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (comboboxType), _("Kernerl interpolation"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (comboboxType), _("Modified ELA-2"));

  label4 = gtk_label_new (_("MntMode"));
  gtk_widget_show (label4);
  gtk_table_attach (GTK_TABLE (table1), label4, 0, 1, 3, 4,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label4), 0, 0.5);

  comboboxMnt = gtk_combo_box_new_text ();
  gtk_widget_show (comboboxMnt);
  gtk_table_attach (GTK_TABLE (table1), comboboxMnt, 1, 2, 3, 4,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);
  gtk_combo_box_append_text (GTK_COMBO_BOX (comboboxMnt), _("4 field check"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (comboboxMnt), _("5 field check"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (comboboxMnt), _("4 field check (no average)"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (comboboxMnt), _("5 field check (no average)"));

  label7 = gtk_label_new (_("Use Chroma to evalute"));
  gtk_widget_show (label7);
  gtk_table_attach (GTK_TABLE (table1), label7, 0, 1, 6, 7,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label7), 0, 0.5);

  checkbuttonChroma = gtk_check_button_new_with_mnemonic ("");
  gtk_widget_show (checkbuttonChroma);
  gtk_table_attach (GTK_TABLE (table1), checkbuttonChroma, 1, 2, 6, 7,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);

  label8 = gtk_label_new (_("Try weave "));
  gtk_widget_show (label8);
  gtk_table_attach (GTK_TABLE (table1), label8, 0, 1, 7, 8,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label8), 0, 0.5);

  checkbuttonTryweave = gtk_check_button_new_with_mnemonic ("");
  gtk_widget_show (checkbuttonTryweave);
  gtk_table_attach (GTK_TABLE (table1), checkbuttonTryweave, 1, 2, 7, 8,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);

  label10 = gtk_label_new (_("Denoise"));
  gtk_widget_show (label10);
  gtk_table_attach (GTK_TABLE (table1), label10, 0, 1, 8, 9,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label10), 0, 0.5);

  checkbuttonDenoise = gtk_check_button_new_with_mnemonic ("");
  gtk_widget_show (checkbuttonDenoise);
  gtk_table_attach (GTK_TABLE (table1), checkbuttonDenoise, 1, 2, 8, 9,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);

  label9 = gtk_label_new (_("Link"));
  gtk_widget_show (label9);
  gtk_table_attach (GTK_TABLE (table1), label9, 0, 1, 4, 5,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label9), 0, 0.5);

  combobox5 = gtk_combo_box_new_text ();
  gtk_widget_show (combobox5);
  gtk_table_attach (GTK_TABLE (table1), combobox5, 1, 2, 4, 5,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);
  gtk_combo_box_append_text (GTK_COMBO_BOX (combobox5), _("No link"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (combobox5), _("Full linking"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (combobox5), _("Y to UV link"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (combobox5), _("UV to Y link"));

  label5 = gtk_label_new (_("Sharp :"));
  gtk_widget_show (label5);
  gtk_table_attach (GTK_TABLE (table1), label5, 0, 1, 9, 10,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label5), 0, 0.5);

  checkbuttonSharp = gtk_check_button_new_with_mnemonic ("");
  gtk_widget_show (checkbuttonSharp);
  gtk_table_attach (GTK_TABLE (table1), checkbuttonSharp, 1, 2, 9, 10,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);

  label16 = gtk_label_new (_("AP type"));
  gtk_widget_show (label16);
  gtk_table_attach (GTK_TABLE (table1), label16, 0, 1, 5, 6,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label16), 0, 0.5);

  checkbuttonFull = gtk_check_button_new_with_mnemonic ("");
  gtk_widget_show (checkbuttonFull);
  gtk_table_attach (GTK_TABLE (table1), checkbuttonFull, 1, 2, 10, 11,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);

  label6 = gtk_label_new (_("Evaluate ALL frames"));
  gtk_widget_show (label6);
  gtk_table_attach (GTK_TABLE (table1), label6, 0, 1, 10, 11,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label6), 0, 0.5);

  combobox6 = gtk_combo_box_new_text ();
  gtk_widget_show (combobox6);
  gtk_table_attach (GTK_TABLE (table1), combobox6, 1, 2, 5, 6,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);
  gtk_combo_box_append_text (GTK_COMBO_BOX (combobox6), _("0 (read manual)"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (combobox6), _("1 (read manual)"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (combobox6), _("2 (read manual)"));

  table2 = gtk_table_new (5, 2, FALSE);
  gtk_widget_show (table2);
  gtk_box_pack_start (GTK_BOX (vbox1), table2, TRUE, TRUE, 0);

  label11 = gtk_label_new (_("motion Threshold, Luma"));
  gtk_widget_show (label11);
  gtk_table_attach (GTK_TABLE (table2), label11, 0, 1, 0, 1,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label11), 0, 0.5);

  label12 = gtk_label_new (_("motion Threshold, Chroma"));
  gtk_widget_show (label12);
  gtk_table_attach (GTK_TABLE (table2), label12, 0, 1, 1, 2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label12), 0, 0.5);

  spinbuttonmthreshL_adj = gtk_adjustment_new (1, 0, 255, 1, 10, 10);
  spinbuttonmthreshL = gtk_spin_button_new (GTK_ADJUSTMENT (spinbuttonmthreshL_adj), 1, 0);
  gtk_widget_show (spinbuttonmthreshL);
  gtk_table_attach (GTK_TABLE (table2), spinbuttonmthreshL, 1, 2, 0, 1,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbuttonmthreshL), TRUE);

  spinbuttonmthreshC_adj = gtk_adjustment_new (1, 0, 255, 1, 10, 10);
  spinbuttonmthreshC = gtk_spin_button_new (GTK_ADJUSTMENT (spinbuttonmthreshC_adj), 1, 0);
  gtk_widget_show (spinbuttonmthreshC);
  gtk_table_attach (GTK_TABLE (table2), spinbuttonmthreshC, 1, 2, 1, 2,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbuttonmthreshC), TRUE);

  label13 = gtk_label_new (_("Area Combing Threshold"));
  gtk_widget_show (label13);
  gtk_table_attach (GTK_TABLE (table2), label13, 0, 1, 2, 3,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label13), 0, 0.5);

  spinbuttoncthresh_adj = gtk_adjustment_new (1, 0, 255, 1, 10, 10);
  spinbuttoncthresh = gtk_spin_button_new (GTK_ADJUSTMENT (spinbuttoncthresh_adj), 1, 0);
  gtk_widget_show (spinbuttoncthresh);
  gtk_table_attach (GTK_TABLE (table2), spinbuttoncthresh, 1, 2, 2, 3,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);

  label14 = gtk_label_new (_("Combed Treshold"));
  gtk_widget_show (label14);
  gtk_table_attach (GTK_TABLE (table2), label14, 0, 1, 3, 4,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label14), 0, 0.5);

  spinbuttonMI_adj = gtk_adjustment_new (1, 0, 255, 1, 10, 10);
  spinbuttonMI = gtk_spin_button_new (GTK_ADJUSTMENT (spinbuttonMI_adj), 1, 0);
  gtk_widget_show (spinbuttonMI);
  gtk_table_attach (GTK_TABLE (table2), spinbuttonMI, 1, 2, 3, 4,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbuttonMI), TRUE);

  label15 = gtk_label_new (_("Artefact Protection threshold "));
  gtk_widget_show (label15);
  gtk_table_attach (GTK_TABLE (table2), label15, 0, 1, 4, 5,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label15), 0, 0.5);

  spinbuttonAP_adj = gtk_adjustment_new (1, 0, 255, 1, 10, 10);
  spinbuttonAP = gtk_spin_button_new (GTK_ADJUSTMENT (spinbuttonAP_adj), 1, 0);
  gtk_widget_show (spinbuttonAP);
  gtk_table_attach (GTK_TABLE (table2), spinbuttonAP, 1, 2, 4, 5,
                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbuttonAP), TRUE);

  dialog_action_area1 = GTK_DIALOG (dialog1)->action_area;
  gtk_widget_show (dialog_action_area1);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);

  cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel");
  gtk_widget_show (cancelbutton1);
  gtk_dialog_add_action_widget (GTK_DIALOG (dialog1), cancelbutton1, GTK_RESPONSE_CANCEL);
  GTK_WIDGET_SET_FLAGS (cancelbutton1, GTK_CAN_DEFAULT);

  okbutton1 = gtk_button_new_from_stock ("gtk-ok");
  gtk_widget_show (okbutton1);
  gtk_dialog_add_action_widget (GTK_DIALOG (dialog1), okbutton1, GTK_RESPONSE_OK);
  GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (dialog1, dialog1, "dialog1");
  GLADE_HOOKUP_OBJECT_NO_REF (dialog1, dialog_vbox1, "dialog_vbox1");
  GLADE_HOOKUP_OBJECT (dialog1, vbox1, "vbox1");
  GLADE_HOOKUP_OBJECT (dialog1, table1, "table1");
  GLADE_HOOKUP_OBJECT (dialog1, label1, "label1");
  GLADE_HOOKUP_OBJECT (dialog1, comboboxOrder, "comboboxOrder");
  GLADE_HOOKUP_OBJECT (dialog1, label2, "label2");
  GLADE_HOOKUP_OBJECT (dialog1, comboboxInterpolate, "comboboxInterpolate");
  GLADE_HOOKUP_OBJECT (dialog1, label3, "label3");
  GLADE_HOOKUP_OBJECT (dialog1, comboboxType, "comboboxType");
  GLADE_HOOKUP_OBJECT (dialog1, label4, "label4");
  GLADE_HOOKUP_OBJECT (dialog1, comboboxMnt, "comboboxMnt");
  GLADE_HOOKUP_OBJECT (dialog1, label7, "label7");
  GLADE_HOOKUP_OBJECT (dialog1, checkbuttonChroma, "checkbuttonChroma");
  GLADE_HOOKUP_OBJECT (dialog1, label8, "label8");
  GLADE_HOOKUP_OBJECT (dialog1, checkbuttonTryweave, "checkbuttonTryweave");
  GLADE_HOOKUP_OBJECT (dialog1, label10, "label10");
  GLADE_HOOKUP_OBJECT (dialog1, checkbuttonDenoise, "checkbuttonDenoise");
  GLADE_HOOKUP_OBJECT (dialog1, label9, "label9");
  GLADE_HOOKUP_OBJECT (dialog1, combobox5, "combobox5");
  GLADE_HOOKUP_OBJECT (dialog1, label5, "label5");
  GLADE_HOOKUP_OBJECT (dialog1, checkbuttonSharp, "checkbuttonSharp");
  GLADE_HOOKUP_OBJECT (dialog1, label16, "label16");
  GLADE_HOOKUP_OBJECT (dialog1, checkbuttonFull, "checkbuttonFull");
  GLADE_HOOKUP_OBJECT (dialog1, label6, "label6");
  GLADE_HOOKUP_OBJECT (dialog1, combobox6, "combobox6");
  GLADE_HOOKUP_OBJECT (dialog1, table2, "table2");
  GLADE_HOOKUP_OBJECT (dialog1, label11, "label11");
  GLADE_HOOKUP_OBJECT (dialog1, label12, "label12");
  GLADE_HOOKUP_OBJECT (dialog1, spinbuttonmthreshL, "spinbuttonmthreshL");
  GLADE_HOOKUP_OBJECT (dialog1, spinbuttonmthreshC, "spinbuttonmthreshC");
  GLADE_HOOKUP_OBJECT (dialog1, label13, "label13");
  GLADE_HOOKUP_OBJECT (dialog1, spinbuttoncthresh, "spinbuttoncthresh");
  GLADE_HOOKUP_OBJECT (dialog1, label14, "label14");
  GLADE_HOOKUP_OBJECT (dialog1, spinbuttonMI, "spinbuttonMI");
  GLADE_HOOKUP_OBJECT (dialog1, label15, "label15");
  GLADE_HOOKUP_OBJECT (dialog1, spinbuttonAP, "spinbuttonAP");
  GLADE_HOOKUP_OBJECT_NO_REF (dialog1, dialog_action_area1, "dialog_action_area1");
  GLADE_HOOKUP_OBJECT (dialog1, cancelbutton1, "cancelbutton1");
  GLADE_HOOKUP_OBJECT (dialog1, okbutton1, "okbutton1");

  return dialog1;
}
Esempio n. 22
0
void
gtr_confirm_remove (GtkWindow  * parent,
                    TrCore     * core,
                    GSList     * torrent_ids,
                    gboolean     delete_files)
{
    GSList * l;
    GtkWidget * d;
    GString * primary_text;
    GString * secondary_text;
    struct delete_data * dd;
    int connected = 0;
    int incomplete = 0;
    const int count = g_slist_length (torrent_ids);

    if (!count)
        return;

    dd = g_new0 (struct delete_data, 1);
    dd->core = core;
    dd->torrent_ids = torrent_ids;
    dd->delete_files = delete_files;

    for (l=torrent_ids; l!=NULL; l=l->next)
    {
        const int id = GPOINTER_TO_INT (l->data);
        tr_torrent * tor = gtr_core_find_torrent (core, id);
        const tr_stat * stat = tr_torrentStat (tor);
        if (stat->leftUntilDone) ++incomplete;
        if (stat->peersConnected) ++connected;
    }

    primary_text = g_string_new (NULL);

    if (!delete_files)
    {
        g_string_printf (primary_text, ngettext ("Remove Torrent?",
                                                 "Remove %d Torrents?",
                                                 count), count);
    }
    else
    {
        g_string_printf (primary_text, ngettext ("Delete this torrent's downloaded files?",
                                                 "Delete these %d torrents' downloaded files?",
                                                 count), count);
    }

    secondary_text = g_string_new (NULL);

    if (!incomplete && !connected)
    {
        g_string_assign (secondary_text, ngettext (
                "Once removed, continuing the transfer will require the torrent file or magnet link.",
                "Once removed, continuing the transfers will require the torrent files or magnet links.",
                count));
    }
    else if (count == incomplete)
    {
        g_string_assign (secondary_text, ngettext ("This torrent has not finished downloading.",
                                                   "These torrents have not finished downloading.",
                                                   count));
    }
    else if (count == connected)
    {
        g_string_assign (secondary_text, ngettext ("This torrent is connected to peers.",
                                                   "These torrents are connected to peers.",
                                                   count));
    }
    else
    {
        if (connected)
            g_string_append (secondary_text, ngettext ("One of these torrents is connected to peers.",
                                                       "Some of these torrents are connected to peers.",
                                                       connected));
        if (connected && incomplete)
            g_string_append (secondary_text, "\n");

        if (incomplete)
            g_string_assign (secondary_text, ngettext ("One of these torrents has not finished downloading.",
                                                       "Some of these torrents have not finished downloading.",
                                                       incomplete));
    }

    d = gtk_message_dialog_new_with_markup (parent,
                                            GTK_DIALOG_DESTROY_WITH_PARENT,
                                            GTK_MESSAGE_QUESTION,
                                            GTK_BUTTONS_NONE,
                                            "<big><b>%s</b></big>",
                                            primary_text->str);
    if (secondary_text->len)
        gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (d),
                                                    "%s", secondary_text->str);
    gtk_dialog_add_buttons (GTK_DIALOG (d),
                            _("_Cancel"), GTK_RESPONSE_CANCEL,
                          (delete_files ? _("_Delete"):
                              _("Remove")), GTK_RESPONSE_ACCEPT,
                            NULL);

    gtk_dialog_set_default_response (GTK_DIALOG (d), GTK_RESPONSE_CANCEL);

    g_signal_connect (d, "response", G_CALLBACK (on_remove_dialog_response), dd);
    gtk_widget_show_all (d);

    g_string_free (primary_text, TRUE);
    g_string_free (secondary_text, TRUE);
}
Esempio n. 23
0
static void
fnr_dialog_setup_common (GtkWidget *dialog, gboolean is_replace, DDisplay *ddisp)
{
  GtkWidget *vbox;
  GtkWidget *hbox;
  GtkWidget *label;
  GtkWidget *search_entry;
  GtkWidget *match_case;
  GtkWidget *match_word;
  GtkWidget *match_all_properties;

  gtk_dialog_set_default_response (GTK_DIALOG (dialog), RESPONSE_FIND);

  /* don't destroy dialog when window manager close button pressed */
  g_signal_connect(G_OBJECT (dialog), "response",
		   G_CALLBACK(fnr_respond), ddisp);
  g_signal_connect(G_OBJECT(dialog), "delete_event",
		   G_CALLBACK(gtk_widget_hide), NULL);
  g_signal_connect(GTK_OBJECT(dialog), "delete_event",
		   G_CALLBACK(gtk_true), NULL);

  vbox = GTK_DIALOG(dialog)->vbox;

  hbox = gtk_hbox_new (FALSE, 12);
  label = gtk_label_new_with_mnemonic (_("_Search for:"));
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
  search_entry = gtk_entry_new ();
  g_object_set_data (G_OBJECT (dialog), "search-entry", search_entry);
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), search_entry);
  gtk_entry_set_width_chars (GTK_ENTRY (search_entry), 30);
  gtk_box_pack_start (GTK_BOX (hbox), search_entry, TRUE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 6);
  
  if (is_replace) {
    GtkWidget *replace_entry;

    hbox = gtk_hbox_new (FALSE, 12);
    label = gtk_label_new_with_mnemonic (_("Replace _with:"));
    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
    replace_entry = gtk_entry_new ();
    g_object_set_data (G_OBJECT (dialog), "replace-entry", replace_entry);
    gtk_label_set_mnemonic_widget (GTK_LABEL (label), replace_entry);
    gtk_entry_set_width_chars (GTK_ENTRY (replace_entry), 30);
    gtk_box_pack_start (GTK_BOX (hbox), replace_entry, TRUE, TRUE, 0);
    gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 6);
  }

  match_case = gtk_check_button_new_with_mnemonic (_("_Match case"));
  gtk_box_pack_start (GTK_BOX (vbox), match_case, FALSE, FALSE, 6);
  g_object_set_data (G_OBJECT (dialog), "match-case", match_case);

  match_word = gtk_check_button_new_with_mnemonic (_("Match _entire word only"));
  gtk_box_pack_start (GTK_BOX (vbox), match_word, FALSE, FALSE, 6);
  g_object_set_data (G_OBJECT (dialog), "match-word", match_word);

  match_all_properties = gtk_check_button_new_with_mnemonic (_("Match _all properties (not just object name)"));
  gtk_box_pack_start (GTK_BOX (vbox), match_all_properties, FALSE, FALSE, 6);
  g_object_set_data (G_OBJECT (dialog), "match-all-properties", match_all_properties);
  if (is_replace)
    gtk_widget_set_sensitive (GTK_WIDGET (match_all_properties), FALSE);
    

  gtk_widget_show_all (vbox);
}
static GObject*
close_confirmation_dialog_constructor (GType type,
                                       guint n_construct_properties,
                                       GObjectConstructParam *construct_params)
{
  GObject *object;
  CloseConfirmationDialog *dialog;
  GtkWidget *hbox, *image, *vbox, *label;
  GtkTreeIter iter;
  gboolean ret, single_page;
  gchar *tmp, *str;
  const gchar *cstr;

  /* chain up to constructor of parent class */
  object =
    G_OBJECT_CLASS (close_confirmation_dialog_parent_class)->constructor (
      type,
      n_construct_properties,
      construct_params);
  dialog = CLOSE_CONFIRMATION_DIALOG (object);

  g_object_set (dialog,
                /* GtkDialog */
                "has-separator",     FALSE,
                /* GtkWindow */
                "resizable",         FALSE,
                "skip-taskbar-hint", TRUE,
                /* GtkContainer */
                "border-width",      5,
                NULL);
  g_object_set (GTK_DIALOG (dialog)->vbox,
                /* GtkBox */
                "spacing", 14,
                NULL);
  g_object_set (GTK_DIALOG (dialog)->action_area,
                /* GtkBox */
                "spacing",      6,
                /* GtkContainer */
                "border-width", 5,
                NULL);

  /* check if there is one or more than one page with changes */
  ret = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (
                                         dialog->store_unsaved_pages),
                                       &iter);
  g_assert (ret);
  single_page = !gtk_tree_model_iter_next (GTK_TREE_MODEL (
                                             dialog->store_unsaved_pages),
                                           &iter);

  /* here starts the layout of the dialog */
  hbox = GTK_WIDGET (g_object_new (GTK_TYPE_HBOX,
                                   /* GtkContainer */
                                   "border-width", 5,
                                   /* GtkBox */
                                   "homogeneous",  FALSE,
                                   "spacing",      12,
                                   NULL));

  /* warning image */
  image = GTK_WIDGET (g_object_new (GTK_TYPE_IMAGE,
                                    /* GtkMisc */
                                    "xalign",    0.5,
                                    "yalign",    0.0,
                                    /* GtkImage */
                                    "stock",     GTK_STOCK_DIALOG_WARNING,
                                    "icon-size", GTK_ICON_SIZE_DIALOG,
                                    NULL));
  gtk_box_pack_start (GTK_BOX (hbox), image,
                      FALSE, FALSE, 0);

  /* vertical box on the right hand side of the dialog */
  vbox = GTK_WIDGET (g_object_new (GTK_TYPE_VBOX,
                                   /* GtkBox */
                                   "homogeneous", FALSE,
                                   "spacing",     12,
                                   NULL));

  /* primary label */
  if (single_page) {
    /* single page */
    gchar *page_name;

    page_name = get_page_name (GTK_TREE_MODEL (dialog->store_unsaved_pages),
                               NULL);
    tmp = g_strdup_printf (
      _("Save the changes to schematic \"%1$s\" before closing?"),
      page_name);
    g_free (page_name);
  } else {
    /* multi page */
    tmp = g_strdup_printf (
      _("There are %1$d schematics with unsaved changes. "
        "Save changes before closing?"),
      count_pages (GTK_TREE_MODEL (dialog->store_unsaved_pages)));
  }
  str = g_strconcat ("<big><b>", tmp, "</b></big>", NULL);
  g_free (tmp);
  label = GTK_WIDGET (g_object_new (GTK_TYPE_LABEL,
                                    /* GtkMisc */
                                    "xalign",     0.0,
                                    "yalign",     0.0,
                                    "selectable", TRUE,
                                    /* GtkLabel */
                                    "wrap",       TRUE,
                                    "use-markup", TRUE,
                                    "label",      str,
                                    NULL));
  g_free (str);
  gtk_box_pack_start (GTK_BOX (vbox), label,
                      FALSE, FALSE, 0);

  if (!single_page) {
    /* more than one page with changes, display each page and offer */
    /* the opportunity to save them before exiting */
    gtk_box_pack_start (GTK_BOX (vbox),
                        close_confirmation_dialog_build_page_list (dialog),
                        FALSE, FALSE, 0);
  }

  /* secondary label */
  cstr = _("If you don't save, all your changes will be permanently lost.");
  label = GTK_WIDGET (g_object_new (GTK_TYPE_LABEL,
                                    /* GtkMisc */
                                    "xalign",     0.0,
                                    "yalign",     0.0,
                                    "selectable", TRUE,
                                    /* GtkLabel */
                                    "wrap",       TRUE,
                                    "label",      cstr,
                                    NULL));
  gtk_box_pack_start (GTK_BOX (vbox), label,
                      FALSE, FALSE, 0);


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


  /* add buttons to dialog action area */
  gtk_dialog_add_buttons (GTK_DIALOG (dialog),
                          _("Close _without saving"), GTK_RESPONSE_NO,
                          GTK_STOCK_CANCEL,           GTK_RESPONSE_CANCEL,
                          GTK_STOCK_SAVE,             GTK_RESPONSE_YES,
                          NULL);

  /* Set the alternative button order (ok, cancel, help) for other systems */
  gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog),
                                          GTK_RESPONSE_YES,
                                          GTK_RESPONSE_NO,
                                          GTK_RESPONSE_CANCEL,
                                          -1);

  gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES);

  /* all done, let's show the contents of the dialog */
  gtk_widget_show_all (hbox);

  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox,
                      FALSE, FALSE, 0);

  return object;
}
Esempio n. 25
0
void
DictMngr::CreateReorderDialog()
{
    GtkWidget *dialog, *selector;
    GtkCellRenderer *renderer;
    HildonTouchSelectorColumn *column;
    GtkTreeModel *tree_model;
    GtkTreeIter iter, iter2;
    GtkTreePath *path;
    gboolean iter_valid = TRUE;
    std::list < std::string > selected_dict_list;
    GtkListStore *dict_list = NULL;
    const gint RESPONSE_FIRST = 1;
    const gint RESPONSE_UP = 2;
    const gint RESPONSE_DOWN = 3;
    const gint RESPONSE_LAST = 4;
    gint response;

    dict_list = gtk_list_store_new(N_DICT_INFO_COLUMNS,
				   G_TYPE_STRING,	/* bookname */
				   G_TYPE_STRING);	/* filename */

    /* create dialog */
    dialog = gtk_dialog_new();
    gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
    gtk_window_set_title(GTK_WINDOW(dialog), _("Reorder"));
    gtk_dialog_add_button(GTK_DIALOG(dialog), _("First"), RESPONSE_FIRST);
    gtk_dialog_add_button(GTK_DIALOG(dialog), _("Up"), RESPONSE_UP);
    gtk_dialog_add_button(GTK_DIALOG(dialog), _("Down"), RESPONSE_DOWN);
    gtk_dialog_add_button(GTK_DIALOG(dialog), _("Last"), RESPONSE_LAST);
    gtk_dialog_add_button(GTK_DIALOG(dialog), "OK", GTK_RESPONSE_ACCEPT);
    gtk_window_set_default_size(GTK_WINDOW(dialog), -1, 400);

    /* dictionary selector */
    selector = hildon_touch_selector_new();
    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), selector);

    renderer = gtk_cell_renderer_text_new();
    g_object_set(G_OBJECT(renderer),
		 "xpad", 10,
		 "ellipsize", PANGO_ELLIPSIZE_END,
		 "ellipsize-set", TRUE,
		 NULL);

    column =
	hildon_touch_selector_append_column(HILDON_TOUCH_SELECTOR
					    (selector),
					    GTK_TREE_MODEL(dict_list),
					    renderer, "text", BOOKNAME_DICT_INFO_COLUMN, NULL);
    hildon_touch_selector_column_set_text_column(column, 0);

    /* fill list with selected dictionaries */
    oStarDict->oConf->GetStringList("/apps/maemo/mstardict/dict_list", selected_dict_list);
    for (std::list < std::string >::iterator i = selected_dict_list.begin();
	 i != selected_dict_list.end(); ++i) {
	DictInfo dictinfo;

	dictinfo.load_from_ifo_file(i->c_str(), 0);
	gtk_list_store_append(dict_list, &iter);
	gtk_list_store_set(dict_list, &iter,
			   BOOKNAME_DICT_INFO_COLUMN,
			   dictinfo.bookname.c_str(), FILENAME_DICT_INFO_COLUMN, i->c_str(), -1);
    }
    g_object_unref(dict_list);

    /* show dialog */
    gtk_widget_show_all(GTK_WIDGET(dialog));

    /* run the dialog */
    while (TRUE) {
        response = gtk_dialog_run(GTK_DIALOG(dialog));
        switch(response) {
        case RESPONSE_FIRST:
            tree_model = hildon_touch_selector_get_model(HILDON_TOUCH_SELECTOR(selector), BOOKNAME_DICT_INFO_COLUMN);
            if (hildon_touch_selector_get_selected(HILDON_TOUCH_SELECTOR(selector), BOOKNAME_DICT_INFO_COLUMN, &iter)) {
                gtk_list_store_move_after(GTK_LIST_STORE(tree_model), &iter, NULL);
                hildon_touch_selector_center_on_selected(HILDON_TOUCH_SELECTOR(selector));
            }
            break;
        case RESPONSE_UP:
            tree_model = hildon_touch_selector_get_model(HILDON_TOUCH_SELECTOR(selector), BOOKNAME_DICT_INFO_COLUMN);
            if (hildon_touch_selector_get_selected(HILDON_TOUCH_SELECTOR(selector), BOOKNAME_DICT_INFO_COLUMN, &iter)) {
                path = gtk_tree_model_get_path(tree_model, &iter);
                gtk_tree_path_prev(path);
                if (gtk_tree_model_get_iter(tree_model, &iter2, path)) {
                    gtk_list_store_swap(GTK_LIST_STORE(tree_model), &iter, &iter2);
                }
                gtk_tree_path_free(path);
                hildon_touch_selector_center_on_selected(HILDON_TOUCH_SELECTOR(selector));
            }
            break;
        case RESPONSE_DOWN:
            tree_model = hildon_touch_selector_get_model(HILDON_TOUCH_SELECTOR(selector), BOOKNAME_DICT_INFO_COLUMN);
            if (hildon_touch_selector_get_selected(HILDON_TOUCH_SELECTOR(selector), BOOKNAME_DICT_INFO_COLUMN, &iter)) {
                path = gtk_tree_model_get_path(tree_model, &iter);
                gtk_tree_path_next(path);
                if (gtk_tree_model_get_iter(tree_model, &iter2, path)) {
                    gtk_list_store_swap(GTK_LIST_STORE(tree_model), &iter, &iter2);
                }
                gtk_tree_path_free(path);
                hildon_touch_selector_center_on_selected(HILDON_TOUCH_SELECTOR(selector));
            }
            break;
        case RESPONSE_LAST:
            tree_model = hildon_touch_selector_get_model(HILDON_TOUCH_SELECTOR(selector), BOOKNAME_DICT_INFO_COLUMN);
            if (hildon_touch_selector_get_selected(HILDON_TOUCH_SELECTOR(selector), BOOKNAME_DICT_INFO_COLUMN, &iter)) {
                gtk_list_store_move_before(GTK_LIST_STORE(tree_model), &iter, NULL);
                hildon_touch_selector_center_on_selected(HILDON_TOUCH_SELECTOR(selector));
            }
            break;
        case GTK_RESPONSE_ACCEPT:
            tree_model = hildon_touch_selector_get_model(HILDON_TOUCH_SELECTOR(selector), BOOKNAME_DICT_INFO_COLUMN);
            iter_valid = gtk_tree_model_get_iter_first(tree_model, &iter);
            selected_dict_list.clear();
            while (iter_valid) {
                const gchar *filename;
                gtk_tree_model_get(GTK_TREE_MODEL(tree_model), &iter,
                                   FILENAME_DICT_INFO_COLUMN, &filename, -1);
                selected_dict_list.push_back(std::string(filename));

                iter_valid = gtk_tree_model_iter_next(tree_model, &iter);
            }
            if (oStarDict->oConf->SetStringList("/apps/maemo/mstardict/dict_list", selected_dict_list)) {
                /* reload dictionaries */
                ReLoadDictionaries(selected_dict_list);
            }
            gtk_widget_destroy(GTK_WIDGET(dialog));
            return;
        default:
            gtk_widget_destroy(GTK_WIDGET(dialog));
            return;
        }
    }
}
/*! \brief Asks for confirmation before closing a window.
 *  \par Function Description
 *  This function asks the user to confirm its closing order for
 *  the given window.
 *
 *  The user is given the possibility to save the pages that currently
 *  have unsaved changes, if any.
 *
 *  It returns TRUE if the user really accepts the close of the
 *  window. Otherwise the user has somehow cancelled and the window
 *  must not be closed.
 *
 *  \param [in] w_current The toplevel environment.
 *  \returns TRUE if the window can be closed, FALSE otherwise.
 */
gboolean
x_dialog_close_window (GschemToplevel *w_current)
{
  TOPLEVEL *toplevel = gschem_toplevel_get_toplevel (w_current);
  GList *iter;
  GtkWidget *dialog;
  PAGE *p_current;
  PAGE *keep_page;
  GList *unsaved_pages, *p_unsaved;
  gboolean ret = FALSE;

  keep_page = toplevel->page_current;

  for ( iter = geda_list_get_glist( toplevel->pages ), unsaved_pages = NULL;
        iter != NULL;
        iter = g_list_next( iter ) ) {

    p_current = (PAGE*)iter->data;

    if (p_current->CHANGED) {
      unsaved_pages = g_list_append (unsaved_pages, (gpointer)p_current);
    }
  }

  if (unsaved_pages == NULL) {
    /* no page with unsaved changes, close window */
    return TRUE;
  }

  dialog = GTK_WIDGET (g_object_new (TYPE_CLOSE_CONFIRMATION_DIALOG,
                                     "unsaved-pages", unsaved_pages,
                                     NULL));

  gtk_window_set_transient_for (GTK_WINDOW (dialog),
                                GTK_WINDOW (w_current->main_window));

  g_list_free (unsaved_pages);
  switch (gtk_dialog_run (GTK_DIALOG (dialog))) {
      case GTK_RESPONSE_NO:
        /* action selected: close without saving */
        /* discard changes, ok to close window */
        ret = TRUE;
        break;

      case GTK_RESPONSE_YES:
        /* action selected: save */
        g_object_get (dialog,
                      "selected-pages", &unsaved_pages,
                      NULL);
        for (p_unsaved = unsaved_pages, ret = TRUE;
             p_unsaved != NULL;
             p_unsaved = g_list_next (p_unsaved)) {
          p_current = (PAGE*)p_unsaved->data;

          s_page_goto (toplevel, p_current);
          gschem_toplevel_page_changed (w_current);

          i_callback_file_save(w_current, 0, NULL);
          /* if user cancelled previous, do not close window */
          ret &= !p_current->CHANGED;
        }
        g_list_free (unsaved_pages);
        break;

      case GTK_RESPONSE_CANCEL:
        /* action selected: cancel */
        /* fall through */
      default:
        /* Hit when the user breaks out of the dialog with the escape key
         * or otherwise destroys the dialog window without a proper response */
        ret = FALSE;
        break;
  }
  gtk_widget_destroy (dialog);

  /* Switch back to the page we were on */
  g_return_val_if_fail (keep_page != NULL, ret);
  s_page_goto (toplevel, keep_page);
  gschem_toplevel_page_changed (w_current);

  return ret;
}
Esempio n. 27
0
/**
 * crée la boite de dialogue initiale avec le  GtkIconView
 *
 * \param nom de l'icône
 *
 * \return le nouveau nom de l'icône ou NULL
 * */
gchar * gsb_select_icon_create_window ( gchar *name_icon )
{
    GtkWidget *content_area;
    GtkWidget *hbox;
    GtkWidget *chooser_button;
    GtkWidget *scroll;
    GtkWidget *icon_view;
	gint result;

    devel_debug ( name_icon );

    if ( new_icon && strlen ( new_icon ) > 0 )
        g_free ( new_icon );

    new_icon = g_strdup ( name_icon );

    path_icon = g_path_get_dirname ( name_icon );
    dialog = gtk_dialog_new_with_buttons ( _("Browse icons"),
                            GTK_WINDOW ( run.window ),
                            GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
                            GTK_STOCK_CANCEL,
                            GTK_RESPONSE_REJECT,
                            NULL);

    gtk_window_set_position ( GTK_WINDOW ( dialog ), GTK_WIN_POS_CENTER_ON_PARENT );
    gtk_window_set_resizable ( GTK_WINDOW ( dialog ), TRUE );

    bouton_OK = gtk_dialog_add_button (GTK_DIALOG ( dialog ),
                                GTK_STOCK_OK,
                                GTK_RESPONSE_ACCEPT);
    gtk_widget_set_size_request ( dialog, 400, 450 );
    content_area = GTK_DIALOG ( dialog ) -> vbox;

    /* création hbox pour GtkEntry répertoire et bouton sélection des répertoires */
    hbox = gtk_hbox_new ( FALSE, 5);
	gtk_container_set_border_width ( GTK_CONTAINER( hbox ), 6 );
    gtk_box_pack_start ( GTK_BOX ( content_area ), hbox, FALSE, FALSE, 5 );

    /* création du GtkComboBoxEntry pour la saisie du répertoire */
    entry_text = gsb_select_icon_create_entry_text ( name_icon );
    gtk_box_pack_start ( GTK_BOX ( hbox ), entry_text, TRUE, TRUE, 0 );

    /* création du bouton de sélection des répertoires */
    chooser_button = gtk_button_new_with_label ( _("Browse") );
    gtk_box_pack_start ( GTK_BOX ( hbox ), chooser_button, FALSE, FALSE, 0 );

    /* création de la vue pour les icônes */
    scroll = gtk_scrolled_window_new ( NULL, NULL);
    gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW ( scroll ),
                             GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
    gtk_box_pack_start ( GTK_BOX ( content_area ), scroll, TRUE, TRUE, 0 );
    icon_view = gsb_select_icon_create_icon_view ( name_icon );
    gtk_container_set_border_width ( GTK_CONTAINER( scroll ), 6 );
    gtk_container_add ( GTK_CONTAINER ( scroll ), icon_view );

    /* gestion des signaux */
    g_signal_connect ( G_OBJECT ( icon_view ),
                        "selection-changed",
                        G_CALLBACK( gsb_select_icon_selection_changed ),
                        NULL );

    g_signal_connect ( G_OBJECT ( chooser_button ),
                        "clicked",
                        G_CALLBACK(gsb_select_icon_create_file_chooser),
                        NULL );

    g_signal_connect ( G_OBJECT( entry_text ),
                        "changed",
                        G_CALLBACK( gsb_select_icon_entry_text_changed ),
                        NULL );

    gtk_widget_show_all ( dialog );

    result = gtk_dialog_run (GTK_DIALOG (dialog));
    switch (result)
    {
      case GTK_RESPONSE_ACCEPT:
         devel_debug ( "réponse OK" );
         break;
      default:
         devel_debug ( "réponse Non OK" );
         if ( new_icon && strlen ( new_icon ) > 0 )
            g_free ( new_icon );
         new_icon = NULL;
         break;
    }
    gtk_widget_destroy (dialog);

    return new_icon;
}
Esempio n. 28
0
static void
gimp_file_entry_browse_clicked (GtkWidget     *widget,
                                GimpFileEntry *entry)
{
  GtkFileChooser *chooser;
  gchar          *utf8;
  gchar          *filename;

  utf8 = gtk_editable_get_chars (GTK_EDITABLE (entry->entry), 0, -1);
  filename = g_filename_from_utf8 (utf8, -1, NULL, NULL, NULL);
  g_free (utf8);

  if (! entry->file_dialog)
    {
      const gchar *title = entry->title;

      if (! title)
        {
          if (entry->dir_only)
            title = _("Select Folder");
          else
            title = _("Select File");
        }

      entry->file_dialog =
        gtk_file_chooser_dialog_new (title, NULL,
                                     entry->dir_only ?
                                     GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER :
                                     GTK_FILE_CHOOSER_ACTION_OPEN,

                                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                     GTK_STOCK_OK,     GTK_RESPONSE_OK,

                                     NULL);

        gtk_dialog_set_alternative_button_order (GTK_DIALOG (entry->file_dialog),
                                                GTK_RESPONSE_OK,
                                                GTK_RESPONSE_CANCEL,
                                                -1);

      chooser = GTK_FILE_CHOOSER (entry->file_dialog);

      gtk_window_set_position (GTK_WINDOW (chooser), GTK_WIN_POS_MOUSE);
      gtk_window_set_role (GTK_WINDOW (chooser),
                           "gimp-file-entry-file-dialog");

      g_signal_connect (chooser, "response",
                        G_CALLBACK (gimp_file_entry_chooser_response),
                        entry);
      g_signal_connect (chooser, "delete-event",
                        G_CALLBACK (gtk_true),
                        NULL);

      g_signal_connect_swapped (entry, "unmap",
                                G_CALLBACK (gtk_widget_hide),
                                chooser);
    }
  else
    {
      chooser = GTK_FILE_CHOOSER (entry->file_dialog);
    }

  gtk_file_chooser_set_filename (chooser, filename);

  g_free (filename);

  gtk_window_set_screen (GTK_WINDOW (chooser), gtk_widget_get_screen (widget));
  gtk_window_present (GTK_WINDOW (chooser));
}
Esempio n. 29
0
void
dlg_preferences (GthBrowser *browser)
{
	DialogData       *data;
	GtkWidget        *notebook;
	GList            *children;
	GList            *scan;
	int               page_num;
	GtkWidget        *list_box;
	GtkTreeSelection *selection;

	if (gth_browser_get_dialog (browser, "preferences") != NULL) {
		gtk_window_present (GTK_WINDOW (gth_browser_get_dialog (browser, "preferences")));
		return;
	}

	data = g_new0 (DialogData, 1);
	data->browser = browser;
	data->builder = _gtk_builder_new_from_file ("preferences.ui", NULL);
	data->dialog = GET_WIDGET ("preferences_dialog");

	gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (data->dialog))), 0);
	gth_browser_set_dialog (browser, "preferences", data->dialog);
	gth_hook_invoke ("dlg-preferences-construct", data->dialog, data->browser, data->builder);

	/* widgets */

	list_box = GET_WIDGET ("tabs_listbox");
	notebook = GET_WIDGET ("notebook");
	children = gtk_container_get_children (GTK_CONTAINER (notebook));
	page_num = 0;
	for (scan = children; scan; scan = scan->next) {
		GtkWidget   *child = scan->data;
		const char  *name;
		GtkWidget   *row;
		GtkWidget   *box;
		GtkWidget   *label;

		name = gtk_notebook_get_tab_label_text (GTK_NOTEBOOK (notebook), child);
		if (name == NULL)
			continue;

		if (scan != children)
			_gtk_list_box_add_separator (GTK_LIST_BOX (list_box));

		row = gtk_list_box_row_new ();
		g_object_set_data (G_OBJECT (row), "gth.page_num", GINT_TO_POINTER (page_num));
		gtk_widget_show (row);
		gtk_container_add (GTK_CONTAINER (list_box), row);

		box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
		gtk_container_set_border_width (GTK_CONTAINER (box), 10);
		gtk_widget_show (box);
		gtk_container_add (GTK_CONTAINER (row), box);

		label = gtk_label_new (name);
		gtk_label_set_ellipsize (GTK_LABEL(label), PANGO_ELLIPSIZE_END);
		gtk_widget_show (label);
		gtk_container_add (GTK_CONTAINER (box), label);

		page_num += 1;
	}

	/* Set the signals handlers. */

	g_signal_connect (data->dialog,
			  "destroy",
			  G_CALLBACK (destroy_cb),
			  data);
	g_signal_connect (list_box,
			  "row-activated",
			  G_CALLBACK (list_box_row_activated_cb),
			  data);

	/* run dialog. */

	gtk_window_set_transient_for (GTK_WINDOW (data->dialog), GTK_WINDOW (browser));
	gtk_widget_show (data->dialog);
}
static void
on_dialog_add_edit_reponse (GtkWidget *dialog, int response_id,
                            LogviewFilterManager *manager)
{
  GtkWidget *entry_name, *entry_regex;
  GtkWidget *radio_color, *radio_visible;
  GtkWidget *check_foreground, *check_background;
  GtkWidget *color_foreground, *color_background;
  gchar *old_name;
  const gchar *name;
  const gchar *regex;
  LogviewFilter *filter;
  GtkTextTag *tag;
  GtkBuilder *builder;

  old_name = g_object_get_data (G_OBJECT (manager), "old_name");
  builder = manager->priv->builder;

  entry_name = GTK_WIDGET (gtk_builder_get_object (builder,
                                                   "entry_name"));
  entry_regex = GTK_WIDGET (gtk_builder_get_object (builder,
                                                    "entry_regex"));
  radio_color = GTK_WIDGET (gtk_builder_get_object (builder,
                                                    "radio_color"));
  radio_visible = GTK_WIDGET (gtk_builder_get_object (builder,
                                                      "radio_visible"));
  check_foreground = GTK_WIDGET (gtk_builder_get_object (builder,
                                                         "check_foreground"));
  check_background = GTK_WIDGET (gtk_builder_get_object (builder,
                                                         "check_background"));
  color_foreground = GTK_WIDGET (gtk_builder_get_object (builder,
                                                         "color_foreground"));
  color_background = GTK_WIDGET (gtk_builder_get_object (builder,
                                                         "color_background"));

  if (response_id == GTK_RESPONSE_APPLY) {
    name = gtk_entry_get_text (GTK_ENTRY (entry_name));
    regex = gtk_entry_get_text (GTK_ENTRY (entry_regex));

    if (!check_name (manager, name) || !check_regex (manager, regex)) {
      return;
    }

    filter = logview_filter_new (name, regex);
    tag = gtk_text_tag_new (name);

    if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio_color))) {
      if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_foreground))) {
        GdkColor foreground_color;
        gtk_color_button_get_color (GTK_COLOR_BUTTON (color_foreground),
                                    &foreground_color);
        g_object_set (G_OBJECT (tag), 
                      "foreground-gdk", &foreground_color,
                      "foreground-set", TRUE, NULL);
      }

      if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_background))) {
        GdkColor background_color;
        gtk_color_button_get_color (GTK_COLOR_BUTTON (color_background),
                                    &background_color);
        g_object_set (tag, 
                      "paragraph-background-gdk", &background_color,
                      "paragraph-background-set", TRUE, NULL);
      }
      
      if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_foreground))
          && !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_background))) {
          GtkWidget *error_dialog;

          error_dialog = gtk_message_dialog_new (GTK_WINDOW (manager),
                                                 GTK_DIALOG_MODAL,
                                                 GTK_MESSAGE_ERROR,
                                                 GTK_BUTTONS_CLOSE,
                                                 "%s",
                                                 _("Please specify either foreground or background color!"));
          gtk_dialog_run (GTK_DIALOG (error_dialog));
          gtk_widget_destroy (error_dialog);
          g_object_unref (tag);
          g_object_unref (filter);

          return;
      }
    } else { /* !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio_color)) */
      g_object_set (tag, "invisible", TRUE, NULL);
    }

    if (old_name && !g_str_equal (old_name, name)) {
      logview_prefs_remove_filter (manager->priv->prefs, old_name);
    }

    g_object_set (G_OBJECT (filter), "texttag", tag, NULL);
    g_object_unref (tag);

    logview_prefs_add_filter (manager->priv->prefs, filter);
    g_object_unref (filter);

    logview_filter_manager_update_model (manager);
  }

  gtk_widget_destroy (dialog);
}