/*
 * This function sets the custom list when the language list has changed in
 * the language dialog (launched from language button or F10 menu).
 */
void
lang_set_custom_callback (gchar *language)
{
  GtkListStore *lang_model = mdm_lang_get_model ();
  GtkTreeIter iter;
  gboolean valid;
  char *locale_name;
  int i=0;

  /* Do nothing if there is no language widget */
  if (language_widget == NULL)
     return;

  /*
   * Handle for either combo box or list style, depending on which is being
   * used.
 . */
  if (GTK_IS_COMBO_BOX (language_widget))
    {
      valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (lang_model),
         &iter);
      while (valid)
        {
          gtk_tree_model_get (GTK_TREE_MODEL (lang_model), &iter,
             LOCALE_COLUMN, &locale_name, -1);

          if (strcmp (language, locale_name) == 0)
            {
              gtk_combo_box_set_active (GTK_COMBO_BOX (language_widget), i);
              break;
            }
          valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (lang_model), &iter);
          i++;
       }
    }
  else if (GTK_IS_SCROLLED_WINDOW (language_widget) && 
           GTK_IS_TREE_VIEW (GTK_BIN (language_widget)->child))
    {
      GtkTreeView  *tv = GTK_TREE_VIEW (GTK_BIN (language_widget)->child);
      GtkTreeModel *tm = gtk_tree_view_get_model (tv);
      GtkTreeSelection *selection = gtk_tree_view_get_selection (tv);
      GtkTreeIter loopiter;

      if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (tm), &loopiter))
        {
          do
            {
              char *locale_file;

              gtk_tree_model_get (GTK_TREE_MODEL (tm), &loopiter, GREETER_LIST_ID, &locale_file, -1);
              if (locale_file != NULL && strcmp (language, locale_file) == 0)
                {
                   GtkTreePath *path = gtk_tree_model_get_path (tm, &loopiter);

                   gtk_tree_selection_select_iter (selection, &loopiter);
                   gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (tv),
                                                 path, NULL,
                                                 FALSE, 0.0, 0.0);
                  gtk_tree_path_free (path);
                  break;
               }
           } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (tm), &loopiter));
        }
    }
}
Esempio n. 2
0
int
fe_dcc_open_recv_win (int passive)
{
	GtkWidget *radio, *table, *vbox, *bbox, *view, *exp, *detailbox;
	GtkListStore *store;
	GSList *group;

	if (dccfwin.window)
	{
		if (!passive)
			mg_bring_tofront (dccfwin.window);
		return TRUE;
	}
	dccfwin.window = mg_create_generic_tab ("Transfers", _(DISPLAY_NAME": Uploads and Downloads"),
														 FALSE, TRUE, close_dcc_file_window, NULL,
														 win_width, win_height, &vbox, 0);
	gtk_container_set_border_width (GTK_CONTAINER (dccfwin.window), 3);
	gtk_box_set_spacing (GTK_BOX (vbox), 3);

	store = gtk_list_store_new (N_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING,
										 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
										 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
										 G_TYPE_STRING, G_TYPE_POINTER, GDK_TYPE_COLOR);
	view = gtkutil_treeview_new (vbox, GTK_TREE_MODEL (store), NULL, -1);
	gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (view), TRUE);
	/* Up/Down Icon column */
	gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view), -1, NULL,
																gtk_cell_renderer_pixbuf_new (),
																"pixbuf", COL_TYPE, NULL);
	dcc_add_column (view, COL_STATUS, COL_COLOR, _("Status"), FALSE);
	dcc_add_column (view, COL_FILE,   COL_COLOR, _("File"), FALSE);
	dcc_add_column (view, COL_SIZE,   COL_COLOR, _("Size"), TRUE);
	dcc_add_column (view, COL_POS,    COL_COLOR, _("Position"), TRUE);
	dcc_add_column (view, COL_PERC,   COL_COLOR, "%", TRUE);
	dcc_add_column (view, COL_SPEED,  COL_COLOR, "KB/s", TRUE);
	dcc_add_column (view, COL_ETA,    COL_COLOR, _("ETA"), FALSE);
	dcc_add_column (view, COL_NICK,   COL_COLOR, _("Nick"), FALSE);

	gtk_tree_view_column_set_expand (gtk_tree_view_get_column (GTK_TREE_VIEW (view), COL_FILE), TRUE);
	gtk_tree_view_column_set_expand (gtk_tree_view_get_column (GTK_TREE_VIEW (view), COL_NICK), TRUE);

	dccfwin.list = view;
	dccfwin.store = store;
	dccfwin.sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
	view_mode = VIEW_BOTH;
	gtk_tree_selection_set_mode (dccfwin.sel, GTK_SELECTION_MULTIPLE);

	if (!prefs.hex_gui_tab_utils)
		g_signal_connect (G_OBJECT (dccfwin.window), "configure_event",
								G_CALLBACK (dcc_configure_cb), 0);
	g_signal_connect (G_OBJECT (dccfwin.sel), "changed",
							G_CALLBACK (dcc_row_cb), NULL);
	/* double click */
	g_signal_connect (G_OBJECT (view), "row-activated",
							G_CALLBACK (dcc_dclick_cb), NULL);

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

	radio = gtk_radio_button_new_with_mnemonic (NULL, _("Both"));
	g_signal_connect (G_OBJECT (radio), "toggled",
							G_CALLBACK (dcc_toggle), GINT_TO_POINTER (VIEW_BOTH));
	gtk_table_attach (GTK_TABLE (table), radio, 3, 4, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
	group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio));

	radio = gtk_radio_button_new_with_mnemonic (group, _("Uploads"));
	g_signal_connect (G_OBJECT (radio), "toggled",
							G_CALLBACK (dcc_toggle), GINT_TO_POINTER (VIEW_UPLOAD));
	gtk_table_attach (GTK_TABLE (table), radio, 1, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
	group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio));

	radio = gtk_radio_button_new_with_mnemonic (group, _("Downloads"));
	g_signal_connect (G_OBJECT (radio), "toggled",
							G_CALLBACK (dcc_toggle), GINT_TO_POINTER (VIEW_DOWNLOAD));
	gtk_table_attach (GTK_TABLE (table), radio, 2, 3, 0, 1, GTK_FILL, GTK_FILL, 0, 0);

	exp = gtk_expander_new (_("Details"));
	gtk_table_attach (GTK_TABLE (table), exp, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);

	detailbox = gtk_table_new (3, 3, FALSE);
	gtk_table_set_col_spacings (GTK_TABLE (detailbox), 6);
	gtk_table_set_row_spacings (GTK_TABLE (detailbox), 2);
	gtk_container_set_border_width (GTK_CONTAINER (detailbox), 6);
	g_signal_connect (G_OBJECT (exp), "activate",
							G_CALLBACK (dcc_exp_cb), detailbox);
	gtk_table_attach (GTK_TABLE (table), detailbox, 0, 4, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);

	dccfwin.file_label = dcc_detail_label (_("File:"), detailbox, 0);
	dccfwin.address_label = dcc_detail_label (_("Address:"), detailbox, 1);

	bbox = gtk_hbutton_box_new ();
	gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_SPREAD);
	gtk_box_pack_end (GTK_BOX (vbox), bbox, FALSE, FALSE, 2);

	dccfwin.abort_button = gtkutil_button (bbox, GTK_STOCK_CANCEL, 0, abort_clicked, 0, _("Abort"));
	dccfwin.accept_button = gtkutil_button (bbox, GTK_STOCK_APPLY, 0, accept_clicked, 0, _("Accept"));
	dccfwin.resume_button = gtkutil_button (bbox, GTK_STOCK_REFRESH, 0, resume_clicked, 0, _("Resume"));
	dccfwin.open_button = gtkutil_button (bbox, 0, 0, browse_dcc_folder, 0, _("Open Folder..."));
	gtk_widget_set_sensitive (dccfwin.accept_button, FALSE);
	gtk_widget_set_sensitive (dccfwin.resume_button, FALSE);
	gtk_widget_set_sensitive (dccfwin.abort_button, FALSE);

	dcc_fill_window (3);
	gtk_widget_show_all (dccfwin.window);
	gtk_widget_hide (detailbox);

	return FALSE;
}
Esempio n. 3
0
static void
create_categories_section (GtkWidget *categories_vbox, GUI *appGUI)
{
	GtkTreeViewColumn *column;
	GtkCellRenderer *renderer;
	GtkWidget *table, *scrolledwindow, *treeview;

	table = gtk_table_new (4, 3, FALSE);
	gtk_box_pack_start (GTK_BOX (categories_vbox), table, TRUE, TRUE, 0);
	gtk_container_set_border_width (GTK_CONTAINER (table), 8);
	gtk_table_set_row_spacings (GTK_TABLE (table), 8);
	gtk_table_set_col_spacings (GTK_TABLE (table), 4);

	appGUI->opt->tasks_category_entry = gtk_entry_new ();
	gtk_table_attach (GTK_TABLE (table), appGUI->opt->tasks_category_entry, 0, 1, 3, 4,
	                  (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0);
	g_signal_connect (G_OBJECT (appGUI->opt->tasks_category_entry), "key_release_event",
	                  G_CALLBACK (tasks_category_entry_key_release_cb), appGUI);

	scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
	gtk_table_attach (GTK_TABLE (table), scrolledwindow, 0, 3, 0, 3,
	                  (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow), GTK_SHADOW_IN);

	treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (appGUI->opt->tasks_category_store));
	gtk_container_add (GTK_CONTAINER (scrolledwindow), treeview);
	gtk_container_set_border_width (GTK_CONTAINER (treeview), 4);
	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), TRUE);
	gtk_tree_view_set_reorderable (GTK_TREE_VIEW (treeview), TRUE);
	gtk_tree_view_set_enable_search (GTK_TREE_VIEW (treeview), FALSE);
	gtk_widget_set_size_request (treeview, -1, 120);
	appGUI->opt->tasks_category_treeview = treeview;

	appGUI->opt->tasks_category_select = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
	g_signal_connect (G_OBJECT (appGUI->opt->tasks_category_select), "changed", G_CALLBACK (tasks_category_selected_cb), appGUI);

	renderer = gtk_cell_renderer_text_new ();
	g_object_set (renderer, "editable", TRUE, "editable-set", TRUE, NULL);
	g_signal_connect (G_OBJECT (renderer), "edited", G_CALLBACK (tasks_category_cell_edited_cb), appGUI);

	column = gtk_tree_view_column_new_with_attributes (_("Name"), renderer, "text", TC_COLUMN_NAME, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
	gtk_tree_view_column_set_expand (column, TRUE);

	renderer = gtk_cell_renderer_toggle_new ();    /* Show in calendar */
	column = gtk_tree_view_column_new_with_attributes(_("Calendar"), renderer, "active", TC_COLUMN_CALENDAR, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
	g_signal_connect (renderer, "toggled", G_CALLBACK (tsk_show_in_calendar_toggled), appGUI);

	renderer = gtk_cell_renderer_toggle_new ();    /* Show in tasks list */
	column = gtk_tree_view_column_new_with_attributes (_("Tasks"), renderer, "active", TC_COLUMN_TASKS, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
	g_signal_connect (renderer, "toggled", G_CALLBACK (tsk_show_in_tasks_list_toggled), appGUI);

	if (config.default_stock_icons)
		appGUI->opt->tasks_category_add_button = utl_gui_stock_button (GTK_STOCK_ADD, FALSE);
	else
		appGUI->opt->tasks_category_add_button = utl_gui_stock_button (OSMO_STOCK_BUTTON_ADD, FALSE);
	gtk_widget_set_sensitive (appGUI->opt->tasks_category_add_button, FALSE);
	gtk_table_attach (GTK_TABLE (table), appGUI->opt->tasks_category_add_button, 1, 2, 3, 4,
	                  (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
	g_signal_connect (appGUI->opt->tasks_category_add_button, "clicked", G_CALLBACK (tasks_category_add_cb), appGUI);

	if (config.default_stock_icons)
		appGUI->opt->tasks_category_remove_button = utl_gui_stock_button (GTK_STOCK_REMOVE, FALSE);
	else
		appGUI->opt->tasks_category_remove_button = utl_gui_stock_button (OSMO_STOCK_BUTTON_REMOVE, FALSE);
	gtk_widget_set_sensitive (appGUI->opt->tasks_category_remove_button, FALSE);
	gtk_table_attach (GTK_TABLE (table), appGUI->opt->tasks_category_remove_button, 2, 3, 3, 4,
	                  (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
	g_signal_connect (appGUI->opt->tasks_category_remove_button, "clicked", G_CALLBACK (tasks_category_remove_cb), appGUI);
}
static void
update_source (RBDiscRecorderPlugin *pi,
	       RBShell            *shell)
{
	GtkAction *burn_action, *copy_action;
	gboolean   playlist_active, is_audiocd_active;
	RBSource  *selected_source;
	const char *source_type;

	if (pi->selected_source != NULL) {
		RhythmDBQueryModel *model;

		g_object_get (pi->selected_source, "query-model", &model, NULL);
		g_signal_handlers_disconnect_by_func (model, playlist_row_inserted_cb, pi);
		g_signal_handlers_disconnect_by_func (model, playlist_entries_changed, pi);
		g_object_unref (model);
	}

	g_object_get (shell, "selected-source", &selected_source, NULL);

	/* for now restrict to playlist sources */
	playlist_active = RB_IS_PLAYLIST_SOURCE (selected_source);

	source_type = G_OBJECT_TYPE_NAME (selected_source);
	is_audiocd_active = g_str_equal (source_type, "RBAudioCdSource");

	burn_action = gtk_action_group_get_action (pi->action_group,
						   "MusicPlaylistBurnToDiscPlaylist");
	copy_action = gtk_action_group_get_action (pi->action_group,
						   "MusicAudioCDDuplicate");

	if (pi->enabled && playlist_active && rb_disc_recorder_has_burner (pi)) {
		RhythmDBQueryModel *model;

		g_object_get (selected_source, "query-model", &model, NULL);
		/* monitor for changes, to enable/disable the burn menu item */
		g_signal_connect_object (G_OBJECT (model),
					 "row_inserted",
					 G_CALLBACK (playlist_row_inserted_cb),
					 pi, 0);
		g_signal_connect_object (G_OBJECT (model),
					 "post-entry-delete",
					 G_CALLBACK (playlist_entries_changed),
					 pi, 0);

		playlist_entries_changed (GTK_TREE_MODEL (model), NULL, pi);
		g_object_unref (model);
		gtk_action_set_visible (burn_action, TRUE);
	} else {
		gtk_action_set_visible (burn_action, FALSE);
	}

	if (pi->enabled && is_audiocd_active && is_copy_available (pi)) {
		gtk_action_set_visible (copy_action, TRUE);
	} else {
		gtk_action_set_visible (copy_action, FALSE);
	}

	if (pi->selected_source != NULL) {
		g_object_unref (pi->selected_source);
	}
	pi->selected_source = selected_source;
}
Esempio n. 5
0
void ColorICCSelector::init()
{
    GtkWidget *t;
    gint row = 0;

    _updating = FALSE;
    _dragging = FALSE;

    t = gtk_table_new (5, 3, FALSE);
    gtk_widget_show (t);
    gtk_box_pack_start (GTK_BOX (_csel), t, TRUE, TRUE, 4);

#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
    //guint partCount = _cmsChannelsOf( icSigRgbData );
    gchar const** names = 0;
    gchar const** tips = 0;
    getThings( cmsSigRgbData, names, tips, _fooScales );
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)

    /* Create components */
    row = 0;


    _fixupBtn = gtk_button_new_with_label(_("Fix"));
    g_signal_connect( G_OBJECT(_fixupBtn), "clicked", G_CALLBACK(_fixupHit), (gpointer)this );
    gtk_widget_set_sensitive( _fixupBtn, FALSE );
    gtk_widget_set_tooltip_text( _fixupBtn, _("Fix RGB fallback to match icc-color() value.") );
    //gtk_misc_set_alignment( GTK_MISC (_fixupBtn), 1.0, 0.5 );
    gtk_widget_show( _fixupBtn );
    gtk_table_attach( GTK_TABLE (t), _fixupBtn, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD );

    // Combobox and store with 2 columns : label (0) and full name (1)
    GtkListStore *store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
    _profileSel = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));

    GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
    gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (_profileSel), renderer, TRUE);
    gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (_profileSel), renderer, "text", 0, NULL);

    GtkTreeIter iter;
    gtk_list_store_append (store, &iter);
    gtk_list_store_set (store, &iter, 0, _("<none>"), 1, _("<none>"), -1);

    gtk_widget_show( _profileSel );
    gtk_combo_box_set_active( GTK_COMBO_BOX(_profileSel), 0 );
    gtk_table_attach( GTK_TABLE(t), _profileSel, 1, 2, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD );

#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
    _profChangedID = g_signal_connect( G_OBJECT(_profileSel), "changed", G_CALLBACK(_profileSelected), (gpointer)this );
#else
    gtk_widget_set_sensitive( _profileSel, false );
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)


    row++;

    _fooCount = 4;
    _fooAdj = new GtkAdjustment*[_fooCount];
    _fooSlider = new GtkWidget*[_fooCount];
    _fooBtn = new GtkWidget*[_fooCount];
    _fooLabel = new GtkWidget*[_fooCount];
    _fooMap = new guchar*[_fooCount];

    for ( guint i = 0; i < _fooCount; i++ ) {
        /* Label */
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
        _fooLabel[i] = gtk_label_new_with_mnemonic( names[i] );
#else
        _fooLabel[i] = gtk_label_new_with_mnemonic( "." );
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
        gtk_misc_set_alignment( GTK_MISC (_fooLabel[i]), 1.0, 0.5 );
        gtk_widget_show( _fooLabel[i] );
        gtk_table_attach( GTK_TABLE (t), _fooLabel[i], 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD );

        /* Adjustment */
        gdouble step = static_cast<gdouble>(_fooScales[i]) / 100.0;
        gdouble page = static_cast<gdouble>(_fooScales[i]) / 10.0;
        gint digits = (step > 0.9) ? 0 : 2;
        _fooAdj[i] = GTK_ADJUSTMENT( gtk_adjustment_new( 0.0, 0.0, _fooScales[i],  step, page, page ) );

        /* Slider */
        _fooSlider[i] = sp_color_slider_new( _fooAdj[i] );
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
        gtk_widget_set_tooltip_text( _fooSlider[i], tips[i] );
#else
        gtk_widget_set_tooltip_text( _fooSlider[i], "." );
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
        gtk_widget_show( _fooSlider[i] );
        gtk_table_attach( GTK_TABLE (t), _fooSlider[i], 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)GTK_FILL, XPAD, YPAD );

        _fooBtn[i] = gtk_spin_button_new( _fooAdj[i], step, digits );
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
        gtk_widget_set_tooltip_text( _fooBtn[i], tips[i] );
#else
        gtk_widget_set_tooltip_text( _fooBtn[i], "." );
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
        sp_dialog_defocus_on_enter( _fooBtn[i] );
        gtk_label_set_mnemonic_widget( GTK_LABEL(_fooLabel[i]), _fooBtn[i] );
        gtk_widget_show( _fooBtn[i] );
        gtk_table_attach( GTK_TABLE (t), _fooBtn[i], 2, 3, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD );

        _fooMap[i] = g_new( guchar, 4 * 1024 );
        memset( _fooMap[i], 0x0ff, 1024 * 4 );


        /* Signals */
        g_signal_connect( G_OBJECT( _fooAdj[i] ), "value_changed", G_CALLBACK( _adjustmentChanged ), _csel );

        g_signal_connect( G_OBJECT( _fooSlider[i] ), "grabbed", G_CALLBACK( _sliderGrabbed ), _csel );
        g_signal_connect( G_OBJECT( _fooSlider[i] ), "released", G_CALLBACK( _sliderReleased ), _csel );
        g_signal_connect( G_OBJECT( _fooSlider[i] ), "changed", G_CALLBACK( _sliderChanged ), _csel );

        row++;
    }

    /* Label */
    _label = gtk_label_new_with_mnemonic (_("_A:"));
    gtk_misc_set_alignment (GTK_MISC (_label), 1.0, 0.5);
    gtk_widget_show (_label);
    gtk_table_attach (GTK_TABLE (t), _label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD);

    /* Adjustment */
    _adj = (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, 255.0, 1.0, 10.0, 10.0);

    /* Slider */
    _slider = sp_color_slider_new (_adj);
    gtk_widget_set_tooltip_text (_slider, _("Alpha (opacity)"));
    gtk_widget_show (_slider);
    gtk_table_attach (GTK_TABLE (t), _slider, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)GTK_FILL, XPAD, YPAD);

    sp_color_slider_set_colors( SP_COLOR_SLIDER( _slider ),
                                SP_RGBA32_F_COMPOSE( 1.0, 1.0, 1.0, 0.0 ),
                                SP_RGBA32_F_COMPOSE( 1.0, 1.0, 1.0, 0.5 ),
                                SP_RGBA32_F_COMPOSE( 1.0, 1.0, 1.0, 1.0 ) );


    /* Spinbutton */
    _sbtn = gtk_spin_button_new (GTK_ADJUSTMENT (_adj), 1.0, 0);
    gtk_widget_set_tooltip_text (_sbtn, _("Alpha (opacity)"));
    sp_dialog_defocus_on_enter (_sbtn);
    gtk_label_set_mnemonic_widget (GTK_LABEL(_label), _sbtn);
    gtk_widget_show (_sbtn);
    gtk_table_attach (GTK_TABLE (t), _sbtn, 2, 3, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD);

    /* Signals */
    g_signal_connect (G_OBJECT (_adj), "value_changed",
                        G_CALLBACK (_adjustmentChanged), _csel);

    g_signal_connect (G_OBJECT (_slider), "grabbed",
                        G_CALLBACK (_sliderGrabbed), _csel);
    g_signal_connect (G_OBJECT (_slider), "released",
                        G_CALLBACK (_sliderReleased), _csel);
    g_signal_connect (G_OBJECT (_slider), "changed",
                        G_CALLBACK (_sliderChanged), _csel);
}
Esempio n. 6
0
GtkWidget*
create_windowMain ()
{
	GtkWidget *vbox1;
	GtkWidget *hpaned1;
	GtkWidget *scrolledwindow1;
	GtkWidget *hbuttonbox1;
	GtkWidget *buttonRefresh;
	GtkWidget *buttonConfigure;
	GtkWidget *buttonClose;
	GtkWidget *buttonAbout;
	GdkPixbuf *icon;
	GtkCellRenderer *treeRenderer;
	GtkTreeViewColumn *treeColumn;

	windowMain = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_widget_set_name (windowMain, "windowMain");
	gtk_window_set_title (GTK_WINDOW (windowMain), "USB Viewer");
	gtk_window_set_default_size (GTK_WINDOW (windowMain), 600, 300);

	icon = gdk_pixbuf_new_from_xpm_data((const char **)usbview_icon);
	gtk_window_set_icon(GTK_WINDOW(windowMain), icon);

	vbox1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_widget_set_name (vbox1, "vbox1");
	gtk_widget_show (vbox1);
	gtk_container_add (GTK_CONTAINER (windowMain), vbox1);

	hpaned1 = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
	gtk_widget_set_name (hpaned1, "hpaned1");
	gtk_widget_show (hpaned1);
	gtk_box_pack_start (GTK_BOX (vbox1), hpaned1, TRUE, TRUE, 0);

	treeStore = gtk_tree_store_new (N_COLUMNS,
				G_TYPE_STRING,	/* NAME_COLUMN */
				G_TYPE_INT,	/* DEVICE_ADDR_COLUMN */
				G_TYPE_STRING	/* COLOR_COLUMN */);
	treeUSB = gtk_tree_view_new_with_model (GTK_TREE_MODEL (treeStore));
	treeRenderer = gtk_cell_renderer_text_new ();
	treeColumn = gtk_tree_view_column_new_with_attributes (
					"USB devices",
					treeRenderer,
					"text", NAME_COLUMN,
					"foreground", COLOR_COLUMN,
					NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (treeUSB), treeColumn);
	gtk_widget_set_name (treeUSB, "treeUSB");
	gtk_widget_show (treeUSB);
	gtk_paned_pack1 (GTK_PANED (hpaned1), treeUSB, FALSE, FALSE);

	scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
	gtk_widget_set_name (scrolledwindow1, "scrolledwindow1");
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
	gtk_widget_show (scrolledwindow1);
	gtk_paned_pack2 (GTK_PANED (hpaned1), scrolledwindow1, TRUE, FALSE);

	textDescriptionBuffer = gtk_text_buffer_new(NULL);
	//textDescription = gtk_text_new (NULL, NULL);
	textDescriptionView = gtk_text_view_new_with_buffer(textDescriptionBuffer);
	gtk_widget_set_name (textDescriptionView, "textDescription");
	gtk_text_view_set_editable(GTK_TEXT_VIEW(textDescriptionView), FALSE);
	gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(textDescriptionView), FALSE);
	gtk_widget_show (textDescriptionView);
	gtk_container_add (GTK_CONTAINER (scrolledwindow1), textDescriptionView);

	hbuttonbox1 = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
	gtk_widget_set_name (hbuttonbox1, "hbuttonbox1");
	gtk_widget_show (hbuttonbox1);
	gtk_box_pack_start (GTK_BOX (vbox1), hbuttonbox1, FALSE, FALSE, 5);
	//gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbuttonbox1), 10);
	//gtk_button_box_set_child_size (GTK_BUTTON_BOX (hbuttonbox1), 50, 25);
	//gtk_button_box_set_child_ipadding (GTK_BUTTON_BOX (hbuttonbox1), 25, 10);

	buttonRefresh = gtk_button_new_with_label("Refresh");
	gtk_widget_set_name (buttonRefresh, "buttonRefresh");
	gtk_widget_show (buttonRefresh);
	gtk_container_add (GTK_CONTAINER (hbuttonbox1), buttonRefresh);
	gtk_container_set_border_width (GTK_CONTAINER (buttonRefresh), 4);
	gtk_widget_set_can_default (buttonRefresh, TRUE);

	buttonConfigure = gtk_button_new_with_label ("Configure...");
	gtk_widget_set_name (buttonConfigure, "buttonConfigure");
	gtk_widget_show (buttonConfigure);
	gtk_container_add (GTK_CONTAINER (hbuttonbox1), buttonConfigure);
	gtk_container_set_border_width (GTK_CONTAINER (buttonConfigure), 4);
	gtk_widget_set_can_default (buttonConfigure, TRUE);

	buttonAbout = gtk_button_new_with_label("About");
	gtk_widget_set_name (buttonAbout, "buttonAbout");
	gtk_widget_show (buttonAbout);
	gtk_container_add (GTK_CONTAINER (hbuttonbox1), buttonAbout);
	gtk_container_set_border_width (GTK_CONTAINER (buttonAbout), 4);
	gtk_widget_set_can_default (buttonAbout, TRUE);

	buttonClose = gtk_button_new_with_label("Quit");
	gtk_widget_set_name (buttonClose, "buttonClose");
	gtk_widget_show (buttonClose);
	gtk_container_add (GTK_CONTAINER (hbuttonbox1), buttonClose);
	gtk_container_set_border_width (GTK_CONTAINER (buttonClose), 4);
	gtk_widget_set_can_default (buttonClose, TRUE);

	g_signal_connect (G_OBJECT (windowMain), "delete_event",
			    G_CALLBACK (on_window1_delete_event),
			    NULL);
	g_signal_connect (G_OBJECT (buttonRefresh), "clicked",
			    G_CALLBACK (on_buttonRefresh_clicked),
			    NULL);
	g_signal_connect (G_OBJECT (buttonConfigure), "clicked",
			    G_CALLBACK (on_buttonConfigure_clicked),
			    NULL);
	g_signal_connect (G_OBJECT (buttonAbout), "clicked",
			    G_CALLBACK (on_buttonAbout_clicked),
			    NULL);
	g_signal_connect (G_OBJECT (buttonClose), "clicked",
			    G_CALLBACK (on_buttonClose_clicked),
			    NULL);

	/* create our timer */
	//timer = gtk_timeout_add (2000, on_timer_timeout, 0);
	
	return windowMain;
}
Esempio n. 7
0
/*
 * plugin management
 */
void gtkui_plugin_mgmt(void)
{
   GtkWidget *scrolled, *vbox;
   GtkCellRenderer   *renderer;
   GtkTreeViewColumn *column;

   DEBUG_MSG("gtk_plugin_mgmt");
   
   /* if the object already exist, set the focus to it */
   if (plugins_window) {
      if(GTK_IS_WINDOW (plugins_window))
         gtk_window_present(GTK_WINDOW (plugins_window));
      else
         gtkui_page_present(plugins_window);
      return;
   }

   plugins_window = gtkui_page_new("Plugins", &gtkui_plug_destroy, &gtkui_plugins_detach);
   
   vbox = gtk_vbox_new(FALSE, 0);
   gtk_container_add(GTK_CONTAINER (plugins_window), vbox);
   gtk_widget_show(vbox);
   
  /* list */
   scrolled = gtk_scrolled_window_new(NULL, NULL);
   gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
   gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW (scrolled), GTK_SHADOW_IN);
   gtk_box_pack_start(GTK_BOX(vbox), scrolled, TRUE, TRUE, 0);
   gtk_widget_show(scrolled);
   
   treeview = gtk_tree_view_new();
   gtk_container_add(GTK_CONTAINER (scrolled), treeview);
   gtk_widget_show(treeview);

   selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
   gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
   g_signal_connect (G_OBJECT (treeview), "row_activated", G_CALLBACK (gtkui_select_plugin), NULL);
   
   renderer = gtk_cell_renderer_text_new ();
   column = gtk_tree_view_column_new_with_attributes (" ", renderer, "text", 0, NULL);
   gtk_tree_view_column_set_sort_column_id (column, 0);
   gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);

   renderer = gtk_cell_renderer_text_new ();
   column = gtk_tree_view_column_new_with_attributes ("Name", renderer, "text", 1, NULL);
   gtk_tree_view_column_set_sort_column_id (column, 1);
   gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);

   renderer = gtk_cell_renderer_text_new ();
   column = gtk_tree_view_column_new_with_attributes ("Version", renderer, "text", 2, NULL);
   gtk_tree_view_column_set_sort_column_id (column, 2);
   gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);

   renderer = gtk_cell_renderer_text_new ();
   column = gtk_tree_view_column_new_with_attributes ("Info", renderer, "text", 3, NULL);
   gtk_tree_view_column_set_sort_column_id (column, 3);
   gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);

   /* create the array for the list widget */
   /* or refreshes it if it exists */
   gtkui_create_plug_array();
   gtk_tree_view_set_model(GTK_TREE_VIEW (treeview), GTK_TREE_MODEL (ls_plugins));   

   gtk_widget_show(plugins_window);
}
Esempio n. 8
0
int destination_address(struct navit *nav)
{

	GtkWidget *window2, *keyboard, *vbox, *table;
	GtkWidget *label_country;
	GtkWidget *label_postal, *label_city, *label_district;
	GtkWidget *label_street, *label_number;
	GtkWidget *hseparator1,*hseparator2;
	GtkWidget *button1,*button2,*button3;
	int i;
	struct search_param *search=&search_param;
	struct attr search_attr, country_name, *country_attr;
	struct tracking *tracking;
	struct country_search *cs;
	struct item *item;


	search->nav=nav;
	search->ms=navit_get_mapset(nav);
	search->sl=search_list_new(search->ms);

	window2 = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(window2),_("Enter Destination"));
	gtk_window_set_wmclass (GTK_WINDOW (window2), "navit", "Navit");
	vbox = gtk_vbox_new(FALSE, 0);
	table = gtk_table_new(3, 8, FALSE);

	search->entry_country = gtk_entry_new();
	label_country = gtk_label_new(_("Country"));
	search->entry_postal = gtk_entry_new();
	gtk_widget_set_sensitive(GTK_WIDGET(search->entry_postal), FALSE);
	label_postal = gtk_label_new(_("Zip Code"));
	search->entry_city = gtk_entry_new();
	label_city = gtk_label_new(_("City"));
	search->entry_district = gtk_entry_new();
	gtk_widget_set_sensitive(GTK_WIDGET(search->entry_district), FALSE);
	label_district = gtk_label_new(_("District/Township"));
	hseparator1 = gtk_vseparator_new();
	search->entry_street = gtk_entry_new();
	label_street = gtk_label_new(_("Street"));
	search->entry_number = gtk_entry_new();
	label_number = gtk_label_new(_("Number"));
 	search->treeview=gtk_tree_view_new();
	search->listbox = gtk_scrolled_window_new (NULL, NULL);
        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (search->listbox),
                        GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

	gtk_tree_view_set_model (GTK_TREE_VIEW (search->treeview), NULL);
	gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(search->listbox),search->treeview);
	{
		GType types[COL_COUNT+1];
		for(i=0;i<COL_COUNT;i++)
			types[i]=G_TYPE_STRING;
		types[i]=G_TYPE_POINTER;
                search->liststore=gtk_list_store_newv(COL_COUNT+1,types);
                search->liststore2=gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(search->liststore));
		gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (search->liststore2), 3, GTK_SORT_ASCENDING);
                gtk_tree_view_set_model (GTK_TREE_VIEW (search->treeview), GTK_TREE_MODEL(search->liststore2));
	}




	hseparator2 = gtk_vseparator_new();
	button1 = gtk_button_new_with_label(_("Map"));
	button2 = gtk_button_new_with_label(_("Bookmark"));
	button3 = gtk_button_new_with_label(_("Destination"));

	gtk_table_attach(GTK_TABLE(table), label_country,  0, 1,  0, 1,  0, GTK_FILL, 0, 0);
	gtk_table_attach(GTK_TABLE(table), label_postal,   1, 2,  0, 1,  0, GTK_FILL, 0, 0);
	gtk_table_attach(GTK_TABLE(table), label_city,     2, 3,  0, 1,  0, GTK_FILL, 0, 0);

	gtk_table_attach(GTK_TABLE(table), search->entry_country,  0, 1,  1, 2,  0, GTK_FILL, 0, 0);
	gtk_table_attach(GTK_TABLE(table), search->entry_postal,   1, 2,  1, 2,  0, GTK_FILL, 0, 0);
	gtk_table_attach(GTK_TABLE(table), search->entry_city,     2, 3,  1, 2,  0, GTK_FILL, 0, 0);

	gtk_table_attach(GTK_TABLE(table), label_district, 0, 1,  2, 3,  0, GTK_FILL, 0, 0);
	gtk_table_attach(GTK_TABLE(table), label_street,   1, 2,  2, 3,  0, GTK_FILL, 0, 0);
	gtk_table_attach(GTK_TABLE(table), label_number,   2, 3,  2, 3,  0, GTK_FILL, 0, 0);

	gtk_table_attach(GTK_TABLE(table), search->entry_district, 0, 1,  3, 4,  0, GTK_FILL, 0, 0);
	gtk_table_attach(GTK_TABLE(table), search->entry_street,   1, 2,  3, 4,  0, GTK_FILL, 0, 0);
	gtk_table_attach(GTK_TABLE(table), search->entry_number,   2, 3,  3, 4,  0, GTK_FILL, 0, 0);

	gtk_table_attach(GTK_TABLE(table), search->listbox,        0, 3,  4, 5,  GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 0, 0);

	gtk_table_attach(GTK_TABLE(table), button1, 0, 1, 5, 6, GTK_FILL, GTK_FILL, 0, 0);
	gtk_table_attach(GTK_TABLE(table), button2, 1, 2, 5, 6, GTK_FILL, GTK_FILL, 0, 0);
	gtk_table_attach(GTK_TABLE(table), button3, 2, 3, 5, 6, GTK_FILL, GTK_FILL, 0, 0);

	g_signal_connect(G_OBJECT(search->entry_country), "changed", G_CALLBACK(changed), search);
	g_signal_connect(G_OBJECT(search->entry_postal), "changed", G_CALLBACK(changed), search);
	g_signal_connect(G_OBJECT(search->entry_city), "changed", G_CALLBACK(changed), search);
	g_signal_connect(G_OBJECT(search->entry_district), "changed", G_CALLBACK(changed), search);
	g_signal_connect(G_OBJECT(search->entry_street), "changed", G_CALLBACK(changed), search);
	g_signal_connect(G_OBJECT(search->entry_number), "changed", G_CALLBACK(changed), search);
	g_signal_connect(G_OBJECT(button1), "clicked", G_CALLBACK(button_map), search);
	g_signal_connect(G_OBJECT(button2), "clicked", G_CALLBACK(button_bookmark), search);
	g_signal_connect(G_OBJECT(button3), "clicked", G_CALLBACK(button_destination), search);
	g_signal_connect(G_OBJECT(search->treeview), "button-release-event", G_CALLBACK(tree_view_button_release), search);
	g_signal_connect(G_OBJECT(search->treeview), "row_activated", G_CALLBACK(row_activated), search);

	gtk_widget_grab_focus(search->entry_city);

	gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 0);
	keyboard=gtk_socket_new();
	gtk_box_pack_end(GTK_BOX(vbox), keyboard, FALSE, FALSE, 0);
	gtk_container_add(GTK_CONTAINER(window2), vbox);
#if 0
	g_signal_connect(G_OBJECT(listbox), "select-row", G_CALLBACK(select_row), NULL);
#endif
	gtk_widget_show_all(window2);

#ifndef _WIN32
	gtk_socket_steal(GTK_SOCKET(keyboard), spawn_xkbd("xkbd","-geometry 200x100"));
#endif

	country_attr=country_default();
	tracking=navit_get_tracking(nav);
	if (tracking && tracking_get_attr(tracking, attr_country_id, &search_attr, NULL))
		country_attr=&search_attr;
	if (country_attr) {
		cs=country_search_new(country_attr, 0);
		item=country_search_get_item(cs);
		if (item && item_attr_get(item, attr_country_name, &country_name))
			gtk_entry_set_text(GTK_ENTRY(search->entry_country), country_name.u.str);
		country_search_destroy(cs);
	} else {
		dbg(0,"warning: no default country found\n");
	}
	search->partial=1;
	return 0;
}
Esempio n. 9
0
void
pidgin_xfer_dialog_update_xfer(PidginXferDialog *dialog,
								PurpleXfer *xfer)
{
	PidginXferUiData *data;
	char *size_str, *remaining_str;
	GtkTreeSelection *selection;
	time_t current_time;
	GtkTreeIter iter;
	gboolean valid;

	g_return_if_fail(dialog != NULL);
	g_return_if_fail(xfer != NULL);

	if ((data = PIDGINXFER(xfer)) == NULL)
		return;

	if (data->in_list == FALSE)
		return;

	current_time = time(NULL);
	if (((current_time - data->last_updated_time) == 0) &&
		(!purple_xfer_is_completed(xfer)))
	{
		/* Don't update the window more than once per second */
		return;
	}
	data->last_updated_time = current_time;

	size_str      = purple_str_size_to_units(purple_xfer_get_size(xfer));
	remaining_str = purple_str_size_to_units(purple_xfer_get_bytes_remaining(xfer));

	gtk_list_store_set(xfer_dialog->model, &data->iter,
					   COLUMN_PROGRESS, purple_xfer_get_progress(xfer),
					   COLUMN_SIZE, size_str,
					   COLUMN_REMAINING, remaining_str,
					   -1);

	g_free(size_str);
	g_free(remaining_str);

	if (purple_xfer_is_completed(xfer))
	{
		GdkPixbuf *pixbuf;

		pixbuf = gtk_widget_render_icon(dialog->window,
										PIDGIN_STOCK_FILE_DONE,
										GTK_ICON_SIZE_MENU, NULL);

		gtk_list_store_set(GTK_LIST_STORE(xfer_dialog->model), &data->iter,
						   COLUMN_STATUS, pixbuf,
						   COLUMN_REMAINING, _("Finished"),
						   -1);

		g_object_unref(pixbuf);
	}

	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(xfer_dialog->tree));

	update_title_progress(dialog);
	if (xfer == dialog->selected_xfer)
		update_detailed_info(xfer_dialog, xfer);

	if (purple_xfer_is_completed(xfer) && dialog->auto_clear)
		pidgin_xfer_dialog_remove_xfer(dialog, xfer);
	else
		update_buttons(dialog, xfer);

	/*
	 * If all transfers are finished, and the pref is set, then
	 * close the dialog.  Otherwise just exit this function.
	 */
	if (dialog->keep_open)
		return;

	valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(dialog->model), &iter);
	while (valid)
	{
		GValue val;
		PurpleXfer *next;

		val.g_type = 0;
		gtk_tree_model_get_value(GTK_TREE_MODEL(dialog->model),
				&iter, COLUMN_DATA, &val);

		next = g_value_get_pointer(&val);
		if (!purple_xfer_is_completed(next))
			return;

		valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(dialog->model), &iter);
	}

	/* If we got to this point then we know everything is finished */
	pidgin_xfer_dialog_hide(dialog);
}
Esempio n. 10
0
void
prefsbox_open (void)
{
  GtkWidget *notebook;
  GtkWidget *grid;
  GtkWidget *controls_list;
  GtkWidget *label;
  GtkCellRenderer *renderer;
  GtkListStore *model;
  GtkTreeIter iter;
  gint i;

  if (prefsbox != NULL) {
    gtk_window_present (GTK_WINDOW (prefsbox));
    return;
  }

  prefsbox = gtk_dialog_new_with_buttons (_("Four-in-a-Row Preferences"),
					  GTK_WINDOW (app),
					  GTK_DIALOG_DESTROY_WITH_PARENT,
					  GTK_STOCK_CLOSE,
					  GTK_RESPONSE_ACCEPT, NULL);
  gtk_container_set_border_width (GTK_CONTAINER (prefsbox), 5);
  gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (prefsbox))),
		       2);

  g_signal_connect (G_OBJECT (prefsbox), "destroy",
		    G_CALLBACK (gtk_widget_destroyed), &prefsbox);

  notebook = gtk_notebook_new ();
  gtk_container_set_border_width (GTK_CONTAINER (notebook), 5);
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (prefsbox))), notebook, TRUE, TRUE, 0);

  /* game tab */

  grid = gtk_grid_new ();
  gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
  gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
  gtk_container_set_border_width (GTK_CONTAINER (grid), 12);

  label = gtk_label_new (_("Game"));
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), grid, label);

  label = gtk_label_new (_("Player One:"));
  gtk_widget_set_hexpand (label, TRUE);
  gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);

  combobox1 = gtk_combo_box_new ();
  renderer = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox1), renderer, TRUE);
  gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combobox1), renderer, "text", 0);
  model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
  gtk_combo_box_set_model (GTK_COMBO_BOX (combobox1), GTK_TREE_MODEL (model));
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, _("Human"), 1, LEVEL_HUMAN, -1);
  if (p.level[PLAYER1] == LEVEL_HUMAN)
    gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox1), &iter);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, _("Level one"), 1, LEVEL_WEAK, -1);
  if (p.level[PLAYER1] == LEVEL_WEAK)
    gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox1), &iter);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, _("Level two"), 1, LEVEL_MEDIUM, -1);
  if (p.level[PLAYER1] == LEVEL_MEDIUM)
    gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox1), &iter);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, _("Level three"), 1, LEVEL_STRONG, -1);
  if (p.level[PLAYER1] == LEVEL_STRONG)
    gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox1), &iter);
  g_signal_connect (combobox1, "changed", G_CALLBACK (on_select_player1), NULL);
  gtk_grid_attach (GTK_GRID (grid), combobox1, 1, 0, 1, 1);

  label = gtk_label_new (_("Player Two:"));
  gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1);

  combobox2 = gtk_combo_box_new ();
  renderer = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox2), renderer, TRUE);
  gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combobox2), renderer, "text", 0);
  model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
  gtk_combo_box_set_model (GTK_COMBO_BOX (combobox2), GTK_TREE_MODEL (model));
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, _("Human"), 1, LEVEL_HUMAN, -1);
  if (p.level[PLAYER2] == LEVEL_HUMAN)
    gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox2), &iter);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, _("Level one"), 1, LEVEL_WEAK, -1);
  if (p.level[PLAYER2] == LEVEL_WEAK)
    gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox2), &iter);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, _("Level two"), 1, LEVEL_MEDIUM, -1);
  if (p.level[PLAYER2] == LEVEL_MEDIUM)
    gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox2), &iter);
  gtk_list_store_append (model, &iter);
  gtk_list_store_set (model, &iter, 0, _("Level three"), 1, LEVEL_STRONG, -1);
  if (p.level[PLAYER2] == LEVEL_STRONG)
    gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox2), &iter);
  g_signal_connect (combobox2, "changed", G_CALLBACK (on_select_player2), NULL);
  gtk_grid_attach (GTK_GRID (grid), combobox2, 1, 1, 1, 1);

  label = gtk_label_new_with_mnemonic (_("_Theme:"));
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
  gtk_grid_attach (GTK_GRID (grid), label, 0, 2, 1, 1);

  combobox_theme = gtk_combo_box_text_new ();
  for (i = 0; i < n_themes; i++) {
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combobox_theme),
		 	            _(theme_get_title (i)));
  }
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), combobox_theme);
  gtk_grid_attach (GTK_GRID (grid), combobox_theme, 1, 2, 1, 1);

  checkbutton_animate =
    gtk_check_button_new_with_mnemonic (_("Enable _animation"));
  gtk_grid_attach (GTK_GRID (grid), checkbutton_animate, 0, 3, 2, 1);

  checkbutton_sound =
    gtk_check_button_new_with_mnemonic (_("E_nable sounds"));
  gtk_grid_attach (GTK_GRID (grid), checkbutton_sound, 0, 4, 2, 1);

  /* keyboard tab */

  label = gtk_label_new_with_mnemonic (_("Keyboard Controls"));

  controls_list = games_controls_list_new (settings);
  games_controls_list_add_controls (GAMES_CONTROLS_LIST (controls_list),
				    "key-left", _("Move left"), DEFAULT_KEY_LEFT,
                                    "key-right", _("Move right"), DEFAULT_KEY_RIGHT,
				    "key-drop", _("Drop marble"), DEFAULT_KEY_DROP,
                                    NULL);
  gtk_container_set_border_width (GTK_CONTAINER (controls_list), 12);
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), controls_list, label);

  /* fill in initial values */

  gtk_combo_box_set_active (GTK_COMBO_BOX (combobox_theme), p.theme_id);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton_animate),
				p.do_animate);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton_sound),
				p.do_sound);

  /* connect signals */

  g_signal_connect (prefsbox, "response", G_CALLBACK (on_dialog_close),
		    &prefsbox);

  g_signal_connect (G_OBJECT (combobox_theme), "changed",
		    G_CALLBACK (on_select_theme), NULL);

  g_signal_connect (G_OBJECT (checkbutton_animate), "toggled",
		    G_CALLBACK (on_toggle_animate), NULL);

  g_signal_connect (G_OBJECT (checkbutton_sound), "toggled",
		    G_CALLBACK (on_toggle_sound), NULL);

  gtk_widget_show_all (prefsbox);
}
Esempio n. 11
0
GtkWindow* BuildMenuDialog_construct(ModalDialog& modal, ProjectList& projectList)
{
  GtkWindow* window = create_dialog_window(MainFrame_getWindow(), "Build Menu", G_CALLBACK(dialog_delete_callback), &modal, -1, 400);

  GtkWidget* buildView = 0;

  {
    GtkTable* table1 = create_dialog_table(2, 2, 4, 4, 4);
    gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(table1));
    {
      GtkVBox* vbox = create_dialog_vbox(4);
      gtk_table_attach(table1, GTK_WIDGET(vbox), 1, 2, 0, 1,
                        (GtkAttachOptions) (GTK_FILL),
                        (GtkAttachOptions) (GTK_FILL), 0, 0);
      {
        GtkButton* button = create_dialog_button("OK", G_CALLBACK(dialog_button_ok), &modal);
        gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(button), FALSE, FALSE, 0);
      }
      {
        GtkButton* button = create_dialog_button("Cancel", G_CALLBACK(dialog_button_cancel), &modal);
        gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(button), FALSE, FALSE, 0);
      }
    }
    {
      GtkFrame* frame = create_dialog_frame("Build menu");
      gtk_table_attach(table1, GTK_WIDGET(frame), 0, 1, 0, 1,
                        (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                        (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0);
      {
        GtkScrolledWindow* scr = create_scrolled_window(GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC, 4);
        gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(scr));

        {
          GtkListStore* store = gtk_list_store_new(1, G_TYPE_STRING);

          GtkWidget* view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
          gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);

          GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
          object_set_boolean_property(G_OBJECT(renderer), "editable", TRUE);
          g_signal_connect(renderer, "edited", G_CALLBACK(project_cell_edited), &projectList);
 
          GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("", renderer, "text", 0, 0);
          gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);

          GtkTreeSelection* selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
          gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE);

          gtk_widget_show(view);

          buildView = view;
          projectList.m_store = store;
          gtk_container_add(GTK_CONTAINER (scr), view);
  
          g_signal_connect(G_OBJECT(view), "key_press_event", G_CALLBACK(project_key_press), &projectList);

          g_object_unref(G_OBJECT(store));
        }
      }
    }
    {
      GtkFrame* frame = create_dialog_frame("Commandline");
      gtk_table_attach(table1, GTK_WIDGET(frame), 0, 1, 1, 2,
                        (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                        (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0);
      {
        GtkScrolledWindow* scr = create_scrolled_window(GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC, 4);
        gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(scr));

        {
          GtkListStore* store = gtk_list_store_new(1, G_TYPE_STRING);

          GtkWidget* view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
          gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);

          GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
          object_set_boolean_property(G_OBJECT(renderer), "editable", TRUE);
          g_signal_connect(renderer, "edited", G_CALLBACK(commands_cell_edited), store);
 
          GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("", renderer, "text", 0, 0);
          gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);

          GtkTreeSelection* selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
          gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE);

          gtk_widget_show(view);

          gtk_container_add(GTK_CONTAINER (scr), view);
  
          g_object_unref(G_OBJECT(store));

          g_signal_connect(G_OBJECT(view), "key_press_event", G_CALLBACK(commands_key_press), store);
         
          g_signal_connect(G_OBJECT(gtk_tree_view_get_selection(GTK_TREE_VIEW(buildView))), "changed", G_CALLBACK(project_selection_changed), store);
        }
      }
    }
  }

  BSPCommandList_Construct(projectList.m_store, g_build_project);

  return window;
}
/*
 * This function sets the custom list when the session list has changed in
 * the session dialog (launched from session button or F10 menu).
 */
void
greeter_custom_set_session (gchar *session)
{
  GList *tmp;
  int i=0;

  /*
   * Since the sessions are created before the session list is generated,
   * keep track of the session and set active row when it is setup.  This
   * function will get a NULL when the session is initialized to NULL
   * at startup, so just return.
   */
  if (session == NULL)
    return;
  else
    {
      /*
       * If the session_widget hasn't been setup yet (which it won't be when
       * the greeter_sessioninit function is called, then just store the 
       * session and we'll set the value when the combo box is initialized later.
       */
      g_free (session_key);
      session_key = g_strdup (session);
    }

  /* Do nothing if there is no session widget */
  if (session_widget == NULL)
     return;

  /* Last isn't in the session list, so handle separate. */
  if (strcmp (session, LAST_SESSION) == 0)
    {
      if (GTK_IS_COMBO_BOX (session_widget))
        {
          gtk_combo_box_set_active (GTK_COMBO_BOX (session_widget), 0);
        }
      else if (GTK_IS_SCROLLED_WINDOW (session_widget) && 
               GTK_IS_TREE_VIEW (GTK_BIN (session_widget)->child))
        {
          GtkTreeView  *tv = GTK_TREE_VIEW (GTK_BIN (session_widget)->child);
          GtkTreeModel *tm = gtk_tree_view_get_model (tv);
          GtkTreeSelection *selection = gtk_tree_view_get_selection (tv);
          GtkTreeIter loopiter;

          if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (tm), &loopiter))
            gtk_tree_selection_select_iter (selection, &loopiter);
        }
    }

  /*
   * Handle for either combo box or list style, depending on which is being
   * used.
 . */
  if (GTK_IS_COMBO_BOX (session_widget))
    {
      for (tmp = sessions; tmp != NULL; tmp = tmp->next)
        {
          char *file;

          i++;
          file = tmp->data;
          if (strcmp (session, file) == 0)
            {
              gtk_combo_box_set_active (GTK_COMBO_BOX (session_widget), i);
              break;
            }
        }
    }
  else if (GTK_IS_SCROLLED_WINDOW (session_widget) && 
           GTK_IS_TREE_VIEW (GTK_BIN (session_widget)->child))
    {
      GtkTreeView  *tv = GTK_TREE_VIEW (GTK_BIN (session_widget)->child);
      GtkTreeModel *tm = gtk_tree_view_get_model (tv);
      GtkTreeSelection *selection = gtk_tree_view_get_selection (tv);
      GtkTreeIter loopiter;

      if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (tm), &loopiter))
        {
          do
            {
              char *file;

              gtk_tree_model_get (GTK_TREE_MODEL (tm), &loopiter, GREETER_LIST_ID, &file, -1);
              if (file != NULL && strcmp (session, file) == 0)
                {
                   GtkTreePath *path = gtk_tree_model_get_path (tm, &loopiter);

                   gtk_tree_selection_select_iter (selection, &loopiter);
                   gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (tv),
                                                 path, NULL,
                                                 FALSE, 0.0, 0.0);
                  gtk_tree_path_free (path);
                  break;
               }
           } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (tm), &loopiter));
        }
    }
}
/* Callback function for combo style custom lists */ 
static void
combo_selected (GtkComboBox *combo, GreeterItemInfo *item)
{
  char  *id = NULL;
  char  *file;
  char  *active;

  if (ve_string_empty (item->id))
    return;
 
  active = gtk_combo_box_get_active_text (combo);

  if (strcmp (item->id, "session") == 0)
    {
      combo_session_selected (active);
    }
  else if (strcmp (item->id, "language") == 0)
    {
      /*
       * Since combo boxes can't store the ID value, have to do some
       * extra work to figure out which row is selected.
       */
      GtkListStore *lang_model = mdm_lang_get_model ();
      GtkTreeIter iter;
      char *name, *untranslated, *lang_display_name, *locale_name;
      gboolean valid;

      valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (lang_model),
	 &iter);
      while (valid)
        {
          gtk_tree_model_get (GTK_TREE_MODEL (lang_model), &iter,
             TRANSLATED_NAME_COLUMN, &name,
             UNTRANSLATED_NAME_COLUMN, &untranslated,
             LOCALE_COLUMN, &locale_name, -1);

          if (untranslated)
             lang_display_name = g_strdup_printf ("%s (%s)", name, untranslated);
          else
             lang_display_name = g_strdup (name);

          if (strcmp (lang_display_name, active) == 0)
            {
              mdm_lang_set_restart_dialog (locale_name);
              break;
            }
          g_free (lang_display_name);
          valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (lang_model), &iter);
        }
    }
  else
    {
      if (DOING_MDM_DEVELOPMENT)
        return;

      id   = gtk_combo_box_get_active_text (combo);
      file = g_strdup_printf ("%s/%s.GreeterInfo",
             ve_sure_string (mdm_config_get_string (MDM_KEY_SERV_AUTHDIR)),
             ve_sure_string (g_getenv ("DISPLAY")));

      mdm_save_customlist_data (file, item->id, id);
   }
}
/* Helper function to set session values */
static void
populate_session (GObject * object)
{
  GList *tmp;

  /* Last isn't in the session list, so add separate. */
  if (GTK_IS_COMBO_BOX (object))
    gtk_combo_box_append_text (GTK_COMBO_BOX (object), _("Last session"));
  else if (GTK_IS_TREE_MODEL (object))
    {
      GtkTreeIter loopiter;
      GtkTreeModel *tm = GTK_TREE_MODEL (object);

      gtk_list_store_append (GTK_LIST_STORE (tm), &loopiter);

      gtk_list_store_set (GTK_LIST_STORE (tm), &loopiter,
         GREETER_LIST_TEXT, _("Last session"),
         GREETER_LIST_ID,   LAST_SESSION,
         -1);
     }

  /* Loop through the sessions and set the custom list values. */
  for (tmp = sessions; tmp != NULL; tmp = tmp->next)
    {
      MdmSession *session;
      char *file;

      file = (char *) tmp->data;
      session = g_hash_table_lookup (sessnames, file);

      if (GTK_IS_COMBO_BOX (object))
        {
          if (session->clearname != NULL)
             gtk_combo_box_append_text (GTK_COMBO_BOX (object), (session->clearname));
          else
             gtk_combo_box_append_text (GTK_COMBO_BOX (object), (session->name));
        }
      else if (GTK_IS_TREE_MODEL (object))
        {
          GtkTreeIter loopiter;
          GtkTreeModel *tm = GTK_TREE_MODEL (object);
          gchar *to_display;

          gtk_list_store_append (GTK_LIST_STORE (tm), &loopiter);
          if (session->clearname != NULL)
             to_display = session->clearname;
          else
             to_display = session->name;

          gtk_list_store_set (GTK_LIST_STORE (tm), &loopiter,
             GREETER_LIST_TEXT, to_display,
             GREETER_LIST_ID,   file,
             -1);
        }
    }

  /*
   * Set the session if one exists, this will calback and set the
   * custom list
   */
  if (session_key != NULL)
    greeter_custom_set_session (session_key);
}
static void
parasite_actionlist_init(ParasiteActionList *actionlist,
                         ParasiteActionListClass *klass)
{
    GtkCellRenderer *renderer;
    GtkTreeViewColumn *column;
    GTypeClass *uimanager_type;
    guint uimanager_signal;

    actionlist->priv = PARASITE_ACTIONLIST_GET_PRIVATE(actionlist);
    actionlist->priv->uimanagers = NULL;

    actionlist->priv->model =
        gtk_tree_store_new(NUM_COLUMNS,
                           G_TYPE_STRING,   // ACTION_LABEL
                           G_TYPE_STRING,   // ACTION_NAME
                           G_TYPE_STRING,   // ACTION_ICON
                           G_TYPE_STRING,   // ROW_COLOR,
                           G_TYPE_STRING,   // SORT_NAME
                           G_TYPE_POINTER); // ADDRESS
    gtk_tree_view_set_model(GTK_TREE_VIEW(actionlist),
                            GTK_TREE_MODEL(actionlist->priv->model));

    column = gtk_tree_view_column_new();
    gtk_tree_view_append_column(GTK_TREE_VIEW(actionlist), column);
    gtk_tree_view_column_set_title(column, "Label");

    renderer = gtk_cell_renderer_pixbuf_new();
    gtk_tree_view_column_pack_start(column, renderer, FALSE);
    gtk_tree_view_column_set_attributes(column, renderer,
                                        "stock-id", ACTION_ICON,
                                        NULL);

    renderer = gtk_cell_renderer_text_new();
    gtk_tree_view_column_pack_start(column, renderer, FALSE);
    gtk_tree_view_column_set_attributes(column, renderer,
                                        "text", ACTION_LABEL,
                                        "foreground", ROW_COLOR,
                                        NULL);

    renderer = gtk_cell_renderer_text_new();
    column = gtk_tree_view_column_new_with_attributes("Action",
                                                      renderer,
                                                      "text", ACTION_NAME,
                                                      "foreground", ROW_COLOR,
                                                      NULL);
    gtk_tree_view_append_column(GTK_TREE_VIEW(actionlist), column);

    gtk_tree_sortable_set_sort_column_id(
        GTK_TREE_SORTABLE(actionlist->priv->model),
        SORT_NAME, GTK_SORT_ASCENDING);

    // Listen to all "actions-changed" signal emissions
    uimanager_type = g_type_class_ref(GTK_TYPE_UI_MANAGER);
    uimanager_signal = g_signal_lookup("actions-changed", GTK_TYPE_UI_MANAGER);
    g_signal_add_emission_hook(uimanager_signal, 0,
                               actions_changed_cb,
                               actionlist,
                               NULL);
    g_type_class_unref(uimanager_type);
}
Esempio n. 16
0
/**************************************************************************
 * Dialog Building Functions
 **************************************************************************/
static GtkWidget *
setup_tree(PidginXferDialog *dialog)
{
	GtkWidget *sw;
	GtkWidget *tree;
	GtkListStore *model;
	GtkCellRenderer *renderer;
	GtkTreeViewColumn *column;
	GtkTreeSelection *selection;

	/* Create the scrolled window. */
	sw = gtk_scrolled_window_new(0, 0);
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
						GTK_SHADOW_IN);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
					GTK_POLICY_AUTOMATIC,
					GTK_POLICY_AUTOMATIC);
	gtk_widget_show(sw);

	/* Build the tree model */
	/* Transfer type, Progress Bar, Filename, Size, Remaining */
	model = gtk_list_store_new(NUM_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_DOUBLE,
							   G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
							   G_TYPE_POINTER);
	dialog->model = model;

	/* Create the treeview */
	dialog->tree = tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
	gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tree), TRUE);
	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
	/* gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE); */

	gtk_widget_show(tree);

	g_signal_connect(G_OBJECT(selection), "changed",
					 G_CALLBACK(selection_changed_cb), dialog);

	g_object_unref(G_OBJECT(model));


	/* Columns */

	/* Transfer Type column */
	renderer = gtk_cell_renderer_pixbuf_new();
	column = gtk_tree_view_column_new_with_attributes(NULL, renderer,
				"pixbuf", COLUMN_STATUS, NULL);
	gtk_tree_view_column_set_sizing(GTK_TREE_VIEW_COLUMN(column),
									GTK_TREE_VIEW_COLUMN_FIXED);
	gtk_tree_view_column_set_fixed_width(GTK_TREE_VIEW_COLUMN(column), 25);
	gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN(column), TRUE);
	gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);

	/* Progress bar column */
	renderer = pidgin_cell_renderer_progress_new();
	column = gtk_tree_view_column_new_with_attributes(_("Progress"), renderer,
				"percentage", COLUMN_PROGRESS, NULL);
	gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN(column), TRUE);
	gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);

	/* Filename column */
	renderer = gtk_cell_renderer_text_new();
	column = gtk_tree_view_column_new_with_attributes(_("Filename"), renderer,
				"text", COLUMN_FILENAME, NULL);
	gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN(column), TRUE);
	gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);

	/* File Size column */
	renderer = gtk_cell_renderer_text_new();
	column = gtk_tree_view_column_new_with_attributes(_("Size"), renderer,
				"text", COLUMN_SIZE, NULL);
	gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN(column), TRUE);
	gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);

	/* Bytes Remaining column */
	renderer = gtk_cell_renderer_text_new();
	column = gtk_tree_view_column_new_with_attributes(_("Remaining"),
				renderer, "text", COLUMN_REMAINING, NULL);
	gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN(column), TRUE);
	gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);

	gtk_tree_view_columns_autosize(GTK_TREE_VIEW(tree));

	gtk_container_add(GTK_CONTAINER(sw), tree);
	gtk_widget_show(tree);

	return sw;
}
Esempio n. 17
0
/* Create list */
static
GtkWidget* create_list(void)
{

    GtkListStore      *list_store;
    GtkWidget         *list;
    GtkTreeViewColumn *column;
    GtkCellRenderer   *renderer;
    GtkTreeSortable   *sortable;
    GtkTreeView       *list_view;
    GtkTreeSelection  *selection;

    /* Create the store */
    list_store = gtk_list_store_new(N_COLUMN,   /* Total number of columns XXX*/
                               G_TYPE_UINT,     /* ID               */
                               G_TYPE_STRING,   /* Operation Code   */
                               G_TYPE_INT,      /* Invokes          */
                               G_TYPE_INT,      /* Num Bytes        */
                               G_TYPE_FLOAT,    /* Avg Bytes        */
                               G_TYPE_INT,      /* RetResult        */
                               G_TYPE_INT,      /* Num Bytes        */
                               G_TYPE_FLOAT,    /* Avg Bytes        */
                               G_TYPE_INT,      /* Total Bytes      */
                               G_TYPE_FLOAT);   /* Avg Bytes        */

    /* Create a view */
    list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));

    list_view = GTK_TREE_VIEW(list);
    sortable = GTK_TREE_SORTABLE(list_store);

    /* Speed up the list display */
    gtk_tree_view_set_fixed_height_mode(list_view, TRUE);

    /* Setup the sortable columns */
    gtk_tree_sortable_set_sort_column_id(sortable, ID_COLUMN, GTK_SORT_ASCENDING);
    gtk_tree_view_set_headers_clickable(list_view, FALSE);

    /* The view now holds a reference.  We can get rid of our own reference */
    g_object_unref (G_OBJECT (list_store));

    /*
     * Create the first column packet, associating the "text" attribute of the
     * cell_renderer to the first column of the model
     */
    /* 1:st column */
    renderer = gtk_cell_renderer_text_new ();
    column = gtk_tree_view_column_new_with_attributes ("ID", renderer,
        "text", ID_COLUMN,
        NULL);

    gtk_tree_view_column_set_sort_column_id(column, ID_COLUMN);
    gtk_tree_view_column_set_resizable(column, TRUE);
    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
    gtk_tree_view_column_set_min_width(column, 40);

    /* Add the column to the view. */
    gtk_tree_view_append_column (list_view, column);

    /* 2:nd column..Operation Code. */
    renderer = gtk_cell_renderer_text_new ();
    column = gtk_tree_view_column_new_with_attributes ("Operation Code", renderer,
        "text", OP_CODE_COLUMN,
        NULL);
    gtk_tree_view_column_set_sort_column_id(column, OP_CODE_COLUMN);
    gtk_tree_view_column_set_resizable(column, TRUE);
    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
    gtk_tree_view_column_set_min_width(column, 210);
    gtk_tree_view_append_column (list_view, column);

    /* 3:d column..Invokes. */
    renderer = gtk_cell_renderer_text_new ();
    column = gtk_tree_view_column_new_with_attributes ("Invokes", renderer,
        "text", INVOKES_COLUMN,
        NULL);
    gtk_tree_view_column_set_sort_column_id(column, INVOKES_COLUMN);
    gtk_tree_view_column_set_resizable(column, TRUE);
    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
    gtk_tree_view_column_set_min_width(column, 60);
    gtk_tree_view_append_column (list_view, column);

    /* 4:th column.. Num Bytes. */
    renderer = gtk_cell_renderer_text_new ();
    column = gtk_tree_view_column_new_with_attributes ("Num Bytes", renderer,
        "text", NUM_BYTES_FWD_COLUMN,
        NULL);


    gtk_tree_view_column_set_sort_column_id(column, NUM_BYTES_FWD_COLUMN);
    gtk_tree_view_column_set_resizable(column, TRUE);
    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
    gtk_tree_view_column_set_min_width(column, 100);
    gtk_tree_view_append_column (list_view, column);

    /* 5:th column.. Avg Bytes. */
    renderer = gtk_cell_renderer_text_new ();
    column = gtk_tree_view_column_new_with_attributes ("Avg Bytes", renderer,
        "text", AVG_BYTES_FWD_COLUMN,
        NULL);
    gtk_tree_view_column_set_cell_data_func(column, renderer, float_data_func,
        GINT_TO_POINTER(AVG_BYTES_FWD_COLUMN), NULL);

    gtk_tree_view_column_set_sort_column_id(column, AVG_BYTES_FWD_COLUMN);
    gtk_tree_view_column_set_resizable(column, TRUE);
    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
    gtk_tree_view_column_set_min_width(column, 80);
    gtk_tree_view_append_column (list_view, column);

    /* 6:d column..Invokes. */
    renderer = gtk_cell_renderer_text_new ();
    column = gtk_tree_view_column_new_with_attributes ("ReturnResult", renderer,
        "text", RET_RES_COLUMN,
        NULL);
    gtk_tree_view_column_set_sort_column_id(column, RET_RES_COLUMN);
    gtk_tree_view_column_set_resizable(column, TRUE);
    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
    gtk_tree_view_column_set_min_width(column, 60);
    gtk_tree_view_append_column (list_view, column);

    /* 7:th column.. Num Bytes. */
    renderer = gtk_cell_renderer_text_new ();
    column = gtk_tree_view_column_new_with_attributes ("Num Bytes", renderer,
        "text", NUM_BYTES_REV_COLUMN,
        NULL);


    gtk_tree_view_column_set_sort_column_id(column, NUM_BYTES_FWD_COLUMN);
    gtk_tree_view_column_set_resizable(column, TRUE);
    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
    gtk_tree_view_column_set_min_width(column, 100);
    gtk_tree_view_append_column (list_view, column);

    /* 8:th column.. Avg Bytes. */
    renderer = gtk_cell_renderer_text_new ();
    column = gtk_tree_view_column_new_with_attributes ("Avg Bytes", renderer,
        "text", AVG_BYTES_REV_COLUMN,
        NULL);
    gtk_tree_view_column_set_cell_data_func(column, renderer, float_data_func,
        GINT_TO_POINTER(AVG_BYTES_REV_COLUMN), NULL);


    gtk_tree_view_column_set_sort_column_id(column, AVG_BYTES_REV_COLUMN);
    gtk_tree_view_column_set_resizable(column, TRUE);
    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
    gtk_tree_view_column_set_min_width(column, 80);
    gtk_tree_view_append_column (list_view, column);

    /* 9:th column.. Total Bytes. */
    renderer = gtk_cell_renderer_text_new ();
    column = gtk_tree_view_column_new_with_attributes ("Total Bytes", renderer,
        "text", TOT_BYTES_COLUMN,
        NULL);


    gtk_tree_view_column_set_sort_column_id(column, NUM_BYTES_FWD_COLUMN);
    gtk_tree_view_column_set_resizable(column, TRUE);
    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
    gtk_tree_view_column_set_min_width(column, 100);
    gtk_tree_view_append_column (list_view, column);

    /* 10:th column.. Avg Bytes. */
    renderer = gtk_cell_renderer_text_new ();
    column = gtk_tree_view_column_new_with_attributes ("Avg Bytes", renderer,
        "text", AVG_BYTES_COLUMN,
        NULL);
    gtk_tree_view_column_set_cell_data_func(column, renderer, float_data_func,
        GINT_TO_POINTER(AVG_BYTES_COLUMN), NULL);

    gtk_tree_view_column_set_sort_column_id(column, AVG_BYTES_COLUMN);
    gtk_tree_view_column_set_resizable(column, TRUE);
    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
    gtk_tree_view_column_set_min_width(column, 60);
    gtk_tree_view_append_column (list_view, column);

    /* Now enable the sorting of each column */
    gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(list_view), TRUE);
    gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(list_view), TRUE);

    /* Setup the selection handler */
    selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(list));
    gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);

    return list;

}
Esempio n. 18
0
void OnDPress_rub(GtkTreeView       *tree_view,
		  GtkTreePath       *path,
		  GtkTreeViewColumn *column,
		  t_window          *window)
{
  column = column;
  tree_view = tree_view;

  char *tmp ;
  GtkTreeIter iter;

  /* Clear zone d affichage */
  gtk_container_foreach(GTK_CONTAINER(window->pBox_aff_p),
			(GtkCallback)OnClear_HBox_p,
			window);

  GtkWidget *pTable = gtk_table_new(5, 5, TRUE);
  gtk_box_pack_start(GTK_BOX(window->pBox_aff_p),
		     pTable,
		     TRUE, TRUE, 0);
  
  /* nom de la rub 2clique */
  gtk_tree_model_get_iter (GTK_TREE_MODEL(window->pTreeStore_p),
                           &iter,
                           path);
  gtk_tree_model_get(GTK_TREE_MODEL(window->pTreeStore_p),
		     &iter,
		     0,
		     &tmp,
		     -1);
  
  if (!strcmp(tmp,"Contacts")) {
    GtkListStore* pListstore;
    GtkWidget *pListView;
    GtkCellRenderer *pCellRenderer;
    GtkTreeViewColumn *pColumn;
    GtkWidget *pScrollbar;
    
    pListstore = gtk_list_store_new(N_COLUMN, 
				    GDK_TYPE_PIXBUF,
				    G_TYPE_STRING);
    /*** Insertion contact ***/
    GdkPixbuf *pPixBufA;
    GtkTreeIter pIter;
    t_contact *p;
    
    p = window->contacts;
    while (p!= NULL){
      gtk_list_store_append(pListstore, &pIter);
      pPixBufA = gdk_pixbuf_new_from_file(p->pic, NULL);
      gtk_list_store_set(pListstore, &pIter,
			 PIX_COLUMN, pPixBufA,
			 TEXT_COLUMN, p->name,
			 -1);
      p = p->next;
    }
    /**************************/
    /* Creation de la vue */
    pListView = gtk_tree_view_new_with_model(GTK_TREE_MODEL(pListstore));
    /* Creation de la premiere colonne */
    pCellRenderer = gtk_cell_renderer_pixbuf_new();
    pColumn = gtk_tree_view_column_new_with_attributes("B",
						       pCellRenderer,
						       "pixbuf", PIX_COLUMN,
						       NULL);
    /* Ajout de la colonne à la vue */
    gtk_tree_view_append_column(GTK_TREE_VIEW(pListView), pColumn);
    /* Creation de la deuxieme colonne */
    pCellRenderer = gtk_cell_renderer_text_new();
    pColumn = gtk_tree_view_column_new_with_attributes("login",
						       pCellRenderer,
						       "text", TEXT_COLUMN,
						       NULL);
    /* Ajout de la colonne à la vue*/ 
    gtk_tree_view_append_column(GTK_TREE_VIEW(pListView), pColumn);
    /* scrollbar */
    pScrollbar = gtk_scrolled_window_new(NULL, NULL);
    gtk_container_add(GTK_CONTAINER(pScrollbar), pListView);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(pScrollbar), 
				   GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
    /*BOUTONS*/
    GtkWidget *pVBox = gtk_vbox_new(FALSE, 0);

    /* ajouter*/
    GtkWidget *pBajouter = gtk_button_new_with_label("Ajouter");
    g_signal_connect(G_OBJECT(pBajouter),
		     "clicked",
		     G_CALLBACK(OnButton_contact_ajouter),
		     window);
    gtk_box_pack_start(GTK_BOX(pVBox),
		       pBajouter,
		       FALSE, FALSE, 0); 
    /*supprimer*/
    GtkWidget *pBsupprimer = gtk_button_new_with_label("Supprimer");
    g_signal_connect(G_OBJECT(pBsupprimer),
		     "clicked",
		     G_CALLBACK(OnButton_contact_supprimer),
		     window);
    gtk_box_pack_start(GTK_BOX(pVBox),
		       pBsupprimer,
		       FALSE, FALSE, 0); 
    /*modifier*/
    GtkWidget *pBmodifier = gtk_button_new_with_label("Modifier");
    g_signal_connect(G_OBJECT(pBmodifier),
		     "clicked",
		     G_CALLBACK(OnButton_contact_modifier),
		     window);
    gtk_box_pack_start(GTK_BOX(pVBox),
		       pBmodifier,
		       FALSE, FALSE, 0);
    
    /* mis dans la zone d affichage */
    GtkWidget *label;
    label = gtk_label_new("  Gestion des contacts  ");
    gtk_table_attach_defaults(GTK_TABLE(pTable),
			      label,
			      1,4,
			      0,1);
    gtk_table_attach_defaults(GTK_TABLE(pTable),
			      pScrollbar,
			      0,4,
			      1,5);
    gtk_table_attach_defaults(GTK_TABLE(pTable),
			      pVBox,
			      4,5,
			      1,5);

    /*affichage */
    gtk_widget_show_all(GTK_WIDGET(window->pHBox_p));
  }
  
  if (!strcmp(tmp,"Apparence")) {
    GtkWidget *label;
    label = gtk_label_new("  Choisir un theme : ");
    gtk_table_attach_defaults(GTK_TABLE(pTable),
			      label,
			      0,2,
			      0,1);

    GtkWidget *pbred = gtk_button_new_with_label("red");
    gtk_table_attach_defaults(GTK_TABLE(pTable),
			      pbred,
			      0,1,
			      1,2);
    g_signal_connect(G_OBJECT(pbred),
		     "clicked",
		     G_CALLBACK(OnButton_red),
		     window);

    GtkWidget *pbdual = gtk_button_new_with_label("dual");
    gtk_table_attach_defaults(GTK_TABLE(pTable),
			     pbdual,
			     1,2,
			     1,2);
    g_signal_connect(G_OBJECT(pbdual),
		     "clicked",
		     G_CALLBACK(OnButton_dual),
		     window);
   
   GtkWidget *pblogo = gtk_button_new_with_label("logo");
   gtk_table_attach_defaults(GTK_TABLE(pTable),
			     pblogo,
			     2,3,
			     1,2);
    g_signal_connect(G_OBJECT(pblogo),
		     "clicked",
		     G_CALLBACK(OnButton_logo),
		     window);
   
   gtk_widget_show_all(GTK_WIDGET(window->pHBox_p));
  }
  
}
Esempio n. 19
0
static void games_scores_dialog_init (GamesScoresDialog *self) 
{
  GtkWidget *vbox;
  GtkWidget *scroll;
  GtkWidget *listview;
  GtkTreeViewColumn *column;
  GtkTreeViewColumn *timecolumn;
  GtkCellRenderer *renderer;
  GtkCellRenderer *timerenderer;

  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GAMES_TYPE_SCORES_DIALOG,
                                            GamesScoresDialogPrivate);

  self->priv->style = GAMES_SCORES_STYLE_PLAIN_DESCENDING;
  /* These two hashes are the reverse of each other. As an optimisation 
   * they share the same set of strings (as keys in the first case and
   * as data in the second). The first hash is responsible for 
   * deallocating the memory for the strings. These two are only
   * valid as a pair. */
  self->priv->categories = g_hash_table_new_full (g_str_hash, g_str_equal,
						     g_free, NULL);
  self->priv->catindices = g_hash_table_new (g_direct_hash, g_direct_equal);
  self->priv->catcounter = 0;
  self->priv->hilight = 0;
  gtk_container_set_border_width (GTK_CONTAINER (self), 5);
  gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), 2);

  g_signal_connect (G_OBJECT (self), "show", 
		      G_CALLBACK (games_scores_dialog_show), NULL);
  g_signal_connect (G_OBJECT (self), "hide", 
		      G_CALLBACK (games_scores_dialog_hide), NULL);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
  gtk_box_pack_end (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))),
                    vbox, TRUE, TRUE, 0);

  scroll = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
				    GTK_POLICY_AUTOMATIC,
				    GTK_POLICY_AUTOMATIC);
  gtk_widget_set_size_request (scroll, 200, 265);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll),
					 GTK_SHADOW_ETCHED_IN);
  gtk_box_pack_end (GTK_BOX (vbox), scroll, TRUE, TRUE, 0);
  
  self->priv->message = gtk_label_new ("");
  gtk_label_set_use_markup (GTK_LABEL (self->priv->message), TRUE);
  gtk_label_set_justify (GTK_LABEL (self->priv->message), 
	                   GTK_JUSTIFY_CENTER);    
  gtk_box_pack_start (GTK_BOX (vbox), self->priv->message, FALSE, FALSE, 0);

  self->priv->hdiv = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
  gtk_box_pack_start (GTK_BOX (vbox), self->priv->hdiv, FALSE, FALSE, 0);

  self->priv->catbar = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
  gtk_box_pack_start (GTK_BOX (vbox), self->priv->catbar, FALSE, FALSE, 0);

  self->priv->label = gtk_label_new (NULL);
  gtk_label_set_use_markup (GTK_LABEL (self->priv->label), TRUE);
  gtk_box_pack_start (GTK_BOX (self->priv->catbar), self->priv->label,
			FALSE, FALSE, 0);	
 
  self->priv->combo = gtk_combo_box_text_new ();
  gtk_combo_box_set_focus_on_click (GTK_COMBO_BOX (self->priv->combo), FALSE);
  gtk_box_pack_start (GTK_BOX (self->priv->catbar), 
			self->priv->combo, TRUE, TRUE, 0);
  gtk_label_set_mnemonic_widget (GTK_LABEL (self->priv->label), self->priv->combo);

  g_signal_connect (G_OBJECT (self->priv->combo), "changed", 
		      G_CALLBACK (games_scores_dialog_change_category), self);

  self->priv->list = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);

  listview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (self->priv->list));
  self->priv->treeview = GTK_TREE_VIEW (listview);

  timerenderer = gtk_cell_renderer_text_new ();
  timecolumn = gtk_tree_view_column_new_with_attributes (/* Score dialog column header for the date
							    the score was recorded */
                                                         _("Date"),
                                                         timerenderer,
                                                         "text", 0,
                                                         NULL);
  g_object_set (G_OBJECT (timerenderer), "xalign", 1.0, NULL);
  gtk_tree_view_append_column (GTK_TREE_VIEW (listview),
                               GTK_TREE_VIEW_COLUMN (timecolumn));
  self->priv->timecolumn = timecolumn;

  renderer = gtk_cell_renderer_text_new ();
  column = gtk_tree_view_column_new_with_attributes ("", renderer, "text", 1, NULL);
  g_object_set (G_OBJECT (renderer), "xalign", 1.0, NULL);
  gtk_tree_view_append_column (GTK_TREE_VIEW (listview),
				 GTK_TREE_VIEW_COLUMN (column));
  self->priv->column = column;
 
  gtk_container_add (GTK_CONTAINER (scroll), listview);
  
  games_scores_dialog_set_buttons (self, GAMES_SCORES_CLOSE_BUTTON);

  gtk_window_set_destroy_with_parent (GTK_WINDOW (self), TRUE);

  gtk_widget_grab_focus (self->priv->combo);

  gtk_widget_show_all (vbox);
  gtk_widget_hide (self->priv->hdiv);
  gtk_widget_hide (self->priv->message);
}
Esempio n. 20
0
int init_preferences(t_window * window)
{
  /* INIT Fenetre Gestion */
  window->pWindow_p = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
  gtk_window_set_title(GTK_WINDOW(window->pWindow_p),
		       "TUTTI 0.1 : Gestion");
  gtk_window_set_position(GTK_WINDOW(window->pWindow_p),
			  GTK_WIN_POS_NONE );
  gtk_window_set_default_size(GTK_WINDOW(window->pWindow_p),600 , 500);
  g_signal_connect(G_OBJECT(window->pWindow_p),
		   "destroy",
		   G_CALLBACK(OnKill_p),
		   NULL);
  g_signal_connect(G_OBJECT(window->pWindow_p),
		   "delete_event",
		   G_CALLBACK(OnKill_p),
		   NULL);
  
  /* box principale */
  window->pHBox_p = gtk_hbox_new(FALSE, 0);
  gtk_container_add(GTK_CONTAINER(window->pWindow_p), window->pHBox_p);
  
  /* Creation de l arbre des parametres */
  window->pTreeStore_p = gtk_tree_store_new( 1, G_TYPE_STRING);

  int i;
  int j;

  char titres[5][20];
  char ssmenu[5][3][20];

  g_sprintf(titres[0], "Generale");
  g_sprintf(ssmenu[0][0], "prop 1");
  g_sprintf(ssmenu[0][1], "prop 2");
  g_sprintf(ssmenu[0][2], "0");
  g_sprintf(titres[1], "Apparence");
  g_sprintf(ssmenu[1][0], "0");
  g_sprintf(titres[2], "Contacts");
  g_sprintf(ssmenu[2][0], "0");
  g_sprintf(titres[3], "Connexion");  
  g_sprintf(ssmenu[3][0], "prop 1");
  g_sprintf(ssmenu[3][1], "prop 2");
  g_sprintf(ssmenu[3][2], "0");
  g_sprintf(titres[4], "0");

  GtkTreeIter pIter_p;
  GtkTreeIter pIter2_p;

  i=0;
  while (strcmp(titres[i],"0")){
    gtk_tree_store_append(window->pTreeStore_p, &pIter_p, NULL);
    gtk_tree_store_set(window->pTreeStore_p, &pIter_p,
		       0, titres[i],
		       -1);
    j = 0;
    while (strcmp(ssmenu[i][j], "0")){
      gtk_tree_store_append(window->pTreeStore_p, &pIter2_p, &pIter_p );
      gtk_tree_store_set(window->pTreeStore_p, &pIter2_p,
			 0,  ssmenu[i][j],
			 -1);
      j++;
    }
    i++;
  }

  /* creation de la vue */
  window->pTreeView_p = gtk_tree_view_new_with_model(GTK_TREE_MODEL(window->pTreeStore_p));
  
  /* Creation de la colonne */
  window->pCellRenderer_p = gtk_cell_renderer_text_new();
  window->pColumn_p = gtk_tree_view_column_new_with_attributes("Rubriques                     ~",
							       window->pCellRenderer_p,
							       "text", 0,
							       NULL);
  
  /* Ajout de la colonne à la vue */
  gtk_tree_view_append_column(GTK_TREE_VIEW(window->pTreeView_p), window->pColumn_p);
  
  /* Creation scrollbar contenant la liste des contacts */
  window->pScrollbar_p = gtk_scrolled_window_new(NULL, NULL);
  gtk_box_pack_start(GTK_BOX(window->pHBox_p), window->pScrollbar_p, FALSE, TRUE, 0);
  
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(window->pScrollbar_p), 
				 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
  
  /* ajout de la vue a la ScrollBar */
  gtk_container_add(GTK_CONTAINER(window->pScrollbar_p), window->pTreeView_p);
  
  /* Creation des rubriques */
  window->pBox_rub_p = gtk_vbox_new(FALSE, 0);
  gtk_box_pack_start(GTK_BOX(window->pHBox_p), window->pBox_rub_p, TRUE, TRUE, 0);

  /* contenue des rubriques */
  window->pBox_aff_p = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_end(GTK_BOX(window->pHBox_p), window->pBox_aff_p, TRUE, TRUE, 0);

  g_signal_connect(window->pTreeView_p,
		   "row-activated",
		   G_CALLBACK(OnDPress_rub),
		   window);
  
  return 1 ;
}
Esempio n. 21
0
static void
cv_tree_init (chanview *cv)
{
	GtkWidget *view, *win;
	GtkCellRenderer *renderer;
	GtkTreeViewColumn *col;
	int wid1, wid2;
	static const GtkTargetEntry dnd_src_target[] =
	{
		{"HEXCHAT_CHANVIEW", GTK_TARGET_SAME_APP, 75 }
	};
	static const GtkTargetEntry dnd_dest_target[] =
	{
		{"HEXCHAT_USERLIST", GTK_TARGET_SAME_APP, 75 }
	};

	win = gtk_scrolled_window_new (0, 0);
	/*gtk_container_set_border_width (GTK_CONTAINER (win), 1);*/
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (win),
													 GTK_SHADOW_IN);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (win),
											  GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
	gtk_container_add (GTK_CONTAINER (cv->box), win);
	gtk_widget_show (win);

	view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (cv->store));
	gtk_widget_set_name (view, "hexchat-tree");
	if (cv->style)
		gtk_widget_set_style (view, cv->style);
	/*gtk_widget_modify_base (view, GTK_STATE_NORMAL, &colors[COL_BG]);*/
	GTK_WIDGET_UNSET_FLAGS (view, GTK_CAN_FOCUS);
	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (view), FALSE);

	if (prefs.hex_gui_tab_dots)
	{
		gtk_tree_view_set_enable_tree_lines (GTK_TREE_VIEW (view), TRUE);
	}
	
	/* Indented channels with no server looks silly, but we still want expanders */
	if (!prefs.hex_gui_tab_server)
	{
		gtk_widget_style_get (view, "expander-size", &wid1, "horizontal-separator", &wid2, NULL);
		gtk_tree_view_set_level_indentation (GTK_TREE_VIEW (view), -wid1 - wid2);
	}


	gtk_container_add (GTK_CONTAINER (win), view);
	col = gtk_tree_view_column_new();

	/* icon column */
	if (cv->use_icons)
	{
		renderer = gtk_cell_renderer_pixbuf_new ();
		if (prefs.hex_gui_compact)
			g_object_set (G_OBJECT (renderer), "ypad", 0, NULL);

		gtk_tree_view_column_pack_start(col, renderer, FALSE);
		gtk_tree_view_column_set_attributes (col, renderer, "pixbuf", COL_PIXBUF, NULL);
	}

	/* main column */
	renderer = gtk_cell_renderer_text_new ();
	if (prefs.hex_gui_compact)
		g_object_set (G_OBJECT (renderer), "ypad", 0, NULL);
	gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (renderer), 1);
	gtk_tree_view_column_pack_start(col, renderer, TRUE);
	gtk_tree_view_column_set_attributes (col, renderer, "text", COL_NAME, "attributes", COL_ATTR, NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);									

	g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (view))),
							"changed", G_CALLBACK (cv_tree_sel_cb), cv);
	g_signal_connect (G_OBJECT (view), "button-press-event",
							G_CALLBACK (cv_tree_click_cb), cv);
	g_signal_connect (G_OBJECT (view), "row-activated",
							G_CALLBACK (cv_tree_activated_cb), NULL);

	gtk_drag_dest_set (view, GTK_DEST_DEFAULT_ALL, dnd_dest_target, 1,
							 GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK);
	gtk_drag_source_set (view, GDK_BUTTON1_MASK, dnd_src_target, 1, GDK_ACTION_COPY);

#ifndef WIN32
	g_signal_connect (G_OBJECT (view), "drag_begin",
							G_CALLBACK (mg_drag_begin_cb), NULL);
	g_signal_connect (G_OBJECT (view), "drag_drop",
							G_CALLBACK (mg_drag_drop_cb), NULL);
	g_signal_connect (G_OBJECT (view), "drag_motion",
							G_CALLBACK (mg_drag_motion_cb), NULL);
	g_signal_connect (G_OBJECT (view), "drag_end",
							G_CALLBACK (mg_drag_end_cb), NULL);
#endif

	((treeview *)cv)->tree = GTK_TREE_VIEW (view);
	((treeview *)cv)->scrollw = win;
	gtk_widget_show (view);
}
Esempio n. 22
0
void
preferences_dialog_init (PreferencesDialog *pd)
{
	GtkWidget		*widget, *entry;
	GtkComboBox		*combo;
	GtkListStore		*store;
	GtkTreeIter		treeiter;
	GtkAdjustment		*itemCount;
	GtkTreeStore		*treestore;
	GtkTreeViewColumn 	*column;
	GSList			*list;
	gchar			*proxyport;
	gchar			*configuredBrowser, *name;
	gboolean		enabled;
	static int		manual;
	struct browser		*iter;
	gint			tmp, i, iSetting, proxy_port;
	gboolean		bSetting;
	gchar			*proxy_host, *proxy_user, *proxy_passwd;
	gchar			*browser_command;
	
	prefdialog = pd;
	pd->priv = PREFERENCES_DIALOG_GET_PRIVATE (pd);
	pd->priv->dialog = liferea_dialog_new ("prefs.ui", "prefdialog");

	/* Set up browser selection popup */
	store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
	for(i = 0, iter = browser_get_all (); iter->id != NULL; iter++, i++) {
		gtk_list_store_append (store, &treeiter);
		gtk_list_store_set (store, &treeiter, 0, _(iter->display), 1, i, -1);
	}
	manual = i;
	/* This allows the user to choose their own browser by typing in the command. */
	gtk_list_store_append (store, &treeiter);
	gtk_list_store_set (store, &treeiter, 0, _("Manual"), 1, i, -1);
	combo = GTK_COMBO_BOX (liferea_dialog_lookup (pd->priv->dialog, "browserpopup"));
	gtk_combo_box_set_model (combo, GTK_TREE_MODEL (store));
	ui_common_setup_combo_text (combo, 0);
	g_signal_connect(G_OBJECT(combo), "changed", G_CALLBACK(on_browser_changed), pd);

	/* Create location menu */
	store = gtk_list_store_new (1, G_TYPE_STRING);

	combo = GTK_COMBO_BOX (liferea_dialog_lookup (pd->priv->dialog, "browserlocpopup"));
	gtk_combo_box_set_model (combo, GTK_TREE_MODEL (store));
	ui_common_setup_combo_text (combo, 0);
	g_signal_connect(G_OBJECT(combo), "changed", G_CALLBACK(on_browser_place_changed), pd);

	gtk_list_store_append (store, &treeiter);
	gtk_list_store_set (store, &treeiter, 0, _("Browser default"), -1);

	gtk_list_store_append (store, &treeiter);
	gtk_list_store_set (store, &treeiter, 0, _("Existing window"), -1);

	gtk_list_store_append (store, &treeiter);
	gtk_list_store_set (store, &treeiter, 0, _("New window"), -1);

	gtk_list_store_append (store, &treeiter);
	gtk_list_store_set (store, &treeiter, 0, _("New tab"), -1);


	/* ================== panel 1 "feeds" ==================== */

	/* check box for feed startup update */
	conf_get_int_value (STARTUP_FEED_ACTION, &iSetting);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (pd->priv->dialog, "startupactionbtn")), (iSetting == 0)); 

	/* cache size setting */
	widget = liferea_dialog_lookup (pd->priv->dialog, "itemCountBtn");
	itemCount = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget));
	conf_get_int_value (DEFAULT_MAX_ITEMS, &iSetting);
	gtk_adjustment_set_value (itemCount, iSetting);

	/* set default update interval spin button and unit combo box */
	ui_common_setup_combo_menu (liferea_dialog_lookup (pd->priv->dialog, "globalRefreshIntervalUnitComboBox"),
	                            default_update_interval_unit_options,
	                            G_CALLBACK (on_default_update_interval_unit_changed),
				    -1);
				   
	widget = liferea_dialog_lookup (pd->priv->dialog, "globalRefreshIntervalUnitComboBox");
	conf_get_int_value (DEFAULT_UPDATE_INTERVAL, &tmp);
	if (tmp % 1440 == 0) {		/* days */
		gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 2);
		tmp /= 1440;
	} else if (tmp % 60 == 0) {	/* hours */
		gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 1);
		tmp /= 60;
	} else {			/* minutes */
		gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
	}
	widget = liferea_dialog_lookup (pd->priv->dialog,"globalRefreshIntervalSpinButton");
	gtk_spin_button_set_range (GTK_SPIN_BUTTON (widget), 0, 1000000000);
	gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), tmp);
	g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (on_default_update_interval_value_changed), pd);

	/* ================== panel 2 "folders" ==================== */

	g_signal_connect (G_OBJECT (liferea_dialog_lookup (pd->priv->dialog, "updateAllFavicons")), "clicked", G_CALLBACK(on_updateallfavicons_clicked), pd);

	conf_get_int_value (FOLDER_DISPLAY_MODE, &iSetting);
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (liferea_dialog_lookup (pd->priv->dialog, "folderdisplaybtn")), iSetting?TRUE:FALSE);
	conf_get_bool_value (FOLDER_DISPLAY_HIDE_READ, &bSetting);
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (liferea_dialog_lookup (pd->priv->dialog, "hidereadbtn")), bSetting?TRUE:FALSE);

	/* ================== panel 3 "headlines" ==================== */

	conf_get_int_value (BROWSE_KEY_SETTING, &iSetting);
	ui_common_setup_combo_menu (liferea_dialog_lookup (pd->priv->dialog, "skimKeyCombo"),
	                            browser_skim_key_options,
	                            G_CALLBACK (on_skim_key_changed),
	                            iSetting);

	conf_get_int_value (DEFAULT_VIEW_MODE, &iSetting);
	ui_common_setup_combo_menu (liferea_dialog_lookup (pd->priv->dialog, "defaultViewModeCombo"),
	                            default_view_mode_options,
	                            G_CALLBACK (on_default_view_mode_changed),
	                            iSetting);
				  
	/* Setup social bookmarking list */
	i = 0;
	conf_get_str_value (SOCIAL_BM_SITE, &name);
	store = gtk_list_store_new (1, G_TYPE_STRING);
	list = bookmarkSites;
	while (list) {
		socialSitePtr siter = list->data;
		if (name && !strcmp (siter->name, name))
			tmp = i;
		gtk_list_store_append (store, &treeiter);
		gtk_list_store_set (store, &treeiter, 0, siter->name, -1);
		list = g_slist_next (list);
		i++;
	}

	combo = GTK_COMBO_BOX (liferea_dialog_lookup (pd->priv->dialog, "socialpopup"));
	g_signal_connect (G_OBJECT (combo), "changed", G_CALLBACK (on_socialsite_changed), pd);
	gtk_combo_box_set_model (combo, GTK_TREE_MODEL (store));
	ui_common_setup_combo_text (combo, 0);
	gtk_combo_box_set_active (combo, tmp);

	/* ================== panel 4 "browser" ==================== */

	/* set the inside browsing flag */
	widget = liferea_dialog_lookup(pd->priv->dialog, "browseinwindow");
	conf_get_bool_value(BROWSE_INSIDE_APPLICATION, &bSetting);
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), bSetting);

	/* set the javascript-disabled flag */
	widget = liferea_dialog_lookup(pd->priv->dialog, "disablejavascript");
	conf_get_bool_value(DISABLE_JAVASCRIPT, &bSetting);
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), bSetting);
	
	/* set the enable Plugins flag */
	widget = liferea_dialog_lookup(pd->priv->dialog, "enableplugins");
	conf_get_bool_value(ENABLE_PLUGINS, &bSetting);
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), bSetting);

	tmp = 0;
	conf_get_str_value(BROWSER_ID, &configuredBrowser);

	if(!strcmp(configuredBrowser, "manual"))
		tmp = manual;
	else
		for(i=0, iter = browser_get_all (); iter->id != NULL; iter++, i++)
			if(!strcmp(configuredBrowser, iter->id))
				tmp = i;

	gtk_combo_box_set_active(GTK_COMBO_BOX(liferea_dialog_lookup(pd->priv->dialog, "browserpopup")), tmp);
	g_free(configuredBrowser);

	conf_get_int_value (BROWSER_PLACE, &iSetting);
	gtk_combo_box_set_active(GTK_COMBO_BOX(liferea_dialog_lookup(pd->priv->dialog, "browserlocpopup")), iSetting);

	conf_get_str_value (BROWSER_COMMAND, &browser_command);
	entry = liferea_dialog_lookup(pd->priv->dialog, "browsercmd");
	gtk_entry_set_text(GTK_ENTRY(entry), browser_command);
	g_free (browser_command);

	gtk_widget_set_sensitive (GTK_WIDGET (entry), tmp == manual);
	gtk_widget_set_sensitive (liferea_dialog_lookup (pd->priv->dialog, "manuallabel"), tmp == manual);	
	gtk_widget_set_sensitive (liferea_dialog_lookup (pd->priv->dialog, "urlhintlabel"), tmp == manual);

	/* ================== panel 4 "GUI" ================ */

	/* tool bar settings */	
	widget = liferea_dialog_lookup (pd->priv->dialog, "hidetoolbarbtn");
	conf_get_bool_value(DISABLE_TOOLBAR, &bSetting);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), bSetting);

	/* select currently active toolbar style option */
	conf_get_str_value (TOOLBAR_STYLE, &name);
	for (i = 0; gui_toolbar_style_values[i] != NULL; ++i) {
		if (strcmp (name, gui_toolbar_style_values[i]) == 0)
			break;
	}
	g_free (name);

	/* On invalid key value: revert to default */
	if (gui_toolbar_style_values[i] == NULL)
		i = 0;

	/* create toolbar style menu */
	ui_common_setup_combo_menu (liferea_dialog_lookup (pd->priv->dialog, "toolbarCombo"),
	                            gui_toolbar_style_options,
	                            G_CALLBACK (on_gui_toolbar_style_changed),
	                            i);

	/* ================= panel 5 "proxy" ======================== */
	conf_get_str_value (PROXY_HOST, &proxy_host);
	gtk_entry_set_text (GTK_ENTRY (liferea_dialog_lookup (pd->priv->dialog, "proxyhostentry")), proxy_host);
	g_free (proxy_host);

	conf_get_int_value (PROXY_PORT, &proxy_port);
	proxyport = g_strdup_printf ("%d", proxy_port);
	gtk_entry_set_text (GTK_ENTRY (liferea_dialog_lookup (pd->priv->dialog, "proxyportentry")), proxyport);
	g_free (proxyport);

	conf_get_bool_value (PROXY_USEAUTH, &enabled);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (pd->priv->dialog, "useProxyAuth")), enabled);

	conf_get_str_value (PROXY_USER, &proxy_user);
	gtk_entry_set_text (GTK_ENTRY (liferea_dialog_lookup (pd->priv->dialog, "proxyusernameentry")), proxy_user);
	g_free (proxy_user);

	conf_get_str_value (PROXY_PASSWD, &proxy_passwd);
	gtk_entry_set_text (GTK_ENTRY (liferea_dialog_lookup (pd->priv->dialog, "proxypasswordentry")), proxy_passwd);
	g_free (proxy_passwd);

	gtk_widget_set_sensitive (GTK_WIDGET (liferea_dialog_lookup(pd->priv->dialog, "proxyauthtable")), enabled);
		
	conf_get_int_value (PROXY_DETECT_MODE, &i);
	switch (i) {
		default:
		case 0: /* proxy auto detect */
			gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (pd->priv->dialog, "proxyAutoDetectRadio")), TRUE);
			enabled = FALSE;
			break;
		case 1: /* no proxy */
			gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (pd->priv->dialog, "noProxyRadio")), TRUE);
			enabled = FALSE;
			break;
		case 2: /* manual proxy */
			gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (pd->priv->dialog, "manualProxyRadio")), TRUE);
			enabled = TRUE;
			break;
	}
	gtk_widget_set_sensitive (GTK_WIDGET (liferea_dialog_lookup (pd->priv->dialog, "proxybox")), enabled);
	g_signal_connect (G_OBJECT (liferea_dialog_lookup (pd->priv->dialog, "proxyAutoDetectRadio")), "clicked", G_CALLBACK (on_proxyAutoDetect_clicked), pd);
	g_signal_connect (G_OBJECT (liferea_dialog_lookup (pd->priv->dialog, "noProxyRadio")), "clicked", G_CALLBACK (on_noProxy_clicked), pd);
	g_signal_connect (G_OBJECT (liferea_dialog_lookup (pd->priv->dialog, "manualProxyRadio")), "clicked", G_CALLBACK (on_manualProxy_clicked), pd);
	g_signal_connect (G_OBJECT (liferea_dialog_lookup (pd->priv->dialog, "proxyhostentry")), "changed", G_CALLBACK (on_proxyhostentry_changed), pd);
	g_signal_connect (G_OBJECT (liferea_dialog_lookup (pd->priv->dialog, "proxyportentry")), "changed", G_CALLBACK (on_proxyportentry_changed), pd);
	g_signal_connect (G_OBJECT (liferea_dialog_lookup (pd->priv->dialog, "proxyusernameentry")), "changed", G_CALLBACK (on_proxyusernameentry_changed), pd);
	g_signal_connect (G_OBJECT (liferea_dialog_lookup (pd->priv->dialog, "proxypasswordentry")), "changed", G_CALLBACK (on_proxypasswordentry_changed), pd);

	/* ================= panel 6 "Enclosures" ======================== */

	/* menu for download tool */
	conf_get_int_value (DOWNLOAD_TOOL, &iSetting);
	ui_common_setup_combo_menu (liferea_dialog_lookup (pd->priv->dialog, "downloadToolCombo"),
	                            enclosure_download_tool_options,
	                            G_CALLBACK (on_enclosure_download_tool_changed),
	                            iSetting);

	/* set up list of configured enclosure types */
	treestore = gtk_tree_store_new (FTS_LEN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER);
	list = (GSList *)enclosure_mime_types_get ();
	while (list) {
		GtkTreeIter *newIter = g_new0 (GtkTreeIter, 1);
		gtk_tree_store_append (treestore, newIter, NULL);
		gtk_tree_store_set (treestore, newIter,
	                	    FTS_TYPE, (NULL != ((encTypePtr)(list->data))->mime)?((encTypePtr)(list->data))->mime:((encTypePtr)(list->data))->extension, 
	                	    FTS_CMD, ((encTypePtr)(list->data))->cmd,
	                	    FTS_PTR, list->data, 
				    -1);
		list = g_slist_next (list);
	}

	widget = liferea_dialog_lookup (pd->priv->dialog, "enc_action_view");
	gtk_tree_view_set_model (GTK_TREE_VIEW (widget), GTK_TREE_MODEL (treestore));

	column = gtk_tree_view_column_new_with_attributes (_("Type"), gtk_cell_renderer_text_new (), "text", FTS_TYPE, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (widget), column);
	gtk_tree_view_column_set_sort_column_id (column, FTS_TYPE);
	column = gtk_tree_view_column_new_with_attributes (_("Program"), gtk_cell_renderer_text_new (), "text", FTS_CMD, NULL);
	gtk_tree_view_column_set_sort_column_id (column, FTS_CMD);
	gtk_tree_view_append_column (GTK_TREE_VIEW(widget), column);

	gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW(widget)), GTK_SELECTION_SINGLE);

	/* ================= panel 7 "Plugins" ======================== */

	pd->priv->plugins_box = liferea_dialog_lookup (pd->priv->dialog, "plugins_box");
	g_assert (pd->priv->plugins_box != NULL);

	GtkWidget *alignment;

	alignment = gtk_alignment_new (0., 0., 1., 1.);
	gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 12, 12, 12, 12);

	widget = peas_gtk_plugin_manager_new (NULL);
	g_assert (widget != NULL);

	gtk_container_add (GTK_CONTAINER (alignment), widget);
	gtk_box_pack_start (GTK_BOX (pd->priv->plugins_box), alignment, TRUE, TRUE, 0);

	g_signal_connect_object (pd->priv->dialog, "destroy", G_CALLBACK (preferences_dialog_destroy_cb), pd, 0);

	gtk_widget_show_all (pd->priv->dialog);

	gtk_window_present (GTK_WINDOW (pd->priv->dialog));
}
Esempio n. 23
0
/* construct widget above */
void gui_init(struct dt_imageio_module_storage_t *self)
{
  self->gui_data = g_malloc0(sizeof(dt_storage_facebook_gui_data_t));
  dt_storage_facebook_gui_data_t *ui = self->gui_data;
  ui->facebook_api = fb_api_init();

  self->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);

  // create labels
  ui->label_album_title = GTK_LABEL(gtk_label_new(_("title")));
  ui->label_album_summary = GTK_LABEL(gtk_label_new(_("summary")));
  ui->label_album_privacy = GTK_LABEL(gtk_label_new(_("privacy")));
  ui->label_status = GTK_LABEL(gtk_label_new(NULL));

  gtk_widget_set_halign(GTK_WIDGET(ui->label_album_title), GTK_ALIGN_START);
  gtk_widget_set_halign(GTK_WIDGET(ui->label_album_summary), GTK_ALIGN_START);
  gtk_widget_set_halign(GTK_WIDGET(ui->label_album_privacy), GTK_ALIGN_START);

  // create entries
  GtkListStore *model_username = gtk_list_store_new(COMBO_USER_MODEL_NB_COL, G_TYPE_STRING, G_TYPE_STRING,
                                                    G_TYPE_STRING); // text, token, id
  ui->comboBox_username = GTK_COMBO_BOX(gtk_combo_box_new_with_model(GTK_TREE_MODEL(model_username)));
  GtkCellRenderer *p_cell = gtk_cell_renderer_text_new();
  gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(ui->comboBox_username), p_cell, FALSE);
  gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(ui->comboBox_username), p_cell, "text", 0, NULL);

  ui->entry_album_title = GTK_ENTRY(gtk_entry_new());
  ui->entry_album_summary = GTK_ENTRY(gtk_entry_new());

  dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(ui->comboBox_username));
  dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(ui->entry_album_title));
  dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(ui->entry_album_summary));

  gtk_entry_set_width_chars(GTK_ENTRY(ui->entry_album_title), 0);
  gtk_entry_set_width_chars(GTK_ENTRY(ui->entry_album_summary), 0);


  // retrieve saved accounts
  ui_refresh_users(ui);

  //////// album list /////////
  GtkWidget *albumlist = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
  GtkListStore *model_album
      = gtk_list_store_new(COMBO_ALBUM_MODEL_NB_COL, G_TYPE_STRING, G_TYPE_STRING); // name, id
  ui->comboBox_album = GTK_COMBO_BOX(gtk_combo_box_new_with_model(GTK_TREE_MODEL(model_album)));
  p_cell = gtk_cell_renderer_text_new();
  gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(ui->comboBox_album), p_cell, FALSE);
  gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(ui->comboBox_album), p_cell, "text", 0, NULL);

  gtk_widget_set_sensitive(GTK_WIDGET(ui->comboBox_album), FALSE);
  gtk_combo_box_set_row_separator_func(ui->comboBox_album, combobox_separator, ui->comboBox_album, NULL);
  gtk_box_pack_start(GTK_BOX(albumlist), GTK_WIDGET(ui->comboBox_album), TRUE, TRUE, 0);

  ui->comboBox_privacy = GTK_COMBO_BOX(gtk_combo_box_text_new());
  GtkListStore *list_store = gtk_list_store_new(COMBO_ALBUM_MODEL_NB_COL, G_TYPE_STRING, G_TYPE_INT);
  GtkTreeIter iter;
  gtk_list_store_append(list_store, &iter);
  gtk_list_store_set(list_store, &iter, COMBO_PRIVACY_MODEL_NAME_COL, _("only me"),
                     COMBO_PRIVACY_MODEL_VAL_COL, FBALBUM_PRIVACY_SELF, -1);
  gtk_list_store_append(list_store, &iter);
  gtk_list_store_set(list_store, &iter, COMBO_PRIVACY_MODEL_NAME_COL, _("friends"),
                     COMBO_PRIVACY_MODEL_VAL_COL, FBALBUM_PRIVACY_ALL_FRIENDS, -1);
  gtk_list_store_append(list_store, &iter);
  gtk_list_store_set(list_store, &iter, COMBO_PRIVACY_MODEL_NAME_COL, _("public"),
                     COMBO_PRIVACY_MODEL_VAL_COL, FBALBUM_PRIVACY_EVERYONE, -1);
  gtk_list_store_append(list_store, &iter);
  gtk_list_store_set(list_store, &iter, COMBO_PRIVACY_MODEL_NAME_COL, _("friends of friends"),
                     COMBO_PRIVACY_MODEL_VAL_COL, FBALBUM_PRIVACY_FRIENDS_OF_FRIENDS, -1);

  gtk_combo_box_set_model(ui->comboBox_privacy, GTK_TREE_MODEL(list_store));

  gtk_combo_box_set_active(GTK_COMBO_BOX(ui->comboBox_privacy), 1); // Set default permission to private
  ui->button_login = GTK_BUTTON(gtk_button_new_with_label(_("login")));
  ui->connected = FALSE;

  // pack the ui
  ////the auth box
  GtkWidget *hbox_auth = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
  GtkWidget *vbox_auth_labels = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
  GtkWidget *vbox_auth_fields = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
  gtk_box_pack_start(GTK_BOX(hbox_auth), vbox_auth_labels, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(hbox_auth), vbox_auth_fields, TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(hbox_auth), TRUE, FALSE, 2);
  gtk_box_pack_start(GTK_BOX(vbox_auth_fields), GTK_WIDGET(ui->comboBox_username), TRUE, FALSE, 2);

  gtk_box_pack_start(GTK_BOX(vbox_auth_labels), GTK_WIDGET(gtk_label_new("")), TRUE, TRUE, 2);
  gtk_box_pack_start(GTK_BOX(vbox_auth_fields), GTK_WIDGET(ui->button_login), TRUE, FALSE, 2);

  gtk_box_pack_start(GTK_BOX(vbox_auth_fields), GTK_WIDGET(albumlist), TRUE, FALSE, 2);

  ////the album creation box
  ui->hbox_album = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5));
  gtk_widget_set_no_show_all(GTK_WIDGET(ui->hbox_album), TRUE); // hide it by default
  GtkWidget *vbox_album_labels = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
  GtkWidget *vbox_album_fields = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
  gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(ui->hbox_album), TRUE, FALSE, 5);
  gtk_box_pack_start(GTK_BOX(ui->hbox_album), vbox_album_labels, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(ui->hbox_album), vbox_album_fields, TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(vbox_album_labels), GTK_WIDGET(ui->label_album_title), TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(vbox_album_fields), GTK_WIDGET(ui->entry_album_title), TRUE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(vbox_album_labels), GTK_WIDGET(ui->label_album_summary), TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(vbox_album_fields), GTK_WIDGET(ui->entry_album_summary), TRUE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(vbox_album_labels), GTK_WIDGET(ui->label_album_privacy), TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(vbox_album_fields), GTK_WIDGET(ui->comboBox_privacy), TRUE, FALSE, 0);

  // connect buttons to signals
  g_signal_connect(G_OBJECT(ui->button_login), "clicked", G_CALLBACK(ui_login_clicked), (gpointer)ui);
  g_signal_connect(G_OBJECT(ui->comboBox_username), "changed", G_CALLBACK(ui_combo_username_changed),
                   (gpointer)ui);
  g_signal_connect(G_OBJECT(ui->comboBox_album), "changed", G_CALLBACK(ui_combo_album_changed), (gpointer)ui);

  g_object_unref(model_username);
  g_object_unref(model_album);
  g_object_unref(list_store);
}
Esempio n. 24
0
static void
tab_panel_app_add_browser_cb (MidoriApp*       app,
                              MidoriBrowser*   browser,
                              MidoriExtension* extension)
{
    GtkTreeStore* model;
    GtkWidget* treeview;
    GtkTreeViewColumn* column;
    GtkCellRenderer* renderer_pixbuf;
    GtkCellRenderer* renderer_text;
    GtkWidget* panel;
    GtkWidget* toolbar;
    gint i;
    /* GtkToolItem* toolitem; */

    g_object_set (browser, "show-tabs", FALSE, NULL);

    panel = katze_object_get_object (browser, "panel");

    model = gtk_tree_store_new (8, MIDORI_TYPE_VIEW,
        G_TYPE_STRING, G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF, G_TYPE_STRING,
        G_TYPE_INT, GDK_TYPE_COLOR, GDK_TYPE_COLOR);
    g_object_set_data (G_OBJECT (browser), "tab-panel-ext-model", model);
    treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
    gtk_tree_view_set_show_expanders (GTK_TREE_VIEW (treeview), FALSE);
    #if GTK_CHECK_VERSION (2, 12, 0)
    g_signal_connect (treeview, "query-tooltip",
        G_CALLBACK (tab_panel_treeview_query_tooltip_cb), NULL);
    gtk_widget_set_has_tooltip (treeview, TRUE);
    #endif
    column = gtk_tree_view_column_new ();
    renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
    gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE);
    gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (column), renderer_pixbuf,
        "pixbuf", 3, "cell-background-gdk", 6, NULL);
    renderer_text = gtk_cell_renderer_text_new ();
    gtk_tree_view_column_pack_start (column, renderer_text, TRUE);
    gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (column), renderer_text,
        "text", 4, "ellipsize", 5,
        "cell-background-gdk", 6, "foreground-gdk", 7, NULL);
    gtk_tree_view_column_set_expand (column, TRUE);
    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
    column = gtk_tree_view_column_new ();
    renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
    gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE);
    gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (column), renderer_pixbuf,
        "stock-id", 1, "follow-state", 2,
        "visible", 2, "cell-background-gdk", 6, NULL);
    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
    g_object_connect (treeview,
                      "signal::row-activated",
                      midori_extension_row_activated_cb, extension,
                      "signal::cursor-changed",
                      midori_extension_cursor_or_row_changed_cb, extension,
                      "signal::columns-changed",
                      midori_extension_cursor_or_row_changed_cb, extension,
                      "signal::button-release-event",
                      midori_extension_button_release_event_cb, extension,
                      "signal::key-release-event",
                      midori_extension_key_release_event_cb, extension,
                      "signal::popup-menu",
                      midori_extension_popup_menu_cb, extension,
                      NULL);
    gtk_widget_show (treeview);

    toolbar = gtk_toolbar_new ();
    g_object_set_data (G_OBJECT (browser), "tab-panel-ext-toolbar", toolbar);
    gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH_HORIZ);
    gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_BUTTON);
    gtk_widget_show (toolbar);

    /*
    TODO: Implement optional thumbnail images
    toolitem = gtk_toggle_tool_button_new_from_stock (STOCK_IMAGE);
    gtk_tool_item_set_is_important (toolitem, TRUE);
    g_signal_connect (toolitem, "toggled",
            G_CALLBACK (tab_panel_button_thumbnail_toggled_cb), notebook);
    gtk_widget_show (GTK_WIDGET (toolitem));
    gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1); */

    i = midori_panel_append_widget (MIDORI_PANEL (panel), treeview,
                                    STOCK_TAB_PANEL, _("Tab Panel"), toolbar);
    if (gtk_widget_get_visible (GTK_WIDGET (browser)))
        midori_panel_set_current_page (MIDORI_PANEL (panel), i);
    g_object_unref (panel);

    midori_browser_foreach (browser,
        (GtkCallback)tab_panel_browser_foreach_cb, treeview);

    g_signal_connect_after (browser, "add-tab",
        G_CALLBACK (tab_panel_browser_add_tab_cb), extension);
    g_signal_connect (browser, "remove-tab",
        G_CALLBACK (tab_panel_browser_remove_tab_cb), extension);
    g_signal_connect (browser, "notify::tab",
        G_CALLBACK (tab_panel_browser_notify_tab_cb), treeview);
    g_signal_connect (extension, "deactivate",
        G_CALLBACK (tab_panel_deactivate_cb), treeview);
    g_signal_connect (browser, "move-tab",
        G_CALLBACK (tab_panel_browser_move_tab_cb), NULL);
}
static gboolean
zimagez_upload_job (ScreenshooterJob *job, GArray *param_values, GError **error)
{
  const gchar *encoded_data;
  const gchar *image_path;
  const gchar *last_user;
  const gchar *proxy_uri;
  /* For translators: the first wildcard is the date, the second one the time,
   * e.g. "Taken on 12/31/99, at 23:13:48". */
  gchar *comment = screenshooter_get_datetime (_("Taken on %x, at %X"));
  gchar *data = NULL;
  gchar *encoded_password = NULL;
  gchar *file_name = NULL;
  gchar *login_response = NULL;
  gchar *online_file_name = NULL;
  gchar *password = g_strdup ("");
  gchar *title;
  gchar *user;

  gsize data_length;
  gboolean response = FALSE;

  const gchar *serverurl = "http://www.zimagez.com/apiXml.php";
  const gchar *method_login = "******";
  const gchar *method_logout = "apiXml.xmlrpcLogout";
  const gchar *method_upload = "apiXml.xmlrpcUpload";
  SoupSession *session;
  SoupURI *soup_proxy_uri;

  GError *tmp_error = NULL;
  GtkTreeIter iter;
  GtkListStore *liststore;
  GValue response_value;

  g_return_val_if_fail (SCREENSHOOTER_IS_JOB (job), FALSE);
  g_return_val_if_fail (param_values != NULL, FALSE);
  g_return_val_if_fail (param_values->len == 3, FALSE);
  g_return_val_if_fail (G_VALUE_HOLDS_STRING (&g_array_index (param_values, GValue, 0)), FALSE);
  g_return_val_if_fail (G_VALUE_HOLDS_STRING (&g_array_index (param_values, GValue, 1)), FALSE);
  g_return_val_if_fail (G_VALUE_HOLDS_STRING (&g_array_index (param_values, GValue, 2)), FALSE);
  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);

  g_object_set_data (G_OBJECT (job), "jobtype", "zimagez");
  if (exo_job_set_error_if_cancelled (EXO_JOB (job), error))
    {
      g_free (comment);
      g_free (password);

      return FALSE;
    }

  /* Get the last user */
  last_user = g_value_get_string (&g_array_index (param_values, GValue, 1));
  user = g_strdup (last_user);

  if (user == NULL)
    user = g_strdup ("");

  if (!g_utf8_validate (user, -1, NULL))
    {
      g_free (user);
      user = g_strdup ("");
    }

  g_object_set_data_full (G_OBJECT (job), "user",
                          g_strdup (user), (GDestroyNotify) g_free);

  /* Get the default title */
  title = g_strdup (g_value_get_string (&g_array_index (param_values, GValue, 2)));
  if (title == NULL)
    title = g_strdup ("");

  if (!g_utf8_validate (title, -1, NULL))
    {
      g_free (title);
      title = g_strdup ("");
    }

  /* Get the path of the image that is to be uploaded */
  image_path = g_value_get_string (&g_array_index (param_values, GValue, 0));

  /* Start the user soup session */
  exo_job_info_message (EXO_JOB (job), _("Initialize the connection..."));
  session = soup_session_sync_new ();

  /* Set the proxy URI if any */
  proxy_uri = g_getenv ("http_proxy");

  if (proxy_uri != NULL)
    {
      soup_proxy_uri = soup_uri_new (proxy_uri);
      g_object_set (session, "proxy-uri", soup_proxy_uri, NULL);
      soup_uri_free (soup_proxy_uri);
    }

  TRACE ("Get the information liststore ready.");
  liststore = gtk_list_store_new (2, G_TYPE_INT, G_TYPE_STRING);

  TRACE ("Append the user");
  gtk_list_store_append (liststore, &iter);
  gtk_list_store_set (liststore, &iter,
                      0, USER,
                      1, user,
                      -1);

  TRACE ("Append the password");
  gtk_list_store_append (liststore, &iter);
  gtk_list_store_set (liststore, &iter,
                      0, PASSWORD,
                      1, password,
                      -1);

  TRACE ("Append the title");
  gtk_list_store_append (liststore, &iter);
  gtk_list_store_set (liststore, &iter,
                      0, TITLE,
                      1, title,
                      -1);

  TRACE ("Append the comment");
  gtk_list_store_append (liststore, &iter);
  gtk_list_store_set (liststore, &iter,
                      0, COMMENT,
                      1, comment,
                      -1);

  TRACE ("Ask the user to fill the information items.");
  screenshooter_job_ask_info (job, liststore,
                              _("Please fill the following fields with your "
                                "<a href=\"http://www.zimagez.com\">ZimageZ</a> \n"
                                "user name, passsword and details about the screenshot."));

  gtk_tree_model_get_iter_first (GTK_TREE_MODEL (liststore), &iter);

  do
    {
      gint field_index;
      gchar *field_value = NULL;

      gtk_tree_model_get (GTK_TREE_MODEL (liststore), &iter,
                          0, &field_index,
                          1, &field_value,
                          -1);

      switch (field_index)
        {
          case USER:
            user = g_strdup (field_value);
            break;
          case PASSWORD:
            password = g_strdup (field_value);
            break;
          case TITLE:
            title = g_strdup (field_value);
            break;
          case COMMENT:
            comment = g_strdup (field_value);
            break;
          default:
            break;
        }

      g_free (field_value);
    }
  while (gtk_tree_model_iter_next (GTK_TREE_MODEL (liststore), &iter));

  while (!response)
    {
      if (exo_job_set_error_if_cancelled (EXO_JOB (job), error))
        {
          soup_session_abort (session);
          g_object_unref (session);

          g_free (user);
          g_free (password);
          g_free (title);
          g_free (comment);
          if (encoded_password != NULL)
            g_free (encoded_password);

          TRACE ("The upload job was cancelled.");

          return FALSE;
        }

      exo_job_info_message (EXO_JOB (job), _("Check the user information..."));

      /* Test if one of the information fields is empty */
      if (has_empty_field (liststore))
        {
          TRACE ("One of the fields was empty, let the user file it.");
          screenshooter_job_ask_info (job, liststore,
                                      _("<span weight=\"bold\" foreground=\"darkred\" "
                                        "stretch=\"semiexpanded\">You must fill all the "
                                        "fields.</span>"));
          continue;
        }

      encoded_password = g_utf8_strreverse (rot13 (password), -1);

      TRACE ("User: %s", user);
      TRACE ("Encoded password: %s", encoded_password);

      /* Start the user session */
      TRACE ("Call the login method");

      exo_job_info_message (EXO_JOB (job), _("Login on ZimageZ..."));

      if (!do_xmlrpc (session, serverurl, method_login,
                      &tmp_error, &response_value,
                      G_TYPE_STRING, user,
                      G_TYPE_STRING, encoded_password,
                      G_TYPE_INVALID))
        {
          g_propagate_error (error, tmp_error);
          soup_session_abort (session);
          g_object_unref (session);

          g_free (password);
          g_free (title);
          g_free (comment);
          g_free (encoded_password);

          return FALSE;
        }

      TRACE ("Read the login response");

      /* If the response is a boolean, there was an error */
      if (G_VALUE_HOLDS_BOOLEAN (&response_value))
        {
          response = g_value_get_boolean (&response_value);
        }
      /* Else we read the string response to get the session ID */
      else if (G_VALUE_HOLDS_STRING (&response_value))
        {
          TRACE ("Read the session ID");
          login_response = g_strdup (g_value_get_string (&response_value));
          response = TRUE;
        }
      /* We received an unexpected reply */
      else
        {
          GError *tmp_err =
            g_error_new (SOUP_XMLRPC_FAULT,
                         SOUP_XMLRPC_FAULT_PARSE_ERROR_NOT_WELL_FORMED,
                         "%s", _("An unexpected reply from ZimageZ was received."
                                 " The upload of the screenshot failed."));
          soup_session_abort (session);
          g_object_unref (session);

          g_free (user);
          g_free (password);
          g_free (title);
          g_free (comment);
          g_free (encoded_password);

          g_propagate_error (error, tmp_err);

          return FALSE;
        }

      g_value_unset (&response_value);

      if (!response)
        {
          /* Login failed, erase the password and ask for the correct on to the
             user */
          gtk_tree_model_get_iter_first (GTK_TREE_MODEL (liststore), &iter);

          do
            {
              gint field_index;

              gtk_tree_model_get (GTK_TREE_MODEL (liststore), &iter, 0, &field_index, -1);

              if (field_index == PASSWORD)
                {
                  gtk_list_store_set (liststore, &iter, 1, g_strdup (""), -1);
                  break;
                }
            }
          while (gtk_tree_model_iter_next (GTK_TREE_MODEL (liststore), &iter));

          screenshooter_job_ask_info (job, liststore,
                                      _("<span weight=\"bold\" foreground=\"darkred\" "
                                        "stretch=\"semiexpanded\">The user and the "
                                        "password you entered do not match. "
                                        "Please retry.</span>"));

          gtk_tree_model_get_iter_first (GTK_TREE_MODEL (liststore), &iter);

          do
            {
              gint field_index;
              gchar *field_value = NULL;

              gtk_tree_model_get (GTK_TREE_MODEL (liststore), &iter,
                                  0, &field_index,
                                  1, &field_value,
                                  -1);

              switch (field_index)
                {
                  case USER:
                    user = g_strdup (field_value);
                    break;
                  case PASSWORD:
                    password = g_strdup (field_value);
                    break;
                  case TITLE:
                    title = g_strdup (field_value);
                    break;
                  case COMMENT:
                    comment = g_strdup (field_value);
                    break;
                  default:
                    break;
                }

              g_free (field_value);
            }
          while (gtk_tree_model_iter_next (GTK_TREE_MODEL (liststore), &iter));
        }
    }

  g_object_set_data_full (G_OBJECT (job), "user",
                          g_strdup (user), (GDestroyNotify) g_free);

  g_free (user);
  g_free (password);
  g_free (encoded_password);

  /* Get the contents of the image file and encode it to base64 */
  g_file_get_contents (image_path, &data, &data_length, NULL);

  encoded_data = g_base64_encode ((guchar*)data, data_length);

  g_free (data);

  /* Get the basename of the image path */
  file_name = g_path_get_basename (image_path);

  exo_job_info_message (EXO_JOB (job), _("Upload the screenshot..."));

  TRACE ("Call the upload method");
  do_xmlrpc (session, serverurl, method_upload,
             &tmp_error, &response_value,
             G_TYPE_STRING, encoded_data,
             G_TYPE_STRING, file_name,
             G_TYPE_STRING, title,
             G_TYPE_STRING, comment,
             G_TYPE_STRING, login_response,
             G_TYPE_INVALID);

  g_free (title);
  g_free (comment);
  g_free (file_name);

  if (tmp_error)
    {
      soup_session_abort (session);
      g_object_unref (session);

      g_propagate_error (error, tmp_error);

      return FALSE;
    }

  /* If the response is a boolean, there was an error */
  if (G_VALUE_HOLDS_BOOLEAN (&response_value))
    {
      if (!g_value_get_boolean (&response_value))
        {
          GError *tmp_err =
            g_error_new (G_IO_ERROR, G_IO_ERROR_FAILED,
                         _("An error occurred while uploading the screenshot."));

          soup_session_abort (session);
          g_object_unref (session);
          g_propagate_error (error, tmp_err);

          return FALSE;
        }
    }
  /* Else we get the file name */
  else if (G_VALUE_HOLDS_STRING (&response_value))
    {
      TRACE ("The screenshot has been uploaded, get the file name.");
      online_file_name = g_strdup (g_value_get_string (&response_value));
    }
  /* We received un unexpected reply */
  else
    {
      GError *tmp_err =
        g_error_new (SOUP_XMLRPC_FAULT,
                     SOUP_XMLRPC_FAULT_PARSE_ERROR_NOT_WELL_FORMED,
                     "%s", _("An unexpected reply from ZimageZ was received."
                       " The upload of the screenshot failed."));
      soup_session_abort (session);
      g_object_unref (session);
      g_propagate_error (error, tmp_err);

      return FALSE;
    }

  g_value_unset (&response_value);

  /* End the user session */
  exo_job_info_message (EXO_JOB (job), _("Close the session on ZimageZ..."));

  TRACE ("Closing the user session");

  do_xmlrpc (session, serverurl, method_logout,
             &tmp_error, &response_value,
             G_TYPE_STRING, login_response,
             G_TYPE_INVALID);

  if (G_IS_VALUE (&response_value))
    g_value_unset (&response_value);

  /* Clean the soup session */
  soup_session_abort (session);
  g_object_unref (session);
  g_free (login_response);

  screenshooter_job_image_uploaded (job, online_file_name);

  if (tmp_error)
    {
      g_propagate_error (error, tmp_error);

      return FALSE;
    }

  return TRUE;
}
Esempio n. 26
0
void
load_interface(cam* cam) {
    gchar *title;
    GdkPixbuf *logo = NULL;
    GtkTreeView* treeview = GTK_TREE_VIEW(glade_xml_get_widget(cam->xml, "treeview_effects"));
    GtkCellRenderer* cell;

    menu_item_filter_type = g_quark_from_static_string("camorama-menu-item-filter-type");

    /* set up the tree view */
    cell = gtk_cell_renderer_text_new();
    g_object_set(cell, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
    gtk_cell_renderer_text_set_fixed_height_from_font(GTK_CELL_RENDERER_TEXT(cell), 1);
    gtk_tree_view_insert_column_with_attributes(treeview, -1,
		    				_("Effects"), cell,
						"text", CAMORAMA_FILTER_CHAIN_COL_NAME,
						NULL);
    cam->filter_chain = camorama_filter_chain_new();
    gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(cam->filter_chain));
    g_object_unref(cam->filter_chain);
    g_signal_connect_swapped(treeview, "button-press-event",
		    	     G_CALLBACK(treeview_clicked_cb), cam);
    g_signal_connect_swapped(treeview, "popup-menu",
		    	     G_CALLBACK(treeview_popup_menu_cb), cam);

    logo = gtk_icon_theme_load_icon(gtk_icon_theme_get_for_screen(gtk_widget_get_screen(glade_xml_get_widget(cam->xml, "main_window"))), CAMORAMA_STOCK_WEBCAM, 24, 0, NULL);
    gtk_window_set_default_icon(logo);
    logo = (GdkPixbuf *) create_pixbuf (PACKAGE_DATA_DIR "/pixmaps/camorama.png");
    if (logo == NULL) {
        printf ("\n\nLOGO NO GO\n\n");
    }

    if (cam->show_adjustments == FALSE) {
        gtk_widget_hide (glade_xml_get_widget
                         (cam->xml, "adjustments_table"));

        gtk_window_resize (GTK_WINDOW
                           (glade_xml_get_widget
                            (cam->xml, "main_window")), 320, 240);
    }
    gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(glade_xml_get_widget(cam->xml, "showadjustment_item")), cam->show_adjustments);
    if (cam->show_effects == FALSE) {
        gtk_widget_hide (glade_xml_get_widget (cam->xml, "scrolledwindow_effects"));
        gtk_window_resize (GTK_WINDOW
                           (glade_xml_get_widget
                            (cam->xml, "main_window")), 320, 240);
    }
    gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(glade_xml_get_widget(cam->xml, "show_effects")), cam->show_effects);

    cam->tray_icon = gtk_status_icon_new_from_stock (CAMORAMA_STOCK_WEBCAM);
    update_tooltip (cam);
    /* add the status to the plug */
    g_object_set_data (G_OBJECT (cam->tray_icon), "available",
                       GINT_TO_POINTER (1));
    g_object_set_data (G_OBJECT (cam->tray_icon), "embedded",
                       GINT_TO_POINTER (0));

    g_signal_connect (cam->tray_icon, "popup-menu",
                      G_CALLBACK (tray_clicked_callback), cam);

    /* connect the signals in the interface 
     * glade_xml_signal_autoconnect(xml);
     * this won't work, can't pass data to callbacks.  have to do it individually :(*/

    title = g_strdup_printf ("Camorama - %s - %dx%d", cam->vid_cap.name,
                             cam->x, cam->y);
    gtk_window_set_title (GTK_WINDOW
                          (glade_xml_get_widget (cam->xml, "main_window")),
                          title);
    g_free (title);

    gtk_window_set_icon (GTK_WINDOW
                         (glade_xml_get_widget (cam->xml, "main_window")),
                         logo);
    gtk_window_set_icon (GTK_WINDOW
                         (glade_xml_get_widget (cam->xml, "prefswindow")),
                         logo);

    glade_xml_signal_connect_data (cam->xml, "on_show_effects_activate",
                                   G_CALLBACK (on_show_effects_activate),
                                   cam);
    gtk_toggle_button_set_active ((GtkToggleButton *)
                                  glade_xml_get_widget (cam->xml,
                                                        "togglebutton1"),
                                  cam->show_adjustments);
    glade_xml_signal_connect_data (cam->xml,
                                   "on_show_adjustments_activate",
                                   G_CALLBACK
                                   (on_show_adjustments_activate), cam);

    glade_xml_signal_connect_data (cam->xml, "on_large_activate",
                                   G_CALLBACK (on_change_size_activate), cam);
    glade_xml_signal_connect_data (cam->xml, "on_medium_activate",
                                   G_CALLBACK (on_change_size_activate), cam);
    glade_xml_signal_connect_data (cam->xml, "on_small_activate",
                                   G_CALLBACK (on_change_size_activate), cam);

    //glade_xml_signal_connect_data(cam->xml, "capture_func", G_CALLBACK(on_change_size_activate), cam);
    glade_xml_signal_connect_data (cam->xml, "capture_func",
                                   G_CALLBACK (capture_func), cam);
    glade_xml_signal_connect_data (cam->xml, "gtk_main_quit",
                                   G_CALLBACK (delete_event), NULL);

    /* sliders */
    glade_xml_signal_connect_data (cam->xml, "contrast_change",
                                   G_CALLBACK (contrast_change), cam);
    gtk_range_set_value ((GtkRange *)
                         glade_xml_get_widget (cam->xml, "slider2"),
                         (int) (cam->contrast / 256));
    glade_xml_signal_connect_data (cam->xml, "brightness_change",
                                   G_CALLBACK (brightness_change), cam);
    gtk_range_set_value ((GtkRange *)
                         glade_xml_get_widget (cam->xml, "slider3"),
                         (int) (cam->brightness / 256));
    glade_xml_signal_connect_data (cam->xml, "colour_change",
                                   G_CALLBACK (colour_change), cam);
    gtk_range_set_value ((GtkRange *)
                         glade_xml_get_widget (cam->xml, "slider4"),
                         (int) (cam->colour / 256));
    glade_xml_signal_connect_data (cam->xml, "hue_change",
                                   G_CALLBACK (hue_change), cam);
    gtk_range_set_value ((GtkRange *)
                         glade_xml_get_widget (cam->xml, "slider5"),
                         (int) (cam->hue / 256));
    glade_xml_signal_connect_data (cam->xml, "wb_change",
                                   G_CALLBACK (wb_change), cam);
    gtk_range_set_value ((GtkRange *)
                         glade_xml_get_widget (cam->xml, "slider6"),
                         (int) (cam->wb / 256));

    /* buttons */
    glade_xml_signal_connect_data (cam->xml, "on_status_show",
                                   G_CALLBACK (on_status_show),
                                   (gpointer) cam);
    glade_xml_signal_connect_data (cam->xml, "on_quit_activate",
                                   G_CALLBACK (on_quit_activate),
                                   (gpointer) cam);
    glade_xml_signal_connect_data (cam->xml, "on_preferences1_activate",
                                   G_CALLBACK (on_preferences1_activate),
                                   (gpointer) cam);
    glade_xml_signal_connect_data (cam->xml, "on_about_activate",
                                   G_CALLBACK (on_about_activate),
                                   (gpointer) cam);

    /* prefs */
    glade_xml_signal_connect_data (cam->xml, "prefs_func",
                                   G_CALLBACK (prefs_func), cam);

    /* general */
    glade_xml_signal_connect_data (cam->xml, "cap_func",
                                   G_CALLBACK (cap_func), cam);

    gtk_toggle_button_set_active ((GtkToggleButton *)
                                  glade_xml_get_widget (cam->xml,
                                                        "captured_cb"),
                                  cam->cap);

    glade_xml_signal_connect_data (cam->xml, "rcap_func",
                                   G_CALLBACK (rcap_func), cam);
    gtk_toggle_button_set_active ((GtkToggleButton *)
                                  glade_xml_get_widget (cam->xml,
                                                        "rcapture"),
                                  cam->rcap);

    glade_xml_signal_connect_data (cam->xml, "acap_func",
                                   G_CALLBACK (acap_func), cam);
    gtk_toggle_button_set_active ((GtkToggleButton *)
                                  glade_xml_get_widget (cam->xml,
                                                        "acapture"),
                                  cam->acap);

    glade_xml_signal_connect_data (cam->xml, "interval_change",
                                   G_CALLBACK (interval_change), cam);

    gtk_spin_button_set_value ((GtkSpinButton *)
                               glade_xml_get_widget (cam->xml,
                                                     "interval_entry"),
                               (cam->timeout_interval / 60000));

    /* local */
    dentry = glade_xml_get_widget (cam->xml, "dentry");
    entry2 = glade_xml_get_widget (cam->xml, "entry2");
    gtk_entry_set_text (GTK_ENTRY
                        (gnome_file_entry_gtk_entry
                         (GNOME_FILE_ENTRY (dentry))), cam->pixdir);

    gtk_entry_set_text (GTK_ENTRY (entry2), cam->capturefile);

    glade_xml_signal_connect_data (cam->xml, "append_func",
                                   G_CALLBACK (append_func), cam);
    gtk_toggle_button_set_active ((GtkToggleButton *)
                                  glade_xml_get_widget (cam->xml,
                                                        "appendbutton"),
                                  cam->timefn);

    glade_xml_signal_connect_data (cam->xml, "jpg_func",
                                   G_CALLBACK (jpg_func), cam);
    if (cam->savetype == JPEG) {
        gtk_toggle_button_set_active ((GtkToggleButton *)
                                      glade_xml_get_widget (cam->xml,
                                                            "jpgb"), TRUE);
    }
    glade_xml_signal_connect_data (cam->xml, "png_func",
                                   G_CALLBACK (png_func), cam);
    if (cam->savetype == PNG) {
        gtk_toggle_button_set_active ((GtkToggleButton *)
                                      glade_xml_get_widget (cam->xml,
                                                            "pngb"), TRUE);
    }

    glade_xml_signal_connect_data (cam->xml, "ts_func",
                                   G_CALLBACK (ts_func), cam);
    gtk_toggle_button_set_active ((GtkToggleButton *)
                                  glade_xml_get_widget (cam->xml,
                                                        "tsbutton"),
                                  cam->timestamp);

    /* remote */
    login_entry = glade_xml_get_widget (cam->xml, "login_entry");
    host_entry = glade_xml_get_widget (cam->xml, "host_entry");
    pw_entry = glade_xml_get_widget (cam->xml, "pw_entry");
    directory_entry = glade_xml_get_widget (cam->xml, "directory_entry");
    filename_entry = glade_xml_get_widget (cam->xml, "filename_entry");
    gtk_entry_set_text (GTK_ENTRY (host_entry), cam->rhost);
    gtk_entry_set_text (GTK_ENTRY (login_entry), cam->rlogin);
    gtk_entry_set_text (GTK_ENTRY (pw_entry), cam->rpw);
    gtk_entry_set_text (GTK_ENTRY (directory_entry), cam->rpixdir);
    gtk_entry_set_text (GTK_ENTRY (filename_entry), cam->rcapturefile);

    glade_xml_signal_connect_data (cam->xml, "rappend_func",
                                   G_CALLBACK (rappend_func), cam);
    gtk_toggle_button_set_active ((GtkToggleButton *)
                                  glade_xml_get_widget (cam->xml,
                                                        "timecb"),
                                  cam->rtimefn);

    glade_xml_signal_connect_data (cam->xml, "rjpg_func",
                                   G_CALLBACK (rjpg_func), cam);
    if (cam->rsavetype == JPEG) {
        gtk_toggle_button_set_active ((GtkToggleButton *)
                                      glade_xml_get_widget (cam->xml,
                                                            "fjpgb"), TRUE);
    }
    glade_xml_signal_connect_data (cam->xml, "rpng_func",
                                   G_CALLBACK (rpng_func), cam);
    if (cam->rsavetype == PNG) {
        gtk_toggle_button_set_active ((GtkToggleButton *)
                                      glade_xml_get_widget (cam->xml,
                                                            "fpngb"), TRUE);
    }

    glade_xml_signal_connect_data (cam->xml, "rts_func",
                                   G_CALLBACK (rts_func), cam);
    gtk_toggle_button_set_active ((GtkToggleButton *)
                                  glade_xml_get_widget (cam->xml,
                                                        "tsbutton2"),
                                  cam->rtimestamp);

    /* timestamp */
    glade_xml_signal_connect_data (cam->xml, "customstring_func",
                                   G_CALLBACK (customstring_func), cam);
    gtk_toggle_button_set_active ((GtkToggleButton *)
                                  glade_xml_get_widget (cam->xml, "cscb"),
                                  cam->usestring);

    string_entry = glade_xml_get_widget (cam->xml, "string_entry");
    gtk_entry_set_text (GTK_ENTRY (string_entry), cam->ts_string);

    glade_xml_signal_connect_data (cam->xml, "drawdate_func",
                                   G_CALLBACK (drawdate_func), cam);
    gtk_toggle_button_set_active ((GtkToggleButton *)
                                  glade_xml_get_widget (cam->xml, "tscb"),
                                  cam->usedate);

    cam->status = glade_xml_get_widget (cam->xml, "status");
    set_sensitive (cam);
    gtk_widget_set_sensitive (glade_xml_get_widget
                              (cam->xml, "string_entry"), cam->usestring);

    gtk_widget_set_size_request (glade_xml_get_widget (cam->xml, "da"),
                                 cam->x, cam->y);

    prefswindow = glade_xml_get_widget (cam->xml, "prefswindow");
}
Esempio n. 27
0
static GSList *
dcc_chat_get_selected (void)
{
	return treeview_get_selected (GTK_TREE_MODEL (dcccwin.store),
											dcccwin.sel, CCOL_DCC);
}
Esempio n. 28
0
gboolean write_menu_conf( xmlTextWriterPtr writer,
		GtkTreeStore *menu_tree, GtkTreeIter *iterator )
{
	gboolean return_value = FALSE;
	gboolean include_open = FALSE;

	gchar *name = NULL;
	gchar *desktop_id = NULL;

        gboolean default_category;

	/* Make sure we have a valid iterator */
	if (!gtk_tree_store_iter_is_valid( menu_tree, iterator) ) {
		g_warning(  "write_menu_conf: invalid iterator." );
		return FALSE;
	}


	/* Loop through the model */
	do {
		gtk_tree_model_get( GTK_TREE_MODEL( menu_tree ), iterator, 
				TREE_MODEL_NAME,
				&name,
				TREE_MODEL_DESKTOP_ID,
				&desktop_id,
                                TREE_MODEL_DEFAULT,
                                &default_category,
				-1 );

		if ( !desktop_id || strlen( desktop_id ) == 0 ) {
			/* </Include> */
			if ( include_open == TRUE ) {
				if ( xmlTextWriterEndElement( writer ) < 0 ) {
					g_warning( "write_menu_conf: "
					          "failed to end Include element." );
					goto cleanup_and_exit;
				} else {
#ifdef DEBUG
					g_debug( "write_menu_conf: </Include>" );
#endif
				}
				include_open = FALSE;
			}
	
			/* <Menu> */
			if ( xmlTextWriterStartElement( writer,
						BAD_CAST "Menu" ) < 0 ) {
				g_warning( "write_menu_conf: "
				          "failed to start Menu element." );
				goto cleanup_and_exit;
			} else {
#ifdef DEBUG
				g_debug( "write_menu_conf: <Menu>" );
#endif
			}

			/* <Name> ... </Name> */
			if ( xmlTextWriterWriteElement( writer, (const xmlChar *) "Name", (const xmlChar *) name ) < 0 ) {
				g_warning( "write_menu_conf: "
				          "failed to write Name element." );
				goto cleanup_and_exit;
			} else {
				g_debug( "write_menu_conf: <Name>%s</Name>", name );
			}

                        if (default_category)
                        {
                                g_debug ("%s is default", name);
                                xmlTextWriterWriteElement( writer, (const xmlChar *) "All", (const xmlChar *)"" );
                        }

			GtkTreeIter child_iterator;

			/* Has children.. */
			if ( gtk_tree_model_iter_children( GTK_TREE_MODEL( menu_tree ),
						&child_iterator, iterator ) ) {

				/* Recurse */
				if ( !write_menu_conf( writer, menu_tree,
							&child_iterator ) ) {
					g_warning( "write_menu_conf: failed to recurse." );
					goto cleanup_and_exit;
				}
			}

			/* </Menu> */
			if ( xmlTextWriterEndElement( writer ) < 0 ) {
				g_warning ( "write_menu_conf: "
				           "failed to end Menu element." );
				goto cleanup_and_exit;
			} else {
				g_debug( "write_menu_conf: </Menu>" );
			}

		} else if ( desktop_id && strcmp( desktop_id,
					SEPARATOR_STRING ) == 0 ) {
			/* </Include> */
			if ( include_open == TRUE ) {
				if ( xmlTextWriterEndElement( writer ) < 0 ) {
					g_warning( "write_menu_conf: "
					          "failed to end Include element." );
					goto cleanup_and_exit;
				} else {
					g_debug( "write_menu_conf: </Include>" );
				}
				include_open = FALSE;
			}

			/* <Separator/> */

			/* This returns -1 for some reason. But this seems to work 
			 * and without this it doesn't work. Oh well.. */
			xmlTextWriterWriteElement( writer, (const xmlChar *) "Separator", NULL );
			xmlTextWriterEndElement( writer );

			g_debug( "write_menu_conf: <Separator/>" );

		} else if ( desktop_id && strlen ( desktop_id ) > 0 ) {
			/* <Include> */
			if ( include_open == FALSE ) {
				if ( xmlTextWriterStartElement( writer,
						BAD_CAST "Include") < 0 ) {
					g_warning( "write_menu_conf: "
					          "failed to start Include element." );
					goto cleanup_and_exit;
				} else {
					g_debug( "write_menu_conf: <Include>" );
				}

				include_open = TRUE;
			}

			/* <Filename> ... </Filename> */
			if ( xmlTextWriterWriteElement( writer,
					(const xmlChar *) "Filename", (const xmlChar *) desktop_id ) < 0 ) {
				g_warning( "write_menu_conf: "
				          "failed to write Filename element." );
				goto cleanup_and_exit;
			} else {
				g_debug( "write_menu_conf: "
				            "<Filename>%s</Filename>", desktop_id );
			}

		} else {
			g_warning( "write_menu_conf: 'what happen?'"
			          " - 'somebody set us up the bomb!'" );
			goto cleanup_and_exit;
		}
		
		if ( name ) {
			g_free( name );
			name = NULL;
		}

		if ( desktop_id ) {
			g_free( desktop_id );
			desktop_id = NULL;
		}

	} while ( gtk_tree_model_iter_next( GTK_TREE_MODEL( menu_tree ), iterator ) );

	/* </Include> */
	if ( include_open == TRUE ) {
		if ( xmlTextWriterEndElement( writer ) < 0 ) {
			g_warning( "write_menu_conf: "
			          "failed to end Include element." );
			goto cleanup_and_exit;
		} else {
			g_debug( "write_menu_conf: </Include>" );
		}
		include_open = FALSE;
	}

	/* Great! Everything went fine! */
	return_value = TRUE;

	cleanup_and_exit:

	if ( name ) {
		g_free( name );
	}

	if ( desktop_id ) {
		g_free( desktop_id );
	}

	return return_value;
}
Esempio n. 29
0
void prov_xdk_create_list (class prov_xdk_data *data)
{
iceb_clock sss(data->window);
GtkListStore *model=NULL;
GtkTreeIter iter;
SQLCURSOR cur;
char strsql[512];
int  kolstr=0;
SQL_str row;

//printf("prov_xdk_create_list %d\n",data->snanomer);
data->kl_shift=0; //0-отжата 1-нажата  

if(data->treeview != NULL)
  gtk_widget_destroy(data->treeview);

data->treeview = gtk_tree_view_new();


gtk_container_add (GTK_CONTAINER (data->sw), data->treeview);

g_signal_connect(data->treeview,"row_activated",G_CALLBACK(prov_xdk_v_row),data);

GtkTreeSelection *selection=gtk_tree_view_get_selection(GTK_TREE_VIEW(data->treeview));
gtk_tree_selection_set_mode(selection,GTK_SELECTION_SINGLE);
g_signal_connect(selection,"changed",G_CALLBACK(prov_xdk_vibor),data);

gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (data->treeview), TRUE); //Устанавливаются полоски при отображении списка
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (data->treeview)),GTK_SELECTION_SINGLE);


model = gtk_list_store_new (NUM_COLUMNS+1, 
G_TYPE_STRING, 
G_TYPE_STRING, 
G_TYPE_STRING, 
G_TYPE_STRING, 
G_TYPE_STRING, 
G_TYPE_STRING, 
G_TYPE_STRING, 
G_TYPE_STRING, 
G_TYPE_STRING, 
G_TYPE_STRING, 
G_TYPE_LONG, 
G_TYPE_INT,  
G_TYPE_INT,
G_TYPE_INT);

iceb_u_str zapros;

if(data->metka_r == 2)
  sprintf(strsql,"select datp,sh,shk,kodkon,deb,kre,komen,ktoi,vrem,val,kekv \
from Prov where kto='%s' and pod=%d and nomd='%s' and \
datd='%04d-%02d-%02d' and oper='%s' and tz=%d order by datp asc",
  data->metkasys,0,rec.nomdk.ravno_filtr(),
  rec.gd,rec.md,rec.dd,rec.kodop.ravno_filtr(),rec.tipz);

if(data->metka_r == 0)
  sprintf(strsql,"select datp,sh,shk,kodkon,deb,kre,komen,ktoi,vrem,val,kekv \
from Prov where kto='%s' and pod=%d and nomd='%s' and \
datd='%04d-%02d-%02d' and oper='%s' and tz=%d and deb <> 0. order by datp asc",
  data->metkasys,0,rec.nomdk.ravno_filtr(),
  rec.gd,rec.md,rec.dd,rec.kodop.ravno_filtr(),rec.tipz);
//  data->metkasys,0,data->nomdok.ravno_filtr(),
//  data->gd,data->md,data->dd,data->kodop.ravno_filtr(),data->tipz);

if(data->metka_r == 1)
  sprintf(strsql,"select datp,sh,shk,kodkon,deb,kre,komen,ktoi,vrem,val,kekv \
from Prov where kto='%s' and pod=%d and nomd='%s' and \
datd='%04d-%02d-%02d' and oper='%s' and tz=%d and kre <> 0. order by datp asc",
  data->metkasys,0,rec.nomdk.ravno_filtr(),
  rec.gd,rec.md,rec.dd,rec.kodop.ravno_filtr(),rec.tipz);

//  data->metkasys,0,data->nomdok.ravno_filtr(),
//  data->gd,data->md,data->dd,data->kodop.ravno_filtr(),data->tipz);

data->zapros.new_plus(strsql);


if((kolstr=cur.make_cursor(&bd,data->zapros.ravno())) < 0)
 {
  iceb_msql_error(&bd,gettext("Ошибка создания курсора !"),data->zapros.ravno(),data->window);
  return;
 }
//gtk_list_store_clear(model);

iceb_u_str ss[NUM_COLUMNS];

data->kolzap=0;
data->suma_deb=0.;
data->suma_kre=0.;

while(cur.read_cursor(&row) != 0)
 {
//  printf("%s %s %s %s\n",row[0],row[1],row[2],row[3]);
  
//  if(prov_xdk_prov_row(row,&data->rk,data->window) != 0)
//    continue;


//  if(iceb_u_SRAV(data->vvod.god.ravno(),row[0],0) == 0 && iceb_u_SRAV(data->vvod.shet.ravno(),row[1],0) == 0)
//    data->snanomer=data->kolzap;
  
  //Дата
  ss[COL_DATA].new_plus(iceb_u_sqldata(row[0]));
  
  //Счёт
  ss[COL_SHET].new_plus(iceb_u_toutf(row[1]));

  //Счёт корреспондент
  ss[COL_SHET_KOR].new_plus(iceb_u_toutf(row[2]));

  //Контрагент
  ss[COL_KONTR].new_plus(iceb_u_toutf(row[3]));

  //Дебет
  ss[COL_DEBET].new_plus(iceb_u_toutf(row[4]));
  data->suma_deb+=atof(row[4]);
  //Кредит
  ss[COL_KREDIT].new_plus(iceb_u_toutf(row[5]));
  data->suma_kre+=atof(row[5]);
  
  //Коментарий
  ss[COL_KOMENT].new_plus(iceb_u_toutf(row[6]));

  //Дата и время записи
  ss[COL_DATA_VREM].new_plus(iceb_u_toutf(iceb_u_vremzap(row[8])));

  //Кто записал
  ss[COL_KTO].new_plus(iceb_kszap(row[7],0,data->window));
  
  if(atoi(row[10]) != 0)
    ss[COL_KEKV].new_plus(row[10]);
  else  
    ss[COL_KEKV].new_plus("");

  gtk_list_store_append (model, &iter);

  gtk_list_store_set (model, &iter,
  COL_DATA,ss[COL_DATA].ravno(),
  COL_KEKV,ss[COL_KEKV].ravno(),
  COL_SHET,ss[COL_SHET].ravno(),
  COL_SHET_KOR,ss[COL_SHET_KOR].ravno(),
  COL_KONTR,ss[COL_KONTR].ravno(),
  COL_DEBET,ss[COL_DEBET].ravno(),
  COL_KREDIT,ss[COL_KREDIT].ravno(),
  COL_KOMENT,ss[COL_KOMENT].ravno(),
  COL_DATA_VREM,ss[COL_DATA_VREM].ravno(),
  COL_KTO,ss[COL_KTO].ravno(),
  COL_VREM,atol(row[8]),
  COL_KTOZ,atoi(row[7]),
  COL_VAL,atoi(row[9]),
  NUM_COLUMNS,data->kolzap,
  -1);

  data->kolzap++;
 }

gtk_tree_view_set_model (GTK_TREE_VIEW(data-> treeview),GTK_TREE_MODEL (model));

g_object_unref (GTK_TREE_MODEL (model));

prov_xdk_add_columns (GTK_TREE_VIEW (data->treeview));

if(data->kolzap == 0)
 {
  gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[SFK2]),FALSE);//Недоступна
  gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[FK3]),FALSE);//Недоступна
  gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[SFK3]),FALSE);//Недоступна
  gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[FK5]),FALSE);//Недоступна
 }
else
 {
  gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[SFK2]),TRUE);//Доступна
  gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[FK3]),TRUE);//Доступна
  gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[SFK3]),TRUE);//Доступна
  gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[FK5]),TRUE);//Доступна
 }

gtk_widget_show (data->treeview);
gtk_widget_show (data->sw);

iceb_snanomer(data->kolzap,&data->snanomer,data->treeview);

prov_xdk_sapka_menu(data);

gtk_widget_show(data->label_kolstr);


}
Esempio n. 30
0
gint
main (gint argc, gchar * argv[])
{
  IconBrowserData *data;
  gchar **themes = NULL;
  GList *ic, *icat;
  GtkListStore *store;
  GtkTreeSelection *sel;
  GtkTreeViewColumn *col;
  GtkCellRenderer *r;
  GtkWidget *w, *p, *box, *t;

  GOptionEntry entrs[] = {
    {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &themes, NULL, NULL},
    {NULL}
  };

  data = g_new0 (IconBrowserData, 1);

#ifdef ENABLE_NLS
  bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);
#endif

  data = g_new0 (IconBrowserData, 1);

  /* initialize GTK+ and parse the command line arguments */
  gtk_init_with_args (&argc, &argv, _("- Icon browser"), entrs, GETTEXT_PACKAGE, NULL);

  /* load icon theme */
  if (themes && themes[0])
    {
      data->theme = gtk_icon_theme_new ();
      gtk_icon_theme_set_custom_theme (data->theme, themes[0]);
    }
  else
    data->theme = gtk_icon_theme_get_default ();

  /* create interface */
  data->win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (data->win), _("Icon browser"));
  gtk_window_set_icon_name (GTK_WINDOW (data->win), "gtk-info");
  gtk_window_set_default_size (GTK_WINDOW (data->win), 500, 400);
  g_signal_connect (G_OBJECT (data->win), "delete-event", G_CALLBACK (gtk_main_quit), NULL);
  g_signal_connect (G_OBJECT (data->win), "key-press-event", G_CALLBACK (key_press_cb), NULL);

#if !GTK_CHECK_VERSION(3,0,0)
  box = gtk_vbox_new (FALSE, 5);
#else
  box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
#endif
  gtk_container_add (GTK_CONTAINER (data->win), box);
  gtk_container_set_border_width (GTK_CONTAINER (data->win), 5);

  /* create icon info box */
#if !GTK_CHECK_VERSION(3,0,0)
  t = gtk_table_new (3, 3, FALSE);
  gtk_table_set_col_spacings (GTK_TABLE (t), 5);
  gtk_table_set_row_spacings (GTK_TABLE (t), 5);
#else
  t = gtk_grid_new ();
  gtk_grid_set_row_spacing (GTK_GRID (t), 5);
  gtk_grid_set_column_spacing (GTK_GRID (t), 5);
#endif
  gtk_box_pack_start (GTK_BOX (box), t, FALSE, FALSE, 2);

  data->image = gtk_image_new_from_stock ("gtk-missing-image", GTK_ICON_SIZE_DIALOG);
#if !GTK_CHECK_VERSION(3,0,0)
  gtk_table_attach (GTK_TABLE (t), data->image, 0, 1, 0, 3, GTK_FILL, 0, 0, 0);
#else
  gtk_grid_attach (GTK_GRID (t), data->image, 0, 0, 1, 3);
#endif

  w = gtk_label_new (NULL);
  gtk_label_set_markup (GTK_LABEL (w), _("<b>Name:</b>"));
  gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5);
#if !GTK_CHECK_VERSION(3,0,0)
  gtk_table_attach (GTK_TABLE (t), w, 1, 2, 0, 1, GTK_FILL, 0, 0, 0);
#else
  gtk_grid_attach (GTK_GRID (t), w, 1, 0, 1, 1);
#endif
  data->lname = gtk_label_new (NULL);
  gtk_label_set_selectable (GTK_LABEL (data->lname), TRUE);
  gtk_misc_set_alignment (GTK_MISC (data->lname), 0, 0.5);
#if !GTK_CHECK_VERSION(3,0,0)
  gtk_table_attach (GTK_TABLE (t), data->lname, 2, 3, 0, 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);
#else
  gtk_grid_attach (GTK_GRID (t), data->lname, 2, 0, 1, 1);
  gtk_widget_set_hexpand (data->lname, TRUE);
#endif

  w = gtk_label_new (NULL);
  gtk_label_set_markup (GTK_LABEL (w), _("<b>Sizes:</b>"));
  gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5);
#if !GTK_CHECK_VERSION(3,0,0)
  gtk_table_attach (GTK_TABLE (t), w, 1, 2, 1, 2, GTK_FILL, 0, 0, 0);
#else
  gtk_grid_attach (GTK_GRID (t), w, 1, 1, 1, 1);
#endif
  data->lsize = gtk_label_new (NULL);
  gtk_label_set_selectable (GTK_LABEL (data->lsize), TRUE);
  gtk_misc_set_alignment (GTK_MISC (data->lsize), 0, 0.5);
#if !GTK_CHECK_VERSION(3,0,0)
  gtk_table_attach (GTK_TABLE (t), data->lsize, 2, 3, 1, 2, GTK_FILL | GTK_EXPAND, 0, 0, 0);
#else
  gtk_grid_attach (GTK_GRID (t), data->lsize, 2, 1, 1, 1);
  gtk_widget_set_hexpand (data->lsize, TRUE);
#endif

  w = gtk_label_new (NULL);
  gtk_label_set_markup (GTK_LABEL (w), _("<b>Filename:</b>"));
  gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5);
#if !GTK_CHECK_VERSION(3,0,0)
  gtk_table_attach (GTK_TABLE (t), w, 1, 2, 2, 3, GTK_FILL, 0, 0, 0);
#else
  gtk_grid_attach (GTK_GRID (t), w, 1, 2, 1, 1);
#endif
  data->lfile = gtk_label_new (NULL);
  gtk_label_set_selectable (GTK_LABEL (data->lfile), TRUE);
  gtk_misc_set_alignment (GTK_MISC (data->lfile), 0, 0.5);
#if !GTK_CHECK_VERSION(3,0,0)
  gtk_table_attach (GTK_TABLE (t), data->lfile, 2, 3, 2, 3, GTK_FILL | GTK_EXPAND, 0, 0, 0);
#else
  gtk_grid_attach (GTK_GRID (t), data->lfile, 2, 2, 1, 1);
  gtk_widget_set_hexpand (data->lfile, TRUE);
#endif

  /* create icon browser */
#if !GTK_CHECK_VERSION(3,0,0)
  p = gtk_hpaned_new ();
#else
  p = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
#endif
  gtk_paned_set_position (GTK_PANED (p), 150);
  gtk_box_pack_start (GTK_BOX (box), p, TRUE, TRUE, 2);

  /* create category list */
  w = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (w), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (w), GTK_SHADOW_ETCHED_IN);
  gtk_paned_add1 (GTK_PANED (p), w);

  store = gtk_list_store_new (1, G_TYPE_STRING);

  data->cat_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (data->cat_list), TRUE);
  gtk_container_add (GTK_CONTAINER (w), data->cat_list);

  sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (data->cat_list));
  g_signal_connect (G_OBJECT (sel), "changed", G_CALLBACK (select_cat), data);

  r = gtk_cell_renderer_text_new ();
  col = gtk_tree_view_column_new_with_attributes (_("Category"), r, "text", 0, NULL);
  gtk_tree_view_column_set_expand (col, TRUE);
  gtk_tree_view_append_column (GTK_TREE_VIEW (data->cat_list), col);

  /* load icons category */
  data->icons = g_hash_table_new (g_direct_hash, g_direct_equal);
  icat = gtk_icon_theme_list_contexts (data->theme);
  for (ic = icat; ic; ic = ic->next)
    {
      GtkTreeIter iter;

      gtk_list_store_append (store, &iter);
      gtk_list_store_set (store, &iter, 0, ic->data, -1);
      g_free (ic->data);
    }
  g_list_free (icat);

  /* create icons list */
  w = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (w), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (w), GTK_SHADOW_ETCHED_IN);
  gtk_paned_add2 (GTK_PANED (p), w);

  data->icon_list = gtk_tree_view_new ();
  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (data->icon_list), TRUE);
  gtk_container_add (GTK_CONTAINER (w), data->icon_list);

  sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (data->icon_list));
  g_signal_connect (G_OBJECT (sel), "changed", G_CALLBACK (select_icon), data);

  col = gtk_tree_view_column_new ();
  gtk_tree_view_column_set_title (col, _("Icons"));
  gtk_tree_view_column_set_sort_column_id (col, 1);
  r = gtk_cell_renderer_pixbuf_new ();
  gtk_tree_view_column_pack_start (col, r, FALSE);
  gtk_tree_view_column_set_attributes (col, r, "pixbuf", 0, NULL);
  r = gtk_cell_renderer_text_new ();
  gtk_tree_view_column_pack_start (col, r, FALSE);
  gtk_tree_view_column_set_attributes (col, r, "text", 1, NULL);
  gtk_tree_view_column_set_expand (col, TRUE);
  gtk_tree_view_append_column (GTK_TREE_VIEW (data->icon_list), col);

  gtk_widget_show_all (data->win);

  /* run it */
  gtk_main ();

  return 0;
}