Exemple #1
0
static void
git_log_pane_init (GitLogPane *self)
{
	gchar *objects[] = {"log_pane",
						"log_branch_combo_model",
						"log_loading_model",
						"find_button_image",
						NULL};
	GError *error = NULL;
	GtkWidget *log_pane;
	GtkWidget *path_entry;
	GtkTreeView *log_view;
	GtkTreeViewColumn *ref_icon_column;
	GtkTreeViewColumn *graph_column;
	GtkTreeViewColumn *short_log_column;
	GtkTreeViewColumn *author_column;
	GtkTreeViewColumn *date_column;
	GtkCellRenderer *ref_icon_renderer;
	GtkCellRenderer *short_log_renderer;
	GtkCellRenderer *author_renderer;
	GtkCellRenderer *date_renderer;
	GtkTreeViewColumn *loading_spinner_column;
	GtkCellRenderer *loading_spinner_renderer;
	GtkCellRenderer *loading_indicator_renderer;
	GtkComboBox *branch_combo;
	GtkTreeSelection *selection;

	self->priv = g_new0 (GitLogPanePriv, 1);
	self->priv->builder = gtk_builder_new ();

	if (!gtk_builder_add_objects_from_file (self->priv->builder, BUILDER_FILE, 
	                                        objects, 
	                                        &error))
	{
		g_warning ("Couldn't load builder file: %s", error->message);
		g_error_free (error);
	}

	log_pane = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
	                                               "log_pane"));
	path_entry = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
	                                                 "path_entry"));
	log_view = GTK_TREE_VIEW (gtk_builder_get_object (self->priv->builder,
	                                                  "log_view"));
	ref_icon_column = GTK_TREE_VIEW_COLUMN (gtk_builder_get_object (self->priv->builder,
	                                                                "ref_icon_column"));
	graph_column = GTK_TREE_VIEW_COLUMN (gtk_builder_get_object (self->priv->builder,
	                                                             "graph_column"));
	short_log_column = GTK_TREE_VIEW_COLUMN (gtk_builder_get_object (self->priv->builder,
	                                                                 "short_log_column"));
	author_column = GTK_TREE_VIEW_COLUMN (gtk_builder_get_object (self->priv->builder,
	                                                              "author_column"));
	date_column = GTK_TREE_VIEW_COLUMN (gtk_builder_get_object (self->priv->builder,
	                                							"date_column"));
	ref_icon_renderer = GTK_CELL_RENDERER (gtk_builder_get_object (self->priv->builder,
	                                                               "ref_icon_renderer"));
	author_renderer = GTK_CELL_RENDERER (gtk_builder_get_object (self->priv->builder,
	                                                             "author_renderer"));
	date_renderer = GTK_CELL_RENDERER (gtk_builder_get_object (self->priv->builder,
	                                                           "date_renderer"));
	branch_combo = GTK_COMBO_BOX (gtk_builder_get_object (self->priv->builder,
	                                                      "branch_combo"));
	loading_spinner_column = GTK_TREE_VIEW_COLUMN (gtk_builder_get_object (self->priv->builder,
	                                                                       "loading_spinner_column"));
	selection = gtk_tree_view_get_selection (log_view);

	/* Path entry */
	g_signal_connect (G_OBJECT (path_entry), "icon-release",
	                  G_CALLBACK (on_path_entry_icon_release),
	                  self);

	/* Set up the log model */
	self->priv->log_model = gtk_list_store_new (1, GIT_TYPE_REVISION);

	/* Ref icon column */
	gtk_tree_view_column_set_cell_data_func (ref_icon_column, ref_icon_renderer,
	                                         (GtkTreeCellDataFunc) ref_icon_cell_function,
	                                         self, NULL);


	/* Graph column */
	self->priv->graph_renderer = giggle_graph_renderer_new ();

	gtk_tree_view_column_pack_start (graph_column, self->priv->graph_renderer,
	                                 TRUE);
	gtk_tree_view_column_add_attribute (graph_column, self->priv->graph_renderer,
	                                    "revision", 0);

	/* Short log column. We have to create this render ouselves becuause Glade
	 * doesn't seem to give us to option to pack it with expand */
	short_log_renderer = gtk_cell_renderer_text_new ();
	g_object_set (G_OBJECT (short_log_renderer), "ellipsize", 
	              PANGO_ELLIPSIZE_END, NULL);
	gtk_tree_view_column_pack_start (short_log_column, short_log_renderer, 
	                                 TRUE);
	gtk_tree_view_column_set_cell_data_func (short_log_column, short_log_renderer,
	                                         (GtkTreeCellDataFunc) short_log_cell_function,
	                                         NULL, NULL);

	/* Author column */
	gtk_tree_view_column_set_cell_data_func (author_column, author_renderer,
	                                         (GtkTreeCellDataFunc) author_cell_function,
	                                         NULL, NULL);

	/* Date column */
	gtk_tree_view_column_set_cell_data_func (date_column, date_renderer,
	                                         (GtkTreeCellDataFunc) date_cell_function,
	                                         NULL, NULL);
	
	gtk_tree_view_set_model (log_view, GTK_TREE_MODEL (self->priv->log_model));

	/* Ref icon tooltip */
	g_signal_connect (G_OBJECT (log_view), "query-tooltip",
	                  G_CALLBACK (on_log_view_query_tooltip),
	                  self);

	/* Loading indicator. The loading indicator is a second tree view display
	 * that looks just like the real log display, except that it displays a 
	 * spinner renderer and the text "Loading..." in the Short Log column. */
	self->priv->log_loading_model = GTK_LIST_STORE (gtk_builder_get_object (self->priv->builder,
	                                                                        "log_loading_model"));
	loading_spinner_renderer = gtk_cell_renderer_spinner_new ();
	loading_indicator_renderer = gtk_cell_renderer_text_new ();

	g_object_set (G_OBJECT (loading_spinner_renderer), "active", TRUE, NULL);

	gtk_tree_view_column_pack_start (loading_spinner_column, 
	                                 loading_spinner_renderer, FALSE);
	gtk_tree_view_column_pack_start (loading_spinner_column, 
	                                 loading_indicator_renderer, TRUE);
	gtk_tree_view_column_add_attribute (loading_spinner_column,
	                                    loading_spinner_renderer,
	                                    "pulse", LOADING_COL_PULSE);
	gtk_tree_view_column_add_attribute (loading_spinner_column,
	                                    loading_indicator_renderer,
	                                    "text", LOADING_COL_INDICATOR);

	/* DnD source */
	gtk_tree_view_enable_model_drag_source (log_view,
	                                        GDK_BUTTON1_MASK,
	                                        drag_source_targets,
	                                        G_N_ELEMENTS (drag_source_targets),
	                                        GDK_ACTION_COPY);

	g_signal_connect (G_OBJECT (log_view), "drag-data-get",
	                  G_CALLBACK (on_log_view_drag_data_get),
	                  self);

	/* DnD target. Use this as a means of selecting a file to view the 
	 * log of. Files or folders would normally be dragged in from the file 
	 * manager, but they can come from any source that supports URI's. */
	gtk_drag_dest_set (log_pane, 
	                   GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT, 
	                   drag_target_targets,
	                   G_N_ELEMENTS (drag_target_targets), 
	                   GDK_ACTION_COPY | GDK_ACTION_MOVE);

	g_signal_connect (G_OBJECT (log_pane), "drag-data-received",
	                  G_CALLBACK (on_log_pane_drag_data_received),
	                  self);

	g_signal_connect (G_OBJECT (log_pane), "drag-drop",
	                  G_CALLBACK (on_log_pane_drag_drop),
	                  self);

	/* Pop up menu */
	g_signal_connect (G_OBJECT (log_view), "button-press-event",
	                  G_CALLBACK (on_log_view_button_press_event),
	                  self);

	/* The loading view always has one row. Cache a copy of its iter for easy
	 * access. */
	gtk_tree_model_get_iter_first (GTK_TREE_MODEL (self->priv->log_loading_model), 
	                               &(self->priv->spinner_iter));

	/* FIXME: GtkSpinner doesn't have those anymore */
	self->priv->spin_cycle_duration = 1000;
	self->priv->spin_cycle_steps =  12;
	
	g_object_set (G_OBJECT (loading_spinner_renderer), "active", TRUE, NULL);

	/* Log message display */
	gtk_tree_selection_set_select_function (selection,
	                                        (GtkTreeSelectionFunc) on_log_view_row_selected,
	                                        self, NULL);

	/* Branch handling */
	self->priv->branches_table = g_hash_table_new_full (g_str_hash, g_str_equal,
	                                                    g_free, 
	                                                    (GDestroyNotify) gtk_tree_path_free);

	g_signal_connect (G_OBJECT (branch_combo), "changed",
	                  G_CALLBACK (on_branch_combo_changed),
	                  self);
	
}
Exemple #2
0
void linphone_gtk_call_log_update(GtkWidget *w){
	GtkTreeView *v=GTK_TREE_VIEW(linphone_gtk_get_widget(w,"logs_view"));
	GtkTreeStore *store;
	const MSList *logs;
	GtkTreeSelection *select;
	GtkWidget *notebook=linphone_gtk_get_widget(w,"viewswitch");
	gint nb;

	store=(GtkTreeStore*)gtk_tree_view_get_model(v);
	if (store==NULL){
		store=gtk_tree_store_new(3,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_POINTER,G_TYPE_STRING);
		gtk_tree_view_set_model(v,GTK_TREE_MODEL(store));
		g_object_unref(G_OBJECT(store));
		fill_renderers(GTK_TREE_VIEW(linphone_gtk_get_widget(w,"logs_view")));
		select=gtk_tree_view_get_selection(v);
		gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);
		g_signal_connect_swapped(G_OBJECT(select),"changed",(GCallback)call_log_selection_changed,v);
		g_signal_connect(G_OBJECT(notebook),"focus-tab",(GCallback)linphone_gtk_call_log_reset_missed_call,NULL);
		g_signal_connect(G_OBJECT(v),"button-press-event",(GCallback)linphone_gtk_call_log_button_pressed,NULL);
	}
	nb=linphone_core_get_missed_calls_count(linphone_gtk_get_core());
	if(nb > 0)
		linphone_gtk_call_log_display_missed_call(nb);
	gtk_tree_store_clear (store);

	for (logs=linphone_core_get_call_logs(linphone_gtk_get_core());logs!=NULL;logs=logs->next){
		LinphoneCallLog *cl=(LinphoneCallLog*)logs->data;
		GtkTreeIter iter, iter2;
		LinphoneAddress *la=linphone_call_log_get_dir(cl)==LinphoneCallIncoming ? linphone_call_log_get_from(cl) : linphone_call_log_get_to(cl);
		char *addr= linphone_address_as_string(la);
		const char *display;
		gchar *logtxt, *headtxt, *minutes, *seconds;
		gchar quality[20];
		const char *status=NULL;
		gchar *start_date=NULL;
		LinphoneFriend *lf=NULL;
		int duration=linphone_call_log_get_duration(cl);
		time_t start_date_time=linphone_call_log_get_start_date(cl);
		const gchar *call_status_icon_name;

#if GLIB_CHECK_VERSION(2,30,0) // The g_date_time_format function exists since 2.26.0 but the '%c' format is only supported since 2.30.0
		if (start_date_time){
			GDateTime *dt=g_date_time_new_from_unix_local(start_date_time);
			start_date=g_date_time_format(dt,"%c");
			g_date_time_unref(dt);
		}
#else
		start_date=g_strdup(ctime(&start_date_time));
		if (start_date[strlen(start_date) - 1] == '\n') {
			start_date[strlen(start_date) - 1] = '\0';
		}
#endif
		lf=linphone_core_get_friend_by_address(linphone_gtk_get_core(),addr);
		if(lf != NULL){
			if ((display=linphone_address_get_display_name(linphone_friend_get_address(lf)))) {
				/*update display name from friend*/
				linphone_address_set_display_name(la,display);
			}
		} else {
			display=linphone_address_get_display_name(la);
		}
		if (display==NULL){
			display=linphone_address_get_username (la);
			if (display==NULL){
				display=linphone_address_get_domain (la);
			}
		}

		if (linphone_call_log_get_quality(cl)!=-1){
			snprintf(quality,sizeof(quality),"%.1f",linphone_call_log_get_quality(cl));
		}else snprintf(quality,sizeof(quality)-1,"%s",_("n/a"));
		switch(linphone_call_log_get_status(cl)){
			case LinphoneCallAborted:
				status=_("Aborted");
			break;
			case LinphoneCallMissed:
				status=_("Missed");
			break;
			case LinphoneCallDeclined:
				status=_("Declined");
			break;
			default:
			break;
		}
		minutes=g_markup_printf_escaped(
			ngettext("%i minute", "%i minutes", duration/60),
			duration/60);
		seconds=g_markup_printf_escaped(
			ngettext("%i second", "%i seconds", duration%60),
			duration%60);
		if (status==NULL) {
				headtxt=g_markup_printf_escaped("<big><b>%s</b></big>\t%s",display,start_date ? start_date : "");
				logtxt=g_markup_printf_escaped(
				_("<small><i>%s</i>\t"
				  "<i>Quality: %s</i></small>\n%s\t%s\t"),
				addr, quality, minutes, seconds);
		} else {
			headtxt=g_markup_printf_escaped(_("<big><b>%s</b></big>\t%s"),display,start_date ? start_date : "");
			logtxt=g_markup_printf_escaped(
			"<small><i>%s</i></small>\t"
				"\n%s",addr, status);
		}
		g_free(minutes);
		g_free(seconds);
		if (start_date) g_free(start_date);
		gtk_tree_store_append (store,&iter,NULL);
		call_status_icon_name = linphone_call_log_get_dir(cl) == LinphoneCallOutgoing ?
			"linphone-call-status-outgoing" : "linphone-call-status-incoming";
		gtk_tree_store_set (store,&iter,
		               0, call_status_icon_name,
		               1, headtxt,2,cl,-1);
		gtk_tree_store_append (store,&iter2,&iter);
		gtk_tree_store_set (store,&iter2,1,logtxt,-1);
		ms_free(addr);
		g_free(logtxt);
		g_free(headtxt);
	}
}
Exemple #3
0
void
remmina_nx_session_set_tree_view (RemminaNXSession *nx, GtkTreeView *tree)
{
    gtk_tree_view_set_model (tree, GTK_TREE_MODEL (nx->session_list));
}
Exemple #4
0
void clist_init(void)
{
	GtkTreeView *view = GTK_TREE_VIEW(clist_wnd);
	GtkTreeModel *model = GTK_TREE_MODEL(list);
	GtkCellRenderer *renderer;
	GtkTreeSelection *selection;
	gint i;

	list = gtk_list_store_new(CLIST_NCOLS, GDK_TYPE_PIXBUF,
					G_TYPE_STRING, G_TYPE_STRING, 
					G_TYPE_STRING, G_TYPE_STRING, 
				   G_TYPE_POINTER
			       );
	model = GTK_TREE_MODEL(list);

	gtk_tree_view_set_model(view, model);
	gtk_tree_view_set_headers_visible(view, TRUE);
	gtk_tree_view_set_headers_clickable(view, TRUE);
	gtk_tree_view_set_rules_hint(view, FALSE);

	renderer = gtk_cell_renderer_pixbuf_new();
	gtk_tree_view_insert_column_with_attributes(view, -1, "",
						    renderer, "pixbuf",
						    COLUMN_ICON, NULL);

	renderer = gtk_cell_renderer_text_new();
	gtk_tree_view_insert_column_with_attributes(view, -1, _("Name"),
						    renderer, "text",
						    COLUMN_NAME, NULL);

	renderer = gtk_cell_renderer_text_new();
	gtk_tree_view_insert_column_with_attributes(view, -1, _("Type"),
						    renderer, "text",
						    COLUMN_TYPE, NULL);

	renderer = gtk_cell_renderer_text_new();
	gtk_tree_view_insert_column_with_attributes(view, -1, _("Size"),
						    renderer, "text",
						    COLUMN_SIZE, NULL);

	renderer = gtk_cell_renderer_text_new();
	gtk_tree_view_insert_column_with_attributes(view, -1, _("Date"),
						    renderer, "text",
						    COLUMN_DATE, NULL);

	for (i = 0; i < CLIST_NVCOLS; i++) 
	{
		GtkTreeViewColumn *col;

		col = gtk_tree_view_get_column(view, i);
		gtk_tree_view_column_set_resizable(col, TRUE);

		gtk_tree_view_column_set_clickable(col, TRUE);
		g_signal_connect(G_OBJECT(col), "clicked", G_CALLBACK(column_clicked), view);
	}

	selection = gtk_tree_view_get_selection(view);
	gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
	gtk_tree_selection_set_select_function(selection, select_func, NULL, NULL);
	g_signal_connect(G_OBJECT(selection), "changed",
			 G_CALLBACK(tree_selection_changed), NULL);
}
Exemple #5
0
void l_uosoppcreate_list (class l_uosoppdata *data)
{
GtkListStore *model=NULL;
GtkTreeIter iter;
SQLCURSOR cur;
SQLCURSOR cur1;
char strsql[512];
int  kolstr=0;
SQL_str row;
iceb_u_str zagolov;

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

gdk_window_set_cursor(data->window->window,gdk_cursor_new(ICEB_CURSOR_GDITE));
iceb_refresh();

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(l_uosoppv_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(l_uosoppvibor),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_INT);

sprintf(strsql,"select * from Uospri order by kod asc");

data->zapros.new_plus(strsql);

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

iceb_u_str ss[NUM_COLUMNS];

data->kolzap=0;


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

  if(iceb_u_SRAV(data->kodtv.ravno(),row[0],0) == 0)
   data->snanomer=data->kolzap;

  //Код группы
  ss[COL_KOD].new_plus(iceb_u_toutf(row[0]));

  //Наименование группы
  ss[COL_NAIM].new_plus(iceb_u_toutf(row[1]));


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

  //Кто записал
  ss[COL_KTO].new_plus(iceb_kszap(row[2],0,data->window));

  //Вид операции
  ss[COL_VIDO].new_plus("");
  if(row[4][0] == '0')
    ss[COL_VIDO].new_plus(gettext("Внешняя"));
  if(row[4][0] == '1')
    ss[COL_VIDO].new_plus(gettext("Внутренняя"));
  if(row[4][0] == '2')
    ss[COL_VIDO].new_plus(gettext("Смена стоимости"));
  //Проводки
  if(row[5][0] == '0')
    ss[COL_PROV].new_plus(gettext("Нужно делать"));
  if(row[5][0] == '1')
    ss[COL_PROV].new_plus(gettext("Не нужно делать"));
  
  gtk_list_store_append (model, &iter);

  gtk_list_store_set (model, &iter,
  COL_KOD,ss[COL_KOD].ravno(),
  COL_NAIM,ss[COL_NAIM].ravno(),
  COL_VIDO,ss[COL_VIDO].ravno(),
  COL_PROV,ss[COL_PROV].ravno(),
  COL_DATA_VREM,ss[COL_DATA_VREM].ravno(),
  COL_KTO,ss[COL_KTO].ravno(),
  NUM_COLUMNS,data->kolzap,
  -1);

  data->kolzap++;
 }
data->kodtv.new_plus("");
gtk_tree_view_set_model (GTK_TREE_VIEW(data-> treeview),GTK_TREE_MODEL (model));

g_object_unref (GTK_TREE_MODEL (model));

l_uosoppadd_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[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[FK5]),TRUE);//Доступна
 }

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

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

if(data->poi.metka_poi == 1 )
 {

// printf("Формирование заголовка с реквизитами поиска.\n");
  iceb_u_str strpoi;  

  strpoi.new_plus(gettext("Поиск"));
  strpoi.plus(" !!!");

  iceb_str_poisk(&strpoi,data->poi.kod.ravno(),gettext("Код"));
  iceb_str_poisk(&strpoi,data->poi.naim.ravno(),gettext("Наименование"));

  gtk_label_set_text(GTK_LABEL(data->label_poisk),strpoi.ravno_toutf());
  gtk_widget_show(data->label_poisk);
 }
else
 {
  gtk_widget_hide(data->label_poisk); 
 }

zagolov.new_plus(gettext("Список приходных операций"));

sprintf(strsql," %s:%d",gettext("Количество записей"),data->kolzap);
zagolov.plus(strsql);

gtk_label_set_text(GTK_LABEL(data->label_kolstr),zagolov.ravno_toutf());

gtk_widget_show(data->label_kolstr);

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

}
static void
caja_history_sidebar_init (CajaHistorySidebar *sidebar)
{
    GtkTreeView       *tree_view;
    GtkTreeViewColumn *col;
    GtkCellRenderer   *cell;
    GtkListStore      *store;
    GtkTreeSelection  *selection;

    tree_view = GTK_TREE_VIEW (gtk_tree_view_new ());
    gtk_tree_view_set_headers_visible (tree_view, FALSE);
    gtk_widget_show (GTK_WIDGET (tree_view));

    col = GTK_TREE_VIEW_COLUMN (gtk_tree_view_column_new ());

    cell = gtk_cell_renderer_pixbuf_new ();
    gtk_tree_view_column_pack_start (col, cell, FALSE);
    gtk_tree_view_column_set_attributes (col, cell,
                                         "surface", HISTORY_SIDEBAR_COLUMN_ICON,
                                         NULL);

    cell = gtk_cell_renderer_text_new ();
    gtk_tree_view_column_pack_start (col, cell, TRUE);
    gtk_tree_view_column_set_attributes (col, cell,
                                         "text", HISTORY_SIDEBAR_COLUMN_NAME,
                                         NULL);

    gtk_tree_view_column_set_fixed_width (col, CAJA_ICON_SIZE_SMALLER);
    gtk_tree_view_append_column (tree_view, col);

    store = gtk_list_store_new (HISTORY_SIDEBAR_COLUMN_COUNT,
                                CAIRO_GOBJECT_TYPE_SURFACE,
                                G_TYPE_STRING,
                                CAJA_TYPE_BOOKMARK);

    gtk_tree_view_set_model (tree_view, GTK_TREE_MODEL (store));
    g_object_unref (store);

    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sidebar),
                                    GTK_POLICY_AUTOMATIC,
                                    GTK_POLICY_AUTOMATIC);
    gtk_scrolled_window_set_hadjustment (GTK_SCROLLED_WINDOW (sidebar), NULL);
    gtk_scrolled_window_set_vadjustment (GTK_SCROLLED_WINDOW (sidebar), NULL);
    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sidebar), GTK_SHADOW_IN);
    gtk_scrolled_window_set_overlay_scrolling (GTK_SCROLLED_WINDOW (sidebar), FALSE);

    gtk_container_add (GTK_CONTAINER (sidebar), GTK_WIDGET (tree_view));
    gtk_widget_show (GTK_WIDGET (sidebar));

    sidebar->tree_view = tree_view;

    selection = gtk_tree_view_get_selection (tree_view);
    gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);

    g_signal_connect_object
    (tree_view, "row_activated",
     G_CALLBACK (row_activated_callback), sidebar, 0);

    g_signal_connect_object (caja_signaller_get_current (),
                             "history_list_changed",
                             G_CALLBACK (history_changed_callback), sidebar, 0);

    g_signal_connect (tree_view, "button-press-event",
                      G_CALLBACK (button_press_event_callback), sidebar);

    g_signal_connect_swapped (caja_preferences,
                              "changed::" CAJA_PREFERENCES_CLICK_POLICY,
                              G_CALLBACK(click_policy_changed_callback),
                              sidebar);
    update_click_policy (sidebar);
}
/*
 * Utility function for when there are more than one albums
 * available. Borrowed from Sound Juicer.
 */
static AlbumDetails *
multiple_album_dialog (GList *albums, RBAudioCdSource *source)
{
	GtkWidget *dialog;
	GtkWidget *albums_listview;
	GtkListStore *albums_store;
	GtkTreeSelection *selection;
	AlbumDetails *album;
	GtkTreeIter iter;
	int response;
	GtkBuilder *builder;
	GtkTreeViewColumn *column;
	GtkCellRenderer *text_renderer;
	RBPlugin *plugin;
	char *builder_file;

	gdk_threads_enter ();

	g_object_get (source, "plugin", &plugin, NULL);
	g_assert (plugin != NULL);

	/* create dialog */
	builder_file = rb_plugin_find_file (plugin, "multiple-album.ui");
	g_object_unref (plugin);

	if (builder_file == NULL) {
		g_warning ("couldn't find multiple-album.ui");
		return NULL;
	}

	builder = rb_builder_load (builder_file, NULL);
	g_free (builder_file);

	dialog = GTK_WIDGET (gtk_builder_get_object (builder, "multiple_dialog"));
	g_assert (dialog != NULL);
	gtk_window_set_transient_for (GTK_WINDOW (dialog),
				      GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (source))));
	albums_listview = GTK_WIDGET (gtk_builder_get_object (builder, "albums_listview"));

	g_signal_connect (albums_listview, "row-activated", G_CALLBACK (album_row_activated), dialog);

	/* add columns */
	text_renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes (_("Title"),
							   text_renderer,
							   "text", 0,
							   NULL);

	gtk_tree_view_append_column (GTK_TREE_VIEW (albums_listview), column);

	column = gtk_tree_view_column_new_with_attributes (_("Artist"),
							   text_renderer,
							   "text", 1,
							   NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (albums_listview), column);

	/* create model for the tree view */
	albums_store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER);
	gtk_tree_view_set_model (GTK_TREE_VIEW (albums_listview), GTK_TREE_MODEL (albums_store));

	for (; albums ; albums = g_list_next (albums)) {
		GtkTreeIter iter;
		AlbumDetails *album = (AlbumDetails*)(albums->data);
		gtk_list_store_append (albums_store, &iter);
		gtk_list_store_set (albums_store, &iter,
				    0, album->title,
				    1, album->artist,
				    2, album,
				    -1);
	}

	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (albums_listview));
	gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);

	/* select the first row */
	gtk_tree_model_get_iter_first (GTK_TREE_MODEL (albums_store), &iter);
	gtk_tree_selection_select_iter (selection, &iter);

	gtk_widget_grab_focus (albums_listview);
	gtk_widget_show_all (dialog);
	response = gtk_dialog_run (GTK_DIALOG (dialog));
	gtk_widget_hide (dialog);

	if (response == GTK_RESPONSE_DELETE_EVENT) {
		album = NULL;
	} else {
		gtk_tree_selection_get_selected (selection, NULL, &iter);
		gtk_tree_model_get (GTK_TREE_MODEL (albums_store), &iter, 2, &album, -1);
	}
	gtk_widget_destroy (GTK_WIDGET (dialog));

	gdk_threads_leave ();
	g_object_unref (builder);
	return album;
}
/*
 * Create a new price tree view with (optional) top level root node.
 * This view will be based on a model that is common to all view of
 * the same set of books, but will have its own private filter on that
 * model.
 */
GtkTreeView *
gnc_tree_view_price_new (QofBook *book,
                         const gchar *first_property_name,
                         ...)
{
    GncTreeView *view;
    GtkTreeModel *model, *f_model, *s_model;
    GtkTreeViewColumn *col;
    GNCPriceDB *price_db;
    va_list var_args;
    const gchar *sample_text;
    gchar *sample_text2;

    ENTER(" ");
    /* Create/get a pointer to the existing model for this set of books. */
    price_db = gnc_pricedb_get_db(book);
    model = gnc_tree_model_price_new (book, price_db);

    /* Set up the view private filter on the common model. */
    f_model = gtk_tree_model_filter_new (model, NULL);
    g_object_unref(G_OBJECT(model));
    s_model = gtk_tree_model_sort_new_with_model (f_model);
    g_object_unref(G_OBJECT(f_model));

    /* Create our view */
    view = g_object_new (GNC_TYPE_TREE_VIEW_PRICE,
                         "name", "price_tree", NULL);
    gtk_tree_view_set_model (GTK_TREE_VIEW (view), s_model);
    g_object_unref(G_OBJECT(s_model));

    DEBUG("model ref count is %d",   G_OBJECT(model)->ref_count);
    DEBUG("f_model ref count is %d", G_OBJECT(f_model)->ref_count);
    DEBUG("s_model ref count is %d", G_OBJECT(s_model)->ref_count);

    sample_text = gnc_commodity_get_printname(gnc_default_currency());
    sample_text2 = g_strdup_printf("%s%s", sample_text, sample_text);
    col = gnc_tree_view_add_text_column (
              view, _("Security"), "security", NULL, sample_text2,
              GNC_TREE_MODEL_PRICE_COL_COMMODITY,
              GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
              sort_by_name);
    g_free(sample_text2);
    col = gnc_tree_view_add_text_column (
              view, _("Currency"), "currency", NULL, sample_text,
              GNC_TREE_MODEL_PRICE_COL_CURRENCY,
              GNC_TREE_MODEL_PRICE_COL_VISIBILITY,
              sort_by_name);
    g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
    col = gnc_tree_view_add_text_column (
              view, _("Date"), "date", NULL, "2005-05-20",
              GNC_TREE_MODEL_PRICE_COL_DATE,
              GNC_TREE_MODEL_PRICE_COL_VISIBILITY,
              sort_by_date);
    g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
    col = gnc_tree_view_add_text_column (
              view, _("Source"), "source", NULL, "Finance::Quote",
              GNC_TREE_MODEL_PRICE_COL_SOURCE,
              GNC_TREE_MODEL_PRICE_COL_VISIBILITY,
              sort_by_source);
    g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
    col = gnc_tree_view_add_text_column (
              view, _("Type"), "type", NULL, "last",
              GNC_TREE_MODEL_PRICE_COL_TYPE,
              GNC_TREE_MODEL_PRICE_COL_VISIBILITY,
              sort_by_type);
    g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
    col = gnc_tree_view_add_numeric_column (
              view, _("Price"), "price", "100.00000",
              GNC_TREE_MODEL_PRICE_COL_VALUE,
              GNC_TREE_VIEW_COLUMN_COLOR_NONE,
              GNC_TREE_MODEL_PRICE_COL_VISIBILITY,
              sort_by_value);
    g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));

    gnc_tree_view_configure_columns(view);

    /* Set properties */
    va_start (var_args, first_property_name);
    g_object_set_valist (G_OBJECT(view), first_property_name, var_args);
    va_end (var_args);

    /* Sort on the commodity column by default. This allows for a consistent
     * sort if commodities are removed and re-added from the model. */
    if (!gtk_tree_sortable_get_sort_column_id(GTK_TREE_SORTABLE(s_model),
            NULL, NULL))
    {
        gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(s_model),
                                             GNC_TREE_MODEL_PRICE_COL_COMMODITY,
                                             GTK_SORT_ASCENDING);
    }

    gtk_widget_show(GTK_WIDGET(view));
    LEAVE(" %p", view);
    return GTK_TREE_VIEW(view);
}
void _fcitx_main_window_add_addon_page(FcitxMainWindow* self)
{
    FcitxAddon* addon;
    utarray_new(self->addons, &addonicd);
    FcitxAddonsLoad(self->addons);

    GtkWidget* vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);

    GtkListStore *store;
    store = gtk_list_store_new(N_COLUMNS, G_TYPE_POINTER);

    GtkWidget* swin = gtk_scrolled_window_new(NULL, NULL);
    gtk_box_pack_start(GTK_BOX(vbox), swin, TRUE, TRUE, 0);
    g_object_set(swin, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
    self->addonview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
    g_object_set(self->addonview, "headers-visible", FALSE, NULL);
    gtk_container_add(GTK_CONTAINER(swin), self->addonview);
    GtkCellRenderer *renderer;
    GtkTreeViewColumn *column;

    renderer = gtk_cell_renderer_toggle_new();
    column = gtk_tree_view_column_new_with_attributes("Enable", renderer, NULL);
    gtk_tree_view_append_column(GTK_TREE_VIEW(self->addonview), column);
    gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(column),
                                       renderer,
                                       _fcitx_main_window_enabled_data_func,
                                       self->addonview,
                                       NULL);
    g_signal_connect(G_OBJECT(renderer), "toggled",
                     G_CALLBACK(_fcitx_main_window_toggled_cb), GTK_TREE_MODEL(store));

    renderer = gtk_cell_renderer_text_new();
    column = gtk_tree_view_column_new_with_attributes("Name", renderer, NULL);
    gtk_tree_view_append_column(GTK_TREE_VIEW(self->addonview), column);
    gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(column),
                                       renderer,
                                       _fcitx_main_window_name_data_func,
                                       self->addonview,
                                       NULL);

    gtk_tree_view_set_model(GTK_TREE_VIEW(self->addonview),
                            GTK_TREE_MODEL(store));

    g_object_unref(store);

    for (addon = (FcitxAddon *) utarray_front(self->addons);
            addon != NULL;
            addon = (FcitxAddon *) utarray_next(self->addons, addon)) {
        GtkTreeIter iter;
        store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(self->addonview)));
        gtk_list_store_append(store, &iter);
        gtk_list_store_set(store, &iter, LIST_ADDON, addon, -1);
    }

    GtkWidget* hbuttonbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
    gtk_box_pack_start(GTK_BOX(vbox), hbuttonbox, FALSE, TRUE, 0);

    self->button = gtk_button_new_with_label(_("Configure"));
    gtk_widget_set_sensitive(self->button, FALSE);
    gtk_button_set_image(GTK_BUTTON(self->button), gtk_image_new_from_stock(GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_BUTTON));
    gtk_box_pack_start(GTK_BOX(hbuttonbox), self->button, TRUE, TRUE, 0);
    g_signal_connect(G_OBJECT(self->button), "clicked", G_CALLBACK(_fcitx_main_window_configure_button_clicked), self);

    GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(self->addonview));
    gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
    g_signal_connect(G_OBJECT(selection), "changed",
                     G_CALLBACK(_fcitx_main_window_addon_selection_changed), self);

    self->addonpage = _fcitx_main_window_add_page(self, _("Addon"), vbox, GTK_STOCK_ADD);
}
Exemple #10
0
/****************************************************************
 * qif_account_picker_dialog
 *
 * Select an account from the ones that the engine knows about,
 * plus those that will be created by the QIF import.  If the
 * user clicks OK, map_entry is changed and TRUE is returned.
 * If the clicks Cancel instead, FALSE is returned. Modal.
 ****************************************************************/
gboolean
qif_account_picker_dialog(QIFImportWindow * qif_wind, SCM map_entry)
{
    QIFAccountPickerDialog * wind;
    SCM gnc_name     = scm_c_eval_string("qif-map-entry:gnc-name");
    SCM set_gnc_name = scm_c_eval_string("qif-map-entry:set-gnc-name!");
    SCM orig_acct    = scm_call_1(gnc_name, map_entry);
    int response;
    GtkBuilder *builder;
    GtkWidget *button;

    wind = g_new0(QIFAccountPickerDialog, 1);

    /* Save the map entry. */
    wind->map_entry = map_entry;
    scm_gc_protect_object(wind->map_entry);

    /* Set the initial account to be selected. */
    if (scm_is_string(orig_acct))
        wind->selected_name = gnc_scm_to_utf8_string (orig_acct);

    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "dialog-account-picker.glade", "QIF Import Account Picker");

    /* Connect all the signals */
    gtk_builder_connect_signals (builder, wind);

    wind->dialog     = GTK_WIDGET(gtk_builder_get_object (builder, "QIF Import Account Picker"));
    wind->treeview   = GTK_TREE_VIEW(gtk_builder_get_object (builder, "account_tree"));
    wind->qif_wind   = qif_wind;

    {
        GtkTreeStore *store;
        GtkCellRenderer *renderer;
        GtkTreeViewColumn *column;
        GtkTreeSelection *selection;

        store = gtk_tree_store_new(NUM_ACCOUNT_COLS, G_TYPE_STRING, G_TYPE_STRING,
                                   G_TYPE_BOOLEAN);
        gtk_tree_view_set_model(wind->treeview, GTK_TREE_MODEL(store));
        g_object_unref(store);

        renderer = gtk_cell_renderer_text_new();
        column = gtk_tree_view_column_new_with_attributes(_("Account"),
                 renderer,
                 "text",
                 ACCOUNT_COL_NAME,
                 NULL);
        g_object_set(column, "expand", TRUE, NULL);
        gtk_tree_view_append_column(wind->treeview, column);

        renderer = gtk_cell_renderer_toggle_new();
        g_object_set(renderer, "activatable", FALSE, NULL);
        column = gtk_tree_view_column_new_with_attributes(_("New?"),
                 renderer,
                 "active",
                 ACCOUNT_COL_CHECK,
                 NULL);
        gtk_tree_view_append_column(wind->treeview, column);

        selection = gtk_tree_view_get_selection(wind->treeview);
        g_signal_connect(selection, "changed",
                         G_CALLBACK(gnc_ui_qif_account_picker_changed_cb), wind);
        g_signal_connect(wind->treeview, "row-activated",
                         G_CALLBACK(gnc_ui_qif_account_picker_row_activated_cb),
                         wind);
    }

    g_signal_connect_after(wind->dialog, "map",
                           G_CALLBACK(gnc_ui_qif_account_picker_map_cb),
                           wind);

    button =  GTK_WIDGET(gtk_builder_get_object (builder, "newbutton"));
    gtk_button_set_use_stock(GTK_BUTTON(button), TRUE);

    /* this is to get the checkmarks set up right.. it will get called
     * again after the window is mapped. */
    build_acct_tree(wind, wind->qif_wind);

    do
    {
        response = gtk_dialog_run(GTK_DIALOG(wind->dialog));
    }
    while (response == GNC_RESPONSE_NEW);
    gtk_widget_destroy(wind->dialog);
    g_object_unref(G_OBJECT(builder));

    scm_gc_unprotect_object(wind->map_entry);
    g_free(wind->selected_name);
    g_free(wind);

    if (response == GTK_RESPONSE_OK)
        return TRUE;

    /* Restore the original mapping. */
    scm_call_2(set_gnc_name, map_entry, orig_acct);

    return FALSE;
}
Exemple #11
0
void
on_input_word_activate (GtkEntry *entry, gpointer user_data)
{

	char *word = NULL, *entry_word = NULL;
	
	entry_word = gtk_entry_get_text ( mydata.input_word );	
	word = g_strchomp( g_strchug( g_strdown( entry_word ) ) );

	if( strlen( word ) == 0 ){
		//g_print("on_input_word_activate():word is NULL\n");
		//avoid some latency by commenting below
//
		gtk_statusbar_pop ( mydata.statusbar, mydata.statusbar_context_id );
		gtk_statusbar_push (GTK_STATUSBAR (mydata.statusbar), mydata.statusbar_context_id, "Please enter a word");
//		remove_all_from_list();	// empty the list as there is no word to search for									
//		if we empty the list it causes a bug of not loading the list of same word although
//		hash table is still there
	}else{
		//it is cause of latency
//		g_print("on_input_word_activate():word= %s\n", word );
		if( ! isalpha( word[0] ) ){
			//g_print("on_input_word_activate(): enter proper word\n");
			// *************** show proper warning to enter proper word **********************
//
			gtk_statusbar_pop ( mydata.statusbar, mydata.statusbar_context_id );
			gtk_statusbar_push (GTK_STATUSBAR (mydata.statusbar), mydata.statusbar_context_id, "Please enter proper english word");
//
			return;
		}								
		//check if hash table is created for word[0] of not
		g_sprintf( file_loaded_name, APP_DBS"%c.db", g_ascii_tolower( word[0] ) );
//		g_print("on_input_word_activate(): filename = %s\n",file_loaded_name);
		
		if( mydata.hash_tab[ g_ascii_toupper(word[0]) - 'A' ] == NULL ){
			//remove the prev word entries
			//remove_all_from_list ();
//			g_print("on_input_word_activate(): generating hash table\n");
			mydata.hash_tab[ g_ascii_toupper(word[0]) - 'A' ] = generate_hash_table( file_loaded_name );
			mydata.list_store_arr[ g_ascii_toupper(word[0]) - 'A' ] = mydata.list_store;
			list_loaded = g_ascii_toupper(word[0]) - 'A';
			//check if hash table is created or not by generate_hash_table() func call				 
			if( mydata.hash_tab[ g_ascii_toupper(word[0]) - 'A' ] == NULL ){
				g_print("on_input_word_activate():\nafter trying to generate_hash_table\nfile: %s could not be located and loaded\n", file_loaded_name );
			}						 
		}else{
			//g_print("on_input_word_activate(): %d", list_loaded );
			if( list_loaded != (g_ascii_toupper(word[0]) - 'A') ){				
				//
				if( mydata.list_store_arr[ g_ascii_toupper(word[0]) - 'A' ] == NULL ){
					populate_list_only( file_loaded_name );
					//g_print("on_input_word_changed(): list populated from file\n" );
				}else{					
					mydata.list_store = mydata.list_store_arr[ g_ascii_toupper(word[0]) - 'A' ];
//					following may be necessary		  
					gtk_tree_view_set_model ( mydata.treeview, GTK_TREE_MODEL(mydata.list_store) );
					//g_print("on_input_word_changed(): list used from previous list\n" );
				}
				
				list_loaded = (g_ascii_toupper(word[0]) - 'A');
				//
			}
		}	
			
	}
	
	on_find_clicked();
	
}
static void
sdb_view_locals_init (SymbolDBViewLocals *dbvl)
{	
	GtkTreeViewColumn *column;
	GtkCellRenderer *renderer;
	GtkTreeSelection *selection;
	GtkTreeStore *store;
	SymbolDBViewLocalsPriv *priv;
	
	g_return_if_fail (dbvl != NULL);

	/*DEBUG_PRINT ("%s", "sdb_view_locals_init  ()");*/
	dbvl->priv = g_new0 (SymbolDBViewLocalsPriv, 1);		
	priv = dbvl->priv;
		
	priv->current_db_file = NULL;
	priv->current_local_file_path = NULL;
	priv->nodes_displayed = NULL;
	priv->waiting_for = NULL;
	priv->nodes_not_yet_removed = g_tree_new_full ((GCompareDataFunc)&symbol_db_gtree_compare_func, 
	    											NULL,
	    											NULL,
	    											NULL);
	priv->symbols_inserted_ids = NULL;
	priv->insert_handler = 0;
	priv->scan_end_handler = 0;
	priv->remove_handler = 0;
	priv->scope_update_handler = 0;
	priv->insertion_idle_handler = 0;
	priv->files_view_status = g_hash_table_new_full (g_str_hash, 
								g_str_equal, g_free, (GDestroyNotify)file_view_status_destroy);
	priv->recv_signals = FALSE;
	priv->display_nothing = FALSE;

	/* initially set it to NULL */
	store = NULL;

	gtk_tree_view_set_model (GTK_TREE_VIEW (dbvl), GTK_TREE_MODEL (store));	
	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (dbvl), FALSE);
	
	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dbvl));
	gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);

	/* search through the tree interactively */
	gtk_tree_view_set_enable_search (GTK_TREE_VIEW (dbvl), TRUE);
	gtk_tree_view_set_search_column (GTK_TREE_VIEW (dbvl), COLUMN_NAME);
	gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (dbvl),
	    sdb_view_locals_search_equal_func, NULL, NULL);
	
	/* Columns */
	column = gtk_tree_view_column_new ();
	gtk_tree_view_column_set_sizing (column,
					 GTK_TREE_VIEW_COLUMN_AUTOSIZE);
	gtk_tree_view_column_set_title (column, _("Symbol"));

	renderer = gtk_cell_renderer_pixbuf_new ();
	gtk_tree_view_column_pack_start (column, renderer, FALSE);
	gtk_tree_view_column_add_attribute (column, renderer, "pixbuf",
					    COLUMN_PIXBUF);

	renderer = gtk_cell_renderer_text_new ();
	gtk_tree_view_column_pack_start (column, renderer, TRUE);
	gtk_tree_view_column_add_attribute (column, renderer, "text",
					    COLUMN_NAME);

	gtk_tree_view_append_column (GTK_TREE_VIEW (dbvl), column);
	gtk_tree_view_set_expander_column (GTK_TREE_VIEW (dbvl), column);	
	
	/* gtk 2.12 
	 * gtk_tree_view_set_show_expanders (GTK_TREE_VIEW (dbvl), FALSE); */
}
void 
symbol_db_view_locals_clear_cache (SymbolDBViewLocals *dbvl)
{
	SymbolDBViewLocalsPriv *priv;	
	GtkTreeStore *store;
	gpointer hash_node = NULL;
	
	g_return_if_fail (dbvl != NULL);
	
	priv = dbvl->priv;
		
	if (priv->insertion_idle_handler > 0)
	{				
		g_source_remove (priv->insertion_idle_handler);
		priv->insertion_idle_handler = 0;
	}
	
	/*DEBUG_PRINT ("%s", "symbol_db_view_locals_clear_cache ()");*/
	/* check whether we already have the view status saved on hash table or not.
	 * If we saved that then don't remove it, or there may be a memory leak
	 */	
	if (priv->current_db_file != NULL)
	{
		/*DEBUG_PRINT ("priv->current_db_file %s ", priv->current_db_file);*/
		hash_node = g_hash_table_lookup (priv->files_view_status, 
										 priv->current_db_file);
	}
	
	if (hash_node == NULL)
	{
		if (priv->nodes_displayed)
		{
			g_tree_destroy (priv->nodes_displayed);
			priv->nodes_displayed = NULL;
		}
	
		/* free the waiting_for structs before destroying the tree itself */
		if (priv->waiting_for)
		{
			g_tree_foreach (priv->waiting_for, traverse_free_waiting_for, NULL);
			g_tree_destroy (priv->waiting_for);
			priv->waiting_for = NULL;
		}

		if (priv->nodes_not_yet_removed)
		{
			g_tree_destroy (priv->nodes_not_yet_removed);
			priv->nodes_not_yet_removed = NULL;
		}
			
		store = GTK_TREE_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (dbvl)));
		if (store != NULL)
			g_object_unref (store);
	}
	
	gtk_tree_view_set_model (GTK_TREE_VIEW (dbvl), NULL);
	
	g_free (priv->current_db_file);
	priv->current_db_file = NULL;
	
	g_free (priv->current_local_file_path);
	priv->current_local_file_path = NULL;
	
	if (priv->files_view_status)
	{
		g_hash_table_foreach_remove (priv->files_view_status, 
									 traverse_files_view_status, NULL);
	}
	
	priv->waiting_for = NULL;
	priv->nodes_displayed = NULL;
}
void
symbol_db_view_locals_update_list (SymbolDBViewLocals *dbvl, SymbolDBEngine *dbe,
							  const gchar* filepath, gboolean force_update)
{
	SymbolDBViewLocalsPriv *priv;
	SymbolDBEngineIterator *iterator;
	GtkTreeStore *store;	
	FileSymbolsStatus *fsstatus;
	
	g_return_if_fail (dbvl != NULL);
	g_return_if_fail (filepath != NULL);
	g_return_if_fail (dbe != NULL);

	priv = dbvl->priv;

	DEBUG_PRINT ("filepath %s", filepath);
	
	/* we're not interested in giving user an updated gtktreestore if recv signals
	 * is false. In that case we can have a project importing...
	 * We should pass on this test if the force option is activated (i.e. is TRUE)
	 */
	if (priv->recv_signals == FALSE && force_update == FALSE)
	{		
		gtk_tree_view_set_model (GTK_TREE_VIEW (dbvl), NULL);
		DEBUG_PRINT ("recv signals is false");
		return;
	}
	
	/* it's a good thing to enable the gtktreewidget */
	gtk_widget_set_sensitive (GTK_WIDGET (dbvl), TRUE);
	
	/* ok, we can have a case where we're revisiting an old file with an already 
	 * populated GtkTreeStore. We're gonna set that gtktreestore along with the
	 * GTree(s) for nodes_displayed and waiting_for.
	 */
	fsstatus = NULL;
	
	if (priv->current_db_file != NULL)
	{
		FileSymbolsStatus *hash_node;
		/* save current symbols status - e.g. gtktreestore, symbols_displayed etc.,
		 * if it hasn't already been done.
		 */
		hash_node = g_hash_table_lookup (priv->files_view_status, 
										 priv->current_db_file);
		
		/* did we find something? yes? well, then we should save nothing... */
		if (hash_node == NULL)
		{
			/* found nothing? ok, save the status */
			GtkTreeStore * store;
		
			/* remove the GSourceFunc, if it's running */
			if (priv->insertion_idle_handler > 0)
			{				
				g_source_remove (priv->insertion_idle_handler);
				priv->insertion_idle_handler = 0;
			}
			
			store = GTK_TREE_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (dbvl)));	
			
			if (store != NULL && priv->nodes_displayed != NULL 
				&& priv->waiting_for != NULL)
			{
				FileSymbolsStatus *fss;
				fss = g_new0 (FileSymbolsStatus, 1);
				fss->store = store;
				fss->nodes_displayed = priv->nodes_displayed;
				fss->waiting_for = priv->waiting_for;
				fss->symbols_inserted_ids = priv->symbols_inserted_ids;
				
				/*DEBUG_PRINT ("%s", "symbol_db_view_locals_update_list (): "
					"g_hash_table_insert ");*/
				/* insert it */
				g_hash_table_insert (priv->files_view_status, 
									 g_strdup (priv->current_db_file), fss);
			}			
		}
	}
	

	/* adjust some vars */
	g_free (priv->current_db_file);
	priv->current_db_file = NULL;
	
	g_free (priv->current_local_file_path);
	priv->current_local_file_path = NULL;

	priv->current_db_file = 
		symbol_db_util_get_file_db_path (dbe, filepath);
	if (priv->current_db_file == NULL) 
	{
		/* the file simply isn't in the db. Don't display nothing. */
		return;
	}
	priv->current_local_file_path = g_strdup (filepath);
	
	/* try to see if we had something saved before in the hash table */
	fsstatus = g_hash_table_lookup (priv->files_view_status,
									priv->current_db_file);	

	if (fsstatus != NULL)
	{
		/* restore the previous saved status ... */
		
		/* set the nodes_displayed */
		priv->nodes_displayed = fsstatus->nodes_displayed;
		
		/* ... the waiting_for ... */
		priv->waiting_for = fsstatus->waiting_for;
	
		/* ... the pending symbols_id to be inserted ... */
		priv->symbols_inserted_ids = fsstatus->symbols_inserted_ids;

		/* and last but not the least the store */
		store = fsstatus->store;		

		/* with this set there's no need to re-retrieve the symbols from db,
		 * speeding up the things.
		 */
		/*DEBUG_PRINT ("%s", "symbol_db_view_locals_update_list (): "
					 "setting gtk_tree_view_set_model to the saved one");*/
		gtk_tree_view_set_model (GTK_TREE_VIEW (dbvl), GTK_TREE_MODEL (store));
		
		
		/* check if we left some ids on the queue. In case restart the idle_function */
		if (g_queue_get_length (priv->symbols_inserted_ids) > 0)
		{
			TraverseData *tdata;
			
			tdata = g_new0 (TraverseData, 1);
			tdata->dbvl = dbvl;
			tdata->data = dbe;
			
			priv->insertion_idle_handler = g_idle_add_full (G_PRIORITY_LOW, 
						 (GSourceFunc) consume_symbols_inserted_queue_idle,
						 (gpointer) tdata,
						 (GDestroyNotify) consume_symbols_inserted_queue_idle_destroy);			
		}

		/* fine, but some symbol-remove signals can have been left. Check if they
		 * can be removed 
		 */
		GList *removed_list;
		TraverseData *tdata;

		tdata = g_new0 (TraverseData, 1);
		tdata->dbvl = dbvl;

		g_tree_foreach (priv->nodes_not_yet_removed, 
		    traverse_check_for_unremoved_symbols, tdata);

		/* the result */
		removed_list = tdata->data;
		
		/* have we removed something? We'll know that checking the list */
		if (removed_list != NULL)
		{
			GList *node = removed_list;
			while (node != NULL)
			{
				g_tree_remove (priv->nodes_not_yet_removed, node->data);

				node = node->next;
			}			
		}
		
		g_list_free (removed_list);
		g_free (tdata);	
	}
	else 
	{	
		priv->nodes_displayed = g_tree_new_full ((GCompareDataFunc)&symbol_db_gtree_compare_func, 
										 NULL,
										 NULL,
										 (GDestroyNotify)&gtk_tree_row_reference_free);		

		priv->waiting_for = g_tree_new_full ((GCompareDataFunc)&symbol_db_gtree_compare_func, 
										 NULL,
										 NULL,
										 NULL);
		
		priv->symbols_inserted_ids = g_queue_new ();

		/*DEBUG_PRINT ("%s", "symbol_db_view_locals_update_list (): creating new store"); */
		store = sdb_view_locals_create_new_store ();
		gtk_tree_view_set_model (GTK_TREE_VIEW (dbvl), GTK_TREE_MODEL (store));
		
		/* Removes all rows from tree_store */
		gtk_tree_store_clear (store);

		iterator = symbol_db_engine_get_file_symbols (dbe, filepath, 
													  	SYMINFO_SIMPLE |
												  		SYMINFO_ACCESS |
														SYMINFO_KIND);		
		
		if (iterator != NULL)
		{
			do {
				gint curr_symbol_id;
				SymbolDBEngineIteratorNode *iter_node;

				iter_node = SYMBOL_DB_ENGINE_ITERATOR_NODE (iterator);
			
				curr_symbol_id = symbol_db_engine_iterator_node_get_symbol_id (iter_node);

				/* we can just call the symbol inserted function. It'll take care of
			 	* building the tree and populating it
			 	*/
				on_symbol_inserted (dbe, curr_symbol_id, (gpointer)dbvl);
			} while (symbol_db_engine_iterator_move_next (iterator) == TRUE);
		
			g_object_unref (iterator);
		}

		/* ok, there may be some symbols left on the waiting_for_list...
 	 	 * launch the callback function by hand, flushing the list it in case 
		 * The 0 stays for an unused process_id
		 */		
		on_scan_end (dbe, 0, dbvl);		
	}
	
	/* only gtk 2.12 ...
	 * gtk_tree_view_set_show_expanders (GTK_TREE_VIEW (dbvl)); */
	
	gtk_tree_view_expand_all (GTK_TREE_VIEW (dbvl));	
}
Exemple #15
0
void trace_view_cpu_filter_callback(gboolean accept,
				    gboolean all_cpus,
				    guint64 *selected_cpu_mask,
				    gpointer data)
{
	GtkTreeView *trace_tree = data;
	TraceViewRecord *rec;
	GtkTreeModel *model;
	TraceViewStore *store;
	guint64 time = 0;
	gint selected_row;
	gint cpus;
	gint cpu;

	if (!accept)
		return;

	model = gtk_tree_view_get_model(trace_tree);
	if (!model)
		return;

	store = TRACE_VIEW_STORE(model);

	selected_row = trace_view_get_selected_row(GTK_WIDGET(trace_tree));
	if (selected_row < 0)
		selected_row = 0;

	g_object_ref(store);
	gtk_tree_view_set_model(trace_tree, NULL);

	/*
	 * If the selected row is not part of one of the CPUs
	 * that are kept, then find one that is. Do nothing if
	 * the first row is selected.
	 */
	if (selected_row) {
		/* Save this timestamp */
		rec = trace_view_store_get_visible_row(TRACE_VIEW_STORE(model), selected_row);
		time = rec->timestamp;
	}

	if (all_cpus) {
		trace_view_store_set_all_cpus(store);
		goto set_model;
	}

	cpus = trace_view_store_get_cpus(store);

	for (cpu = 0; cpu < cpus; cpu++) {
		if (cpu_isset(selected_cpu_mask, cpu))
			trace_view_store_set_cpu(store, cpu);
		else
			trace_view_store_clear_cpu(store, cpu);
	}

 set_model:
	gtk_tree_view_set_model(trace_tree, GTK_TREE_MODEL(store));
	g_object_unref(store);

	if (!time)
		return;
	/*
	 * Try to select the row that was near the selection
	 * before the change.
	 */
	trace_view_select(GTK_WIDGET(trace_tree), time);
}
Exemple #16
0
/* for all kinds of lists in osm2go */
GtkWidget *list_new(bool show_headers, unsigned int btn_flags, void *context,
                    void(*cb_changed)(GtkTreeSelection*,void*),
                    const std::vector<list_button> &buttons,
                    const std::vector<list_view_column> &columns,
                    GtkTreeModel *store)
{
  assert(cb_changed != nullptr);

  guint rows = 1;
  guint cols = 3;
  /* make space for user buttons */
  if(btn_flags & LIST_BTN_2ROW)
    rows = 2;
  else
    cols = buttons.size();

  GtkWidget *vbox = gtk_vbox_new(FALSE,3);
  list_priv_t *priv = new list_priv_t(cb_changed, context, gtk_table_new(rows, cols, TRUE), btn_flags);

  g_object_set_data(G_OBJECT(vbox), "priv", priv);
  g_signal_connect_swapped(vbox, "destroy", G_CALLBACK(del_priv), priv);

  /* hildon hides these by default */
  gtk_tree_view_set_headers_visible(priv->view, show_headers ? TRUE : FALSE);

  GtkTreeSelection *sel = gtk_tree_view_get_selection(priv->view);

  gtk_box_pack_start(GTK_BOX(vbox), osm2go_platform::scrollable_container(GTK_WIDGET(priv->view)),
                     TRUE, TRUE, 0);

  /* make list react on clicks */
  g_signal_connect_after(priv->view, "row-activated", G_CALLBACK(on_row_activated), vbox);

  /* add button box */
  gtk_box_pack_start(GTK_BOX(vbox), priv->table, FALSE, FALSE, 0);

  assert_cmpnum_op(buttons.size(), >=, cols);
  assert_cmpnum_op(buttons.size(), <=, cols * rows);

  /* add the three default buttons, but keep all but the first disabled for now */
  for(unsigned int i = 0; i < 3; i++) {
    if(strchr(buttons[i].first, '_') != nullptr)
      priv->button.widget[i] = gtk_button_new_with_mnemonic(buttons[i].first);
    else
      priv->button.widget[i] = osm2go_platform::button_new_with_label(buttons[i].first);
    gtk_table_attach_defaults(GTK_TABLE(priv->table),
                              priv->button.widget[i], i, i + 1, 0, 1);
    g_signal_connect_swapped(priv->button.widget[i], "clicked",
                             buttons[i].second, priv->callback_context);
    gtk_widget_set_sensitive(priv->button.widget[i], i == 0 ? TRUE : FALSE);
  }

  list_set_columns(priv->view, columns);

  if(buttons.size() > 3)
    list_set_user_buttons(priv, buttons);

  gtk_tree_view_set_model(priv->view, store);

  // set this up last so it will not be called with an incompletely set up
  // context pointer
  g_signal_connect(sel, "changed", G_CALLBACK(changed), vbox);

  return vbox;
}
Exemple #17
0
void history_search_init(void)
{
    history_filter = history_create_filter(GTK_TREE_MODEL(history_tab->store));
    gtk_tree_view_set_model(GTK_TREE_VIEW(history_tab->view), GTK_TREE_MODEL(history_filter));
}
void keyboard_dialog_show(Key *key)
{
	GtkWidget *dialog;
	GtkTreeView *view;
	GtkCellRenderer *renderer;
	GtkTreeViewColumn *column;
	GtkTreeSelection *sel;
	GtkTreePath *path;
	GtkTreeIter iter;
	GObject *obj;

	dialog = create_dialog_keyboard_settings();
	obj = G_OBJECT(dialog);

	g_signal_connect(obj, "destroy",
			 G_CALLBACK(event_destroy), NULL);
	g_signal_connect(obj, "response",
			 G_CALLBACK(event_response), key);

	/* key */
	g_signal_connect(obj, "key_press_event",
			 G_CALLBACK(event_key_pressed),
			 g_object_get_data(obj, "key_button"));

	/* action store */
	if (action_store == NULL)
		action_store = action_store_create();
	else
		g_object_ref(action_store);

	/* action view */
	view = g_object_get_data(obj, "action_tree");
	gtk_tree_view_set_model(view, GTK_TREE_MODEL(action_store));
	gtk_tree_selection_set_mode(gtk_tree_view_get_selection(view),
				    GTK_SELECTION_SINGLE);


	/* -- */
	renderer = gtk_cell_renderer_text_new();
	column = gtk_tree_view_column_new_with_attributes("ID", renderer,
							  "text", COL_ID,
							  NULL);
	gtk_tree_view_column_set_cell_data_func(column, renderer,
						id_set_func, NULL, NULL);
	gtk_tree_view_append_column(view, column);

	/* -- */
	renderer = gtk_cell_renderer_text_new();
	column = gtk_tree_view_column_new_with_attributes("Description", renderer,
							  "text", COL_DESCRIPTION,
							  NULL);
	gtk_tree_view_column_set_cell_data_func(column, renderer,
						description_set_func, NULL,
						NULL);
	gtk_tree_view_append_column(view, column);

	gtk_widget_show(dialog);

	if (key == NULL)
		return;

	/* set old values */
	gui_entry_set_from(obj, "key", key->key);
	gui_entry_set_from(obj, "data", key->data);

	/* select the action */
	if (gui_tree_model_find(GTK_TREE_MODEL(action_store),
				COL_PTR, &iter, key->info)) {
		sel = gtk_tree_view_get_selection(view);
		gtk_tree_selection_select_iter(sel, &iter);

		/* scroll it visible */
		path = gtk_tree_model_get_path(GTK_TREE_MODEL(action_store),
					       &iter);
		gtk_tree_view_scroll_to_cell(view, path, column, TRUE, 0, 0);
	}
}
Exemple #19
0
inline static void show_autorun_dlg(GVolume* vol, GMount* mount)
{
    GtkBuilder* builder;
    GtkTreeIter it;
    GtkTreeViewColumn* col;
    GtkTreeSelection* tree_sel;
    GtkCellRenderer*render;
    GtkImage* icon;
    GIcon* gicon;
    AutoRun* data;

    data = g_slice_new(AutoRun);
    data->cancel = g_cancellable_new();

    builder = gtk_builder_new();
    gtk_builder_add_from_file(builder, PACKAGE_UI_DIR "/autorun.glade", NULL);
    data->dlg = GTK_DIALOG(gtk_builder_get_object(builder, "dlg"));
    data->view = GTK_TREE_VIEW(gtk_builder_get_object(builder, "listview"));
    data->type = GTK_LABEL(gtk_builder_get_object(builder, "type"));
    icon = GTK_IMAGE(gtk_builder_get_object(builder, "icon"));
    g_object_unref(builder);

    gicon = g_volume_get_icon(vol);
    gtk_image_set_from_gicon(icon, gicon, GTK_ICON_SIZE_DIALOG);
    g_object_unref(gicon);

    gtk_dialog_set_default_response(data->dlg, GTK_RESPONSE_OK);
    gtk_dialog_set_alternative_button_order(data->dlg, GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1);

    tree_sel = gtk_tree_view_get_selection(data->view);
    gtk_tree_selection_set_mode(tree_sel, GTK_SELECTION_BROWSE);

    col = gtk_tree_view_column_new();
    render = gtk_cell_renderer_pixbuf_new();
    gtk_tree_view_column_pack_start(col, render, FALSE);
    gtk_tree_view_column_set_attributes(col, render, "gicon", 0, NULL);

    render = gtk_cell_renderer_text_new();
    gtk_tree_view_column_pack_start(col, render, FALSE);
    gtk_tree_view_column_set_attributes(col, render, "text", 1, NULL);

    gtk_tree_view_append_column(data->view, col);

    data->store = gtk_list_store_new(3, G_TYPE_ICON, G_TYPE_STRING, G_TYPE_OBJECT);
    data->mount = (GMount*)g_object_ref(mount);

    gtk_list_store_append(data->store, &it);
    gicon = g_themed_icon_new("system-file-manager");
    gtk_list_store_set(data->store, &it, 0, gicon, 1, _("Open in File Manager"), -1);
    g_object_unref(gicon);

    gtk_tree_view_set_model(data->view, GTK_TREE_MODEL(data->store));

    gtk_tree_model_get_iter_first(GTK_TREE_MODEL(data->store), &it);
    gtk_tree_selection_select_iter(tree_sel, &it);

    g_signal_connect(data->view, "row-activated", G_CALLBACK(on_row_activated), data);
    g_signal_connect(data->dlg, "response", G_CALLBACK(on_dlg_response), data);

    g_signal_connect(data->mount, "unmounted", G_CALLBACK(on_unmount), data);

    gtk_window_set_keep_above(GTK_WINDOW(data->dlg), TRUE);
    gtk_window_present(GTK_WINDOW(data->dlg));

    g_mount_guess_content_type(mount, TRUE, data->cancel, on_content_type_finished, data);

    pcmanfm_ref();
}
Exemple #20
0
void kasdok_create_list (class kasdok_data *data)
{
    GtkListStore *model=NULL;
    GtkTreeIter iter;
    SQLCURSOR cur;
    SQLCURSOR cur1;
    char strsql[512];
    int  kolstr=0;
    SQL_str row,row1;
    iceb_u_str zagolov;

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

    gdk_window_set_cursor(data->window->window,gdk_cursor_new(ICEB_CURSOR_GDITE));
    iceb_refresh();

    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(kasdok_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(kasdok_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_INT);

    sprintf(strsql,"select datp,kontr,suma,ktoi,vrem,koment from Kasord1 where datd='%s' and \
kassa=%d and nomd='%s' and tp=%d order by kontr asc",
            data->datad.ravno_sqldata(),data->kassa.ravno_atoi(),data->nomdok.ravno(),data->tipz);
//printf("strsql=%s\n",strsql);
    if((kolstr=cur.make_cursor(&bd,strsql)) < 0)
    {
        iceb_msql_error(&bd,gettext("Ошибка создания курсора !"),strsql,data->window);
        return;
    }
//gtk_list_store_clear(model);

    iceb_u_str ss[NUM_COLUMNS];

    data->kolzap=0;
    data->suma=0.;
    short d,m,g;
    while(cur.read_cursor(&row) != 0)
    {
//  printf("%s %s %s %s\n",row[0],row[1],row[2],row[3]);


        if(iceb_u_SRAV(data->kontr_zap.ravno(),row[1],0) == 0)
            data->snanomer=data->kolzap;


        //Дата подтверждения записи
        ss[COL_DATA_POD].new_plus("");
        if(row[0][0] != '0')
        {
            iceb_u_rsdat(&d,&m,&g,row[0],2);
            sprintf(strsql,"%02d.%02d.%d",d,m,g);
            ss[COL_DATA_POD].new_plus(strsql);

        }

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

        //Сумма
        ss[COL_SUMA].new_plus(row[2]);
        data->suma+=atof(row[2]);

        //Узнаём наименование контрагента
        ss[COL_NAIM].new_plus("");

        sprintf(strsql,"select naikon from Kontragent where kodkon='%s'",row[1]);
        if(sql_readkey(&bd,strsql,&row1,&cur1) == 1)
            ss[COL_NAIM].new_plus(iceb_u_toutf(row1[0]));

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

        //Кто записал
        ss[COL_KTO].new_plus(iceb_kszap(row[3],0,data->window));
        /*Коментарий*/
        ss[COL_KOMENT].new_plus(iceb_u_toutf(row[5]));

        gtk_list_store_append (model, &iter);

        gtk_list_store_set (model, &iter,
                            COL_KONTR,ss[COL_KONTR].ravno(),
                            COL_NAIM,ss[COL_NAIM].ravno(),
                            COL_SUMA,ss[COL_SUMA].ravno(),
                            COL_DATA_POD,ss[COL_DATA_POD].ravno(),
                            COL_KOMENT,ss[COL_KOMENT].ravno(),
                            COL_DATA_VREM,ss[COL_DATA_VREM].ravno(),
                            COL_KTO,ss[COL_KTO].ravno(),
                            NUM_COLUMNS,data->kolzap,
                            -1);

        data->kolzap++;
    }
    data->kontr_zap.new_plus("");

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

    g_object_unref (GTK_TREE_MODEL (model));

    kasdok_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[FK4]),FALSE);//Недоступна
        gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[FK5]),FALSE);//Недоступна
//  gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[FK6]),FALSE);//Недоступна
        gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[FK7]),FALSE);//Недоступна
        gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[SFK7]),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[FK4]),TRUE);//Доступна
        gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[FK5]),TRUE);//Доступна
//  gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[FK6]),TRUE);//Доступна
        gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[FK7]),TRUE);//Доступна
        gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[SFK7]),TRUE);//Доступна
    }
    gtk_widget_show (data->treeview);
    gtk_widget_show (data->sw);

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

//формируем заголовок с реквизитами документа
    l_kasdok_str_rek(data,&zagolov);




    gdk_window_set_cursor(data->window->window,gdk_cursor_new(ICEB_CURSOR));
}
static GtkWidget *
gnc_stock_split_assistant_create (StockSplitInfo *info)
{
    GtkBuilder *builder;
    GtkWidget *window;

    builder = gtk_builder_new();
    gnc_builder_add_from_file  (builder , "assistant-stock-split.glade", "Stock Split Assistant");
    window = GTK_WIDGET(gtk_builder_get_object (builder, "Stock Split Assistant"));
    info->window = window;

    /* Set the assistant colors */
    gnc_assistant_set_colors (GTK_ASSISTANT (info->window));

    /* Enable buttons on first, second, fourth and last page. */
    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
                                     GTK_WIDGET(gtk_builder_get_object(builder, "intro_page_label")),
                                     TRUE);
    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
                                     GTK_WIDGET(gtk_builder_get_object(builder, "stock_account_page")),
                                     TRUE);
    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
                                     GTK_WIDGET(gtk_builder_get_object(builder, "stock_cash_page")),
                                     TRUE);
    gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
                                     GTK_WIDGET(gtk_builder_get_object(builder, "finish_page_label")),
                                     TRUE);

    /* Account page Widgets */
    {
        GtkTreeView *view;
        GtkListStore *store;
        GtkTreeSelection *selection;
        GtkCellRenderer *renderer;
        GtkTreeViewColumn *column;

        info->account_view = GTK_WIDGET(gtk_builder_get_object(builder, "account_view"));

        view = GTK_TREE_VIEW(info->account_view);

        store = gtk_list_store_new(NUM_SPLIT_COLS, G_TYPE_POINTER, G_TYPE_STRING,
                                   G_TYPE_STRING, G_TYPE_STRING);
        gtk_tree_view_set_model(view, GTK_TREE_MODEL(store));
        g_object_unref(store);

        renderer = gtk_cell_renderer_text_new();
        column = gtk_tree_view_column_new_with_attributes(_("Account"), renderer,
                 "text", SPLIT_COL_FULLNAME,
                 NULL);
        gtk_tree_view_append_column(view, column);

        renderer = gtk_cell_renderer_text_new();
        column = gtk_tree_view_column_new_with_attributes(_("Symbol"), renderer,
                 "text", SPLIT_COL_MNEMONIC,
                 NULL);
        gtk_tree_view_append_column(view, column);

        renderer = gtk_cell_renderer_text_new();
        column = gtk_tree_view_column_new_with_attributes(_("Shares"), renderer,
                 "text", SPLIT_COL_SHARES,
                 NULL);
        gtk_tree_view_append_column(view, column);

        selection = gtk_tree_view_get_selection(view);
        gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE);
        g_signal_connect (selection, "changed",
                          G_CALLBACK (selection_changed_cb), info);

    }

    /* Details Page Widgets */
    {
        GtkWidget *box;
        GtkWidget *amount;
        GtkWidget *date;
        GtkWidget *label;

        info->description_entry = GTK_WIDGET(gtk_builder_get_object(builder, "description_entry"));

        box = GTK_WIDGET(gtk_builder_get_object(builder, "date_box"));
        date = gnc_date_edit_new (gnc_time (NULL), FALSE, FALSE);
        gtk_box_pack_start (GTK_BOX (box), date, TRUE, TRUE, 0);
        info->date_edit = date;
        label = GTK_WIDGET(gtk_builder_get_object(builder, "date_label"));
        gnc_date_make_mnemonic_target (GNC_DATE_EDIT(date), label);

        box = GTK_WIDGET(gtk_builder_get_object(builder, "distribution_box"));
        amount = gnc_amount_edit_new ();
        g_signal_connect (amount, "changed",
                          G_CALLBACK (gnc_stock_split_details_valid_cb), info);
        gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (amount), TRUE);
        gtk_box_pack_start (GTK_BOX (box), amount, TRUE, TRUE, 0);
        info->distribution_edit = amount;

        label = GTK_WIDGET(gtk_builder_get_object(builder, "distribution_label"));
        gtk_label_set_mnemonic_widget(GTK_LABEL(label), amount);

        box = GTK_WIDGET(gtk_builder_get_object(builder, "price_box"));
        amount = gnc_amount_edit_new ();
        gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (amount),
                                        gnc_default_price_print_info ());
        g_signal_connect (amount, "changed",
                          G_CALLBACK (gnc_stock_split_details_valid_cb), info);
        gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (amount), TRUE);
        gtk_box_pack_start (GTK_BOX (box), amount, TRUE, TRUE, 0);
        info->price_edit = amount;

        label = GTK_WIDGET(gtk_builder_get_object(builder, "price_label"));
        gtk_label_set_mnemonic_widget(GTK_LABEL(label), amount);

        info->price_currency_edit = gnc_currency_edit_new();
        gnc_currency_edit_set_currency (GNC_CURRENCY_EDIT(info->price_currency_edit), gnc_default_currency());
        gtk_widget_show (info->price_currency_edit);

        box = GTK_WIDGET(gtk_builder_get_object (builder, "price_currency_box"));
        gtk_box_pack_start(GTK_BOX(box), info->price_currency_edit, TRUE, TRUE, 0);
    }

    /* Cash page Widgets */
    {
        GtkWidget *box;
        GtkWidget *tree;
        GtkWidget *amount;
        GtkWidget *label;
        GtkWidget *scroll;
        GtkTreeSelection *selection;

        box = GTK_WIDGET(gtk_builder_get_object(builder, "cash_box"));
        amount = gnc_amount_edit_new ();
        g_signal_connect (amount, "changed",
                          G_CALLBACK (gnc_stock_split_cash_valid_cb), info);
        gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (amount), TRUE);
        gtk_box_pack_start (GTK_BOX (box), amount, TRUE, TRUE, 0);
        info->cash_edit = amount;

        label = GTK_WIDGET(gtk_builder_get_object(builder, "cash_label"));
        gtk_label_set_mnemonic_widget(GTK_LABEL(label), amount);

        info->memo_entry = GTK_WIDGET(gtk_builder_get_object(builder, "memo_entry"));

        /* income tree */
        tree = GTK_WIDGET(gnc_tree_view_account_new (FALSE));
        info->income_tree = tree;
        gnc_tree_view_account_set_filter (GNC_TREE_VIEW_ACCOUNT (tree),
                                          gnc_stock_split_assistant_view_filter_income,
                                          NULL, /* user data */
                                          NULL  /* destroy callback */);

        gtk_widget_show (tree);

        gtk_tree_view_expand_all (GTK_TREE_VIEW(tree));
        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(tree));
        gtk_tree_selection_unselect_all (selection);
        g_signal_connect (selection, "changed",
                          G_CALLBACK (gnc_stock_split_cash_valid_cb), info);

        label = GTK_WIDGET(gtk_builder_get_object(builder, "income_label"));
        gtk_label_set_mnemonic_widget (GTK_LABEL(label), tree);

        scroll = GTK_WIDGET(gtk_builder_get_object(builder, "income_scroll"));
        gtk_container_add (GTK_CONTAINER (scroll), tree);

        /* asset tree */
        tree = GTK_WIDGET(gnc_tree_view_account_new (FALSE));
        info->asset_tree = tree;
        gnc_tree_view_account_set_filter (GNC_TREE_VIEW_ACCOUNT (tree),
                                          gnc_stock_split_assistant_view_filter_asset,
                                          NULL /* user data */,
                                          NULL /* destroy callback */);

        gtk_widget_show (tree);

        label = GTK_WIDGET(gtk_builder_get_object(builder, "asset_label"));
        gtk_label_set_mnemonic_widget (GTK_LABEL(label), tree);

        scroll = GTK_WIDGET(gtk_builder_get_object(builder, "asset_scroll"));
        gtk_container_add (GTK_CONTAINER (scroll), tree);

        gtk_tree_view_expand_all (GTK_TREE_VIEW(tree));
        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(tree));
        gtk_tree_selection_unselect_all (selection);
        g_signal_connect (selection, "changed",
                          G_CALLBACK (gnc_stock_split_cash_valid_cb), info);
    }

    g_signal_connect (G_OBJECT(window), "destroy",
                      G_CALLBACK (gnc_stock_split_assistant_window_destroy_cb), info);

    gtk_builder_connect_signals(builder, info);
    g_object_unref(G_OBJECT(builder));
    return window;

}
Exemple #22
0
/* public methods implementation */
GtkWidget *
book_view_gtk_new (Ekiga::BookPtr book)
{
  BookViewGtk *result = NULL;

  GtkWidget *label = NULL;
  GtkWidget *hbox = NULL;
  GtkWidget *button = NULL;

  GtkTreeSelection *selection = NULL;
  GtkListStore *store = NULL;
  GtkTreeViewColumn *column = NULL;
  GtkCellRenderer *renderer = NULL;

  result = (BookViewGtk *) g_object_new (BOOK_VIEW_GTK_TYPE, NULL);

  result->priv = new _BookViewGtkPrivate (book);
  result->priv->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
  gtk_frame_set_shadow_type (GTK_FRAME (result), GTK_SHADOW_NONE);

  /* The Search Box */
  boost::shared_ptr<Ekiga::Filterable> filtered = boost::dynamic_pointer_cast<Ekiga::Filterable> (book);

  if (filtered) {

    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    result->priv->entry = gtk_entry_new ();
    button = gtk_button_new_from_stock (GTK_STOCK_FIND);
    label = gtk_label_new_with_mnemonic (_("_Search Filter:"));
    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 2);
    gtk_box_pack_start (GTK_BOX (hbox), result->priv->entry, TRUE, TRUE, 2);
    gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 2);
    gtk_box_pack_start (GTK_BOX (result->priv->vbox), hbox, FALSE, FALSE, 0);
    g_signal_connect (result->priv->entry, "activate",
		      G_CALLBACK (on_entry_activated_cb), result);
    g_signal_connect (button, "clicked",
		      G_CALLBACK (on_button_clicked_cb), result);
  } else {

    result->priv->entry = NULL;
  }

  /* The List Store */
  result->priv->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW
				  (result->priv->scrolled_window),
				  GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);

  result->priv->tree_view = GTK_TREE_VIEW (gtk_tree_view_new ());
  gtk_tree_view_set_headers_visible (result->priv->tree_view, FALSE);
  gtk_container_add (GTK_CONTAINER (result), GTK_WIDGET (result->priv->vbox));
  gtk_box_pack_start (GTK_BOX (result->priv->vbox),
		     GTK_WIDGET (result->priv->scrolled_window), TRUE, TRUE, 0);
  gtk_container_add (GTK_CONTAINER (result->priv->scrolled_window),
		     GTK_WIDGET (result->priv->tree_view));

  selection = gtk_tree_view_get_selection (result->priv->tree_view);
  gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
  g_signal_connect (selection, "changed",
		    G_CALLBACK (on_selection_changed), result);

  g_signal_connect (result->priv->tree_view, "event-after",
		    G_CALLBACK (on_contact_clicked), result);

  store = gtk_list_store_new (COLUMN_NUMBER,
			      G_TYPE_POINTER,
                              GDK_TYPE_PIXBUF,
                              G_TYPE_STRING);

  gtk_tree_view_set_model (result->priv->tree_view, GTK_TREE_MODEL (store));
  g_object_unref (store);

  /* Name */
  column = gtk_tree_view_column_new ();
  renderer = gtk_cell_renderer_pixbuf_new ();
  gtk_tree_view_column_pack_start (column, renderer, FALSE);
  gtk_tree_view_column_set_attributes (column, renderer,
                                       "pixbuf", COLUMN_PIXBUF, 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", COLUMN_NAME,
                                       NULL);

  gtk_tree_view_column_set_title (column, _("Full Name"));
  gtk_tree_view_column_set_sort_column_id (column, COLUMN_NAME);
  gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column),
                                   GTK_TREE_VIEW_COLUMN_AUTOSIZE);
  gtk_tree_view_column_set_resizable (column, true);
  gtk_tree_view_append_column (GTK_TREE_VIEW (result->priv->tree_view), column);

  /* The status bar */
  result->priv->statusbar = gtk_statusbar_new ();
  gtk_box_pack_start (GTK_BOX (result->priv->vbox), result->priv->statusbar, FALSE, TRUE, 0);

  /* connect to the signals */
  result->priv->connections.add (book->contact_added.connect (boost::bind (&on_contact_added, _1, (gpointer)result)));
  result->priv->connections.add (book->contact_updated.connect (boost::bind (&on_contact_updated, _1, (gpointer)result)));
  result->priv->connections.add (book->contact_removed.connect (boost::bind (&on_contact_removed, _1, (gpointer)result)));
  result->priv->connections.add (book->updated.connect (boost::bind (&on_updated, (gpointer)result)));


  /* populate */
  book->visit_contacts (boost::bind (&on_visit_contacts, _1, (gpointer)result));

  return (GtkWidget *) result;
}
Exemple #23
0
static void
ft_manager_build_ui (EmpathyFTManager *manager)
{
  GtkBuilder *gui;
  GtkTreeView *view;
  GtkListStore *liststore;
  GtkTreeViewColumn *column;
  GtkCellRenderer *renderer;
  GtkTreeSelection *selection;
  gchar *filename;
  EmpathyFTManagerPriv *priv = GET_PRIV (manager);

  filename = empathy_file_lookup ("empathy-ft-manager.ui", "src");
  gui = tpaw_builder_get_file (filename,
      "ft_manager_dialog", &priv->window,
      "ft_list", &priv->treeview,
      "clear_button", &priv->clear_button,
      "open_button", &priv->open_button,
      "abort_button", &priv->abort_button,
      NULL);
  g_free (filename);

  tpaw_builder_connect (gui, manager,
      "ft_manager_dialog", "destroy", ft_manager_destroy_cb,
      "ft_manager_dialog", "response", ft_manager_response_cb,
      "ft_manager_dialog", "delete-event", ft_manager_delete_event_cb,
      "ft_manager_dialog", "key-press-event", ft_manager_key_press_event_cb,
      NULL);

  tpaw_builder_unref_and_keep_widget (gui, priv->window);

  /* Window geometry. */
  empathy_geometry_bind (GTK_WINDOW (priv->window), "ft-manager");

  /* Setup the tree view */
  view = GTK_TREE_VIEW (priv->treeview);
  selection = gtk_tree_view_get_selection (view);
  gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
  g_signal_connect (selection, "changed",
      G_CALLBACK (ft_manager_selection_changed), manager);
  g_signal_connect (view, "button-press-event",
                    G_CALLBACK (ft_view_button_press_event_cb),
                    manager);
  gtk_tree_view_set_headers_visible (view, TRUE);
  gtk_tree_view_set_enable_search (view, FALSE);

  /* Setup the model */
  liststore = gtk_list_store_new (5,
      G_TYPE_INT,     /* percent */
      G_TYPE_ICON,    /* icon */
      G_TYPE_STRING,  /* message */
      G_TYPE_STRING,  /* remaining */
      G_TYPE_OBJECT); /* ft_handler */
  gtk_tree_view_set_model (view, GTK_TREE_MODEL (liststore));
  priv->model = GTK_TREE_MODEL (liststore);
  g_object_unref (liststore);

  /* Progress column */
  column = gtk_tree_view_column_new ();
  gtk_tree_view_column_set_title (column, _("%"));
  gtk_tree_view_column_set_sort_column_id (column, COL_PERCENT);
  gtk_tree_view_insert_column (view, column, -1);

  renderer = gtk_cell_renderer_progress_new ();
  g_object_set (renderer, "xalign", 0.5, NULL);
  gtk_tree_view_column_pack_start (column, renderer, FALSE);
  gtk_tree_view_column_set_cell_data_func (column, renderer,
      ft_manager_progress_cell_data_func, NULL, NULL);

  /* Icon and filename column*/
  column = gtk_tree_view_column_new ();
  gtk_tree_view_column_set_title (column, _("File"));
  gtk_tree_view_column_set_expand (column, TRUE);
  gtk_tree_view_column_set_resizable (column, TRUE);
  gtk_tree_view_column_set_sort_column_id (column, COL_MESSAGE);
  gtk_tree_view_column_set_spacing (column, 3);
  gtk_tree_view_insert_column (view, column, -1);

  renderer = gtk_cell_renderer_pixbuf_new ();
  g_object_set (renderer, "xpad", 3,
      "stock-size", GTK_ICON_SIZE_DND, NULL);
  gtk_tree_view_column_pack_start (column, renderer, FALSE);
  gtk_tree_view_column_set_attributes (column, renderer,
      "gicon", COL_ICON, NULL);

  renderer = gtk_cell_renderer_text_new ();
  g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
  gtk_tree_view_column_pack_start (column, renderer, TRUE);
  gtk_tree_view_column_set_attributes (column, renderer,
      "text", COL_MESSAGE, NULL);

  /* Remaining time column */
  column = gtk_tree_view_column_new ();
  gtk_tree_view_column_set_title (column, _("Remaining"));
  gtk_tree_view_column_set_sort_column_id (column, COL_REMAINING);
  gtk_tree_view_insert_column (view, column, -1);

  renderer = gtk_cell_renderer_text_new ();
  g_object_set (renderer, "xalign", 0.5, NULL);
  gtk_tree_view_column_pack_start (column, renderer, FALSE);
  gtk_tree_view_column_set_attributes (column, renderer,
      "text", COL_REMAINING, NULL);

  /* clear button should be sensitive only if there are completed/cancelled
   * handlers in the store.
   */
  gtk_widget_set_sensitive (priv->clear_button, FALSE);
}
Exemple #24
0
void l_zarnah_create_list (class l_zarnah_data *data)
{
iceb_clock sss(data->window);
GtkListStore *model=NULL;
GtkTreeIter iter;
SQLCURSOR cur;
char strsql[512];
int  kolstr=0;
SQL_str row;
//GdkColor color;

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(l_zarnah_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(l_zarnah_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_INT);


sprintf(strsql,"select * from Nash order by kod asc");

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

iceb_u_str ss[NUM_COLUMNS];

data->kolzap=0;

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


  if(iceb_u_SRAV(data->kod_kat_tv.ravno(),row[0],0) == 0)
    data->snanomer=data->kolzap;

  //Код
  ss[COL_KOD].new_plus(iceb_u_toutf(row[0]));
  
  //Наименование
  ss[COL_NAIM].new_plus(iceb_u_toutf(row[1]));

  //Счёт
  ss[COL_SHET].new_plus(iceb_u_toutf(row[2]));

  //Код табеля
  
  ss[COL_KOD_TAB].new_plus("");
  if(atoi(row[3]) != 0)
    ss[COL_KOD_TAB].new_plus(iceb_u_toutf(row[3]));

  //Вид начисления
  if(row[4][0] == '0')
   ss[COL_VID_NAH].new_plus(gettext("Основная"));
  if(row[4][0] == '1')
   ss[COL_VID_NAH].new_plus(gettext("Дополнительная"));
  if(row[4][0] == '2')
   ss[COL_VID_NAH].new_plus(gettext("Прочая"));
   
  //Дата и время записи
  ss[COL_DATA_VREM].new_plus(iceb_u_toutf(iceb_u_vremzap(row[6])));

  //Кто записал
  ss[COL_KTO].new_plus(iceb_kszap(row[5],0,data->window));

  //Проводки
  if(row[7][0] == '0')
   ss[COL_PROV].new_plus(gettext("Нужно делать"));
  else  
   ss[COL_PROV].new_plus(gettext("Не нужно делать"));
  
  //фонд зарплаты
  if(row[8][0] == '0')
   ss[COL_FZ].new_plus(gettext("Входит"));
  else  
   ss[COL_FZ].new_plus(gettext("Невходит"));

  gtk_list_store_append (model, &iter);

  gtk_list_store_set (model, &iter,
  COL_KOD,ss[COL_KOD].ravno(),
  COL_NAIM,ss[COL_NAIM].ravno(),
  COL_SHET,ss[COL_SHET].ravno(),
  COL_KOD_TAB,ss[COL_KOD_TAB].ravno(),
  COL_VID_NAH,ss[COL_VID_NAH].ravno(),
  COL_PROV,ss[COL_PROV].ravno(),
  COL_FZ,ss[COL_FZ].ravno(),
  COL_DATA_VREM,ss[COL_DATA_VREM].ravno(),
  COL_KTO,ss[COL_KTO].ravno(),
  NUM_COLUMNS,data->kolzap,
  -1);

  data->kolzap++;
 }
data->kod_kat_tv.new_plus("");

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

g_object_unref (GTK_TREE_MODEL (model));

l_zarnah_add_columns (GTK_TREE_VIEW (data->treeview));


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

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

//Стать подсветкой стороки на нужный номер строки
iceb_snanomer(data->kolzap,&data->snanomer,data->treeview);


iceb_u_str stroka;
iceb_u_str zagolov;
zagolov.plus(gettext("Список начислений"));

sprintf(strsql," %s:%d",gettext("Количество записей"),data->kolzap);
zagolov.plus(strsql);

gtk_label_set_text(GTK_LABEL(data->label_kolstr),zagolov.ravno_toutf());

if(data->metka_poi == 1)
 {
  
  zagolov.new_plus(gettext("Поиск"));
  zagolov.plus(" !!!");

  iceb_str_poisk(&zagolov,data->poisk.kod.ravno(),gettext("Код"));
  iceb_str_poisk(&zagolov,data->poisk.naim.ravno(),gettext("Наименование"));
  

  gtk_label_set_text(GTK_LABEL(data->label_poisk),zagolov.ravno_toutf());
  gtk_widget_show(data->label_poisk);
 }
else
 gtk_widget_hide(data->label_poisk); 

gtk_widget_show(data->label_kolstr);

}
Exemple #25
0
/*
 * plugin management
 */
void gtkui_plugin_mgmt(GSimpleAction *action, GVariant *value, gpointer data)
{
   GtkWidget *scrolled, *vbox;
   GtkCellRenderer   *renderer;
   GtkTreeViewColumn *column;

   (void) action;
   (void) value;
   (void) data;

   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_box_new(GTK_ORIENTATION_VERTICAL, 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));   

   g_signal_connect(G_OBJECT(treeview), "button-press-event", G_CALLBACK(gtkui_plugin_context), NULL);

   gtk_widget_show(plugins_window);
}
Exemple #26
0
/* create the "open with" dialog. */
void
dlg_open_with (FrWindow *window,
	       GList    *file_list)
{
	DialogData *data;
	GAppInfo *app;
	GList *scan, *app_names = NULL;
	char **editors;
	int i;
	GtkWidget *cancel_button;
	GtkTreeIter iter;
	GtkCellRenderer *renderer;
	GtkTreeViewColumn *column;
	GtkIconTheme *theme;
	int icon_size;

	if (file_list == NULL)
		return;

	data = g_new0 (DialogData, 1);
	data->settings = g_settings_new (EXRED_SCHEMA_GENERAL);
	data->builder = _gtk_builder_new_from_file ("open-with.ui");
	if (data->builder == NULL) {
		g_free (data);
		return;
	}

	data->file_list = path_list_dup (file_list);
	data->window = window;

	/* Get the widgets. */

	data->dialog = _gtk_builder_get_widget (data->builder, "open_with_dialog");
	data->o_app_tree_view = _gtk_builder_get_widget (data->builder, "o_app_list_tree_view");
	data->o_recent_tree_view = _gtk_builder_get_widget (data->builder, "o_recent_tree_view");
	data->o_app_entry = _gtk_builder_get_widget (data->builder, "o_app_entry");
	data->o_del_button = _gtk_builder_get_widget (data->builder, "o_del_button");
	data->ok_button = _gtk_builder_get_widget (data->builder, "o_ok_button");
	cancel_button = _gtk_builder_get_widget (data->builder, "o_cancel_button");

	gtk_widget_set_sensitive (data->ok_button, FALSE);

	/* Set the signals handlers. */

	g_signal_connect (G_OBJECT (data->dialog),
			  "destroy",
			  G_CALLBACK (open_with__destroy_cb),
			  data);

	g_signal_connect (G_OBJECT (data->o_app_entry),
			  "changed",
			  G_CALLBACK (app_entry__changed_cb),
			  data);

	g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (data->o_app_tree_view))),
			  "changed",
			  G_CALLBACK (app_list_selection_changed_cb),
			  data);
	g_signal_connect (G_OBJECT (data->o_app_tree_view),
			  "row_activated",
			  G_CALLBACK (app_activated_cb),
			  data);

	g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (data->o_recent_tree_view))),
			  "changed",
			  G_CALLBACK (recent_list_selection_changed_cb),
			  data);
	g_signal_connect (G_OBJECT (data->o_recent_tree_view),
			  "row_activated",
			  G_CALLBACK (recent_activated_cb),
			  data);

	g_signal_connect (G_OBJECT (data->ok_button),
			  "clicked",
			  G_CALLBACK (open_cb),
			  data);
	g_signal_connect_swapped (G_OBJECT (cancel_button),
				  "clicked",
				  G_CALLBACK (gtk_widget_destroy),
				  G_OBJECT (data->dialog));
	g_signal_connect (G_OBJECT (data->o_del_button),
			  "clicked",
			  G_CALLBACK (delete_recent_cb),
			  data);

	/* Set data. */

	/* * registered applications list. */

	data->app_list = NULL;
	for (scan = data->file_list; scan; scan = scan->next) {
		const char *mime_type;
		const char *name = scan->data;

		mime_type = get_file_mime_type_for_path (name, FALSE);
		if ((mime_type != NULL) && ! g_content_type_is_unknown (mime_type))
			data->app_list = g_list_concat (data->app_list, g_app_info_get_all_for_type (mime_type));
	}

	data->app_model = GTK_TREE_MODEL (gtk_list_store_new (N_COLUMNS,
							      GDK_TYPE_PIXBUF,
							      G_TYPE_STRING,
							      G_TYPE_POINTER));

	gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (data->app_model),
					      TEXT_COLUMN,
					      GTK_SORT_ASCENDING);

	gtk_tree_view_set_model (GTK_TREE_VIEW (data->o_app_tree_view),
				 data->app_model);
	g_object_unref (G_OBJECT (data->app_model));

	theme = gtk_icon_theme_get_default ();
	icon_size = get_folder_pixbuf_size_for_list (GTK_WIDGET (data->dialog));

	for (scan = data->app_list; scan; scan = scan->next) {
		gboolean   found;
		char      *utf8_name;
		GdkPixbuf *icon_image = NULL;

		app = scan->data;

		found = FALSE;
		if (app_names != NULL) {
			GList *p;
			for (p = app_names; p && !found; p = p->next)
				if (g_strcmp0 ((char*)p->data, g_app_info_get_executable (app)) == 0)
					found = TRUE;
		}

		if (found)
			continue;

		app_names = g_list_prepend (app_names, (char*) g_app_info_get_executable (app));

		utf8_name = g_locale_to_utf8 (g_app_info_get_name (app), -1, NULL, NULL, NULL);	
		icon_image = get_icon_pixbuf (g_app_info_get_icon (app), icon_size, theme);
		
		gtk_list_store_append (GTK_LIST_STORE (data->app_model),
				       &iter);
		gtk_list_store_set (GTK_LIST_STORE (data->app_model),
				    &iter,
				    ICON_COLUMN, icon_image,
				    TEXT_COLUMN, utf8_name,
				    DATA_COLUMN, app,
				    -1);

		g_free (utf8_name);
	}

	column = gtk_tree_view_column_new ();

	renderer = gtk_cell_renderer_pixbuf_new ();
	gtk_tree_view_column_pack_start (column, renderer, FALSE);
	gtk_tree_view_column_set_attributes (column, renderer,
					     "pixbuf", ICON_COLUMN,
					     NULL);

	renderer = gtk_cell_renderer_text_new ();
	gtk_tree_view_column_pack_start (column,
					 renderer,
					 TRUE);
	gtk_tree_view_column_set_attributes (column, renderer,
					     "text", TEXT_COLUMN,
					     NULL);

	gtk_tree_view_append_column (GTK_TREE_VIEW (data->o_app_tree_view),
				     column);

	if (app_names)
		g_list_free (app_names);

	/* * recent editors list. */

	data->recent_model = GTK_TREE_MODEL (gtk_list_store_new (1, G_TYPE_STRING));
	gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (data->recent_model), 0, GTK_SORT_ASCENDING);

	gtk_tree_view_set_model (GTK_TREE_VIEW (data->o_recent_tree_view),
				 data->recent_model);
	g_object_unref (G_OBJECT (data->recent_model));

	editors = g_settings_get_strv (data->settings, PREF_GENERAL_EDITORS);
	for (i = 0; editors[i] != NULL; i++) {
		gtk_list_store_append (GTK_LIST_STORE (data->recent_model), &iter);
		gtk_list_store_set (GTK_LIST_STORE (data->recent_model), &iter,
				    0, editors[i],
				    -1);
	}
	g_strfreev (editors);

	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes (NULL,
							   renderer,
							   "text", 0,
							   NULL);
	gtk_tree_view_column_set_sort_column_id (column, 0);
	gtk_tree_view_append_column (GTK_TREE_VIEW (data->o_recent_tree_view),
				     column);

	/* Run dialog. */
	gtk_window_set_transient_for (GTK_WINDOW (data->dialog),
				      GTK_WINDOW (window));
	gtk_window_set_modal (GTK_WINDOW (data->dialog), TRUE);
	gtk_widget_show_all (data->dialog);
}
void _camera_import_dialog_new(_camera_import_dialog_t *data)
{
  data->dialog=gtk_dialog_new_with_buttons(_("import images from camera"),NULL,GTK_DIALOG_MODAL,_("cancel"),GTK_RESPONSE_NONE,C_("camera import", "import"),GTK_RESPONSE_ACCEPT,NULL);
  GtkWidget *content = gtk_dialog_get_content_area (GTK_DIALOG (data->dialog));

  // List - setup store
  data->store = gtk_list_store_new (2,GDK_TYPE_PIXBUF,G_TYPE_STRING);

  // IMPORT PAGE
  data->import.page=gtk_vbox_new(FALSE,5);
  gtk_container_set_border_width(GTK_CONTAINER(data->import.page),5);

  // Top info
  data->import.info=gtk_label_new( _("please wait while prefetching thumbnails of images from camera...") );
  gtk_label_set_single_line_mode( GTK_LABEL(data->import.info) , FALSE );
  gtk_misc_set_alignment(GTK_MISC(data->import.info), 0.0, 0.0);
  gtk_box_pack_start(GTK_BOX(data->import.page),data->import.info,FALSE,FALSE,0);

  // jobcode
  data->import.jobname=_camera_import_gconf_widget(data,_("jobcode"),"plugins/capture/camera/import/jobcode");
  gtk_box_pack_start(GTK_BOX(data->import.page),GTK_WIDGET(data->import.jobname->widget),FALSE,FALSE,0);


  // Create the treview with list model data store
  data->import.treeview=gtk_scrolled_window_new(NULL,NULL);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(data->import.treeview),GTK_POLICY_NEVER,GTK_POLICY_ALWAYS);

  gtk_container_add(GTK_CONTAINER(data->import.treeview), gtk_tree_view_new());
  GtkTreeView *treeview=GTK_TREE_VIEW(gtk_bin_get_child(GTK_BIN(data->import.treeview)));

  GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new( );
  GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes( _("thumbnail") , renderer,"pixbuf",0, (char *)NULL);
  gtk_tree_view_append_column( treeview , column);

  renderer = gtk_cell_renderer_text_new( );
  column = gtk_tree_view_column_new_with_attributes( _("storage file"), renderer, "text", 1, (char *)NULL);
  gtk_tree_view_append_column( treeview , column);
  gtk_tree_view_column_set_expand( column, TRUE);


  GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
  gtk_tree_selection_set_mode(selection,GTK_SELECTION_MULTIPLE);

  gtk_tree_view_set_model(treeview,GTK_TREE_MODEL(data->store));
  gtk_tree_view_set_headers_visible(treeview,FALSE);

  gtk_box_pack_start(GTK_BOX(data->import.page),data->import.treeview,TRUE,TRUE,0);


  // SETTINGS PAGE
  data->settings.page=gtk_vbox_new(FALSE,5);
  gtk_container_set_border_width(GTK_CONTAINER(data->settings.page),5);

  // general settings
  gtk_box_pack_start(GTK_BOX(data->settings.page),dtgtk_label_new(_("general"),DARKTABLE_LABEL_TAB|DARKTABLE_LABEL_ALIGN_RIGHT),FALSE,FALSE,0);

  // ignoring of jpegs. hack while we don't handle raw+jpeg in the same directories.
  data->settings.general.ignore_jpeg = gtk_check_button_new_with_label (_("ignore JPEG files"));
  g_object_set(data->settings.general.ignore_jpeg, "tooltip-text", _("do not load files with an extension of .jpg or .jpeg. this can be useful when there are raw+JPEG in a directory."), NULL);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->settings.general.ignore_jpeg), dt_conf_get_bool("ui_last/import_ignore_jpegs"));
  gtk_box_pack_start(GTK_BOX(data->settings.page), data->settings.general.ignore_jpeg, FALSE, FALSE, 0);
  g_signal_connect (G_OBJECT(data->settings.general.ignore_jpeg), "clicked",G_CALLBACK (_check_button_callback),data);

  GtkWidget *hbox=gtk_hbox_new(FALSE,5);
  data->settings.general.date_override=gtk_check_button_new_with_label(_("override today's date"));
  gtk_box_pack_start(GTK_BOX(hbox),data->settings.general.date_override,FALSE,FALSE,0);
  g_object_set(data->settings.general.date_override,"tooltip-text",_("check this, if you want to override the timestamp used when expanding variables:\n$(YEAR), $(MONTH), $(DAY),\n$(HOUR), $(MINUTE), $(SECONDS)"),(char *)NULL);

  data->settings.general.date_entry=gtk_entry_new();
  gtk_widget_set_sensitive( data->settings.general.date_entry, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->settings.general.date_override)));
  gtk_box_pack_start(GTK_BOX(hbox),data->settings.general.date_entry,TRUE,TRUE,0);

  g_signal_connect (G_OBJECT (data->settings.general.date_override), "clicked",G_CALLBACK (_check_button_callback),data);

  gtk_box_pack_start(GTK_BOX(data->settings.page),hbox,FALSE,FALSE,0);


  // THE NOTEBOOK
  data->notebook=gtk_notebook_new();
  gtk_notebook_append_page(GTK_NOTEBOOK(data->notebook),data->import.page,gtk_label_new(_("images")));
  gtk_notebook_append_page(GTK_NOTEBOOK(data->notebook),data->settings.page,gtk_label_new(_("settings")));

  // end
  gtk_box_pack_start(GTK_BOX(content),data->notebook,TRUE,TRUE,0);
  //gtk_widget_set_size_request(content,400,400);
}
Exemple #28
0
/* exported interface documented in gtk/download.h */
nserror nsgtk_download_init(void)
{
	GtkBuilder* builder;
	nserror res;

	res = nsgtk_builder_new_from_resname("downloads", &builder);
	if (res != NSERROR_OK) {
		LOG("Download UI builder init failed");
		return res;
	}

	gtk_builder_connect_signals(builder, NULL);

	nsgtk_download_button_pause = GTK_BUTTON(gtk_builder_get_object(builder, "buttonPause"));
	nsgtk_download_button_clear = GTK_BUTTON(gtk_builder_get_object(builder, "buttonClear"));
	nsgtk_download_button_cancel = GTK_BUTTON(gtk_builder_get_object(builder, "buttonCancel"));
	nsgtk_download_button_resume = GTK_BUTTON(gtk_builder_get_object(builder, "buttonPlay"));

	nsgtk_download_progress_bar = GTK_PROGRESS_BAR(gtk_builder_get_object(builder, "progressBar"));
	nsgtk_download_window = GTK_WINDOW(gtk_builder_get_object(builder, "wndDownloads"));
	nsgtk_download_parent = NULL;

	gtk_window_set_transient_for(GTK_WINDOW(nsgtk_download_window),
				     nsgtk_download_parent);
	gtk_window_set_destroy_with_parent(GTK_WINDOW(nsgtk_download_window),
					   FALSE);

	nsgtk_downloads_timer = g_timer_new();

	nsgtk_download_tree = nsgtk_download_tree_view_new(builder);

	nsgtk_download_store = gtk_list_store_new(NSGTK_DOWNLOAD_N_COLUMNS,
						  G_TYPE_INT, /* % complete */
						  G_TYPE_STRING, /* Description */
						  G_TYPE_STRING, /* Time remaining */
						  G_TYPE_STRING, /* Speed */
						  G_TYPE_INT,	/* Pulse */
						  G_TYPE_STRING, /* Status */
						  G_TYPE_POINTER /* Download structure */
		);


	gtk_tree_view_set_model(nsgtk_download_tree,
				GTK_TREE_MODEL(nsgtk_download_store));

	gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(nsgtk_download_store),
					NSGTK_DOWNLOAD_STATUS,
					(GtkTreeIterCompareFunc) nsgtk_download_sort, NULL, NULL);
	gtk_tree_sortable_set_sort_column_id(
		GTK_TREE_SORTABLE(nsgtk_download_store),
		NSGTK_DOWNLOAD_STATUS, GTK_SORT_ASCENDING);

	g_object_unref(nsgtk_download_store);

	nsgtk_download_selection =
		gtk_tree_view_get_selection(nsgtk_download_tree);
	gtk_tree_selection_set_mode(nsgtk_download_selection,
				    GTK_SELECTION_MULTIPLE);

	g_signal_connect(G_OBJECT(nsgtk_download_selection), "changed",
			 G_CALLBACK(nsgtk_download_sensitivity_evaluate), NULL);
	g_signal_connect(nsgtk_download_tree, "row-activated",
			 G_CALLBACK(nsgtk_download_tree_view_row_activated),
			 NULL);
	g_signal_connect_swapped(gtk_builder_get_object(builder, "buttonClear"),
				 "clicked", 
				 G_CALLBACK(nsgtk_download_do),
				 nsgtk_download_store_clear_item);
	g_signal_connect_swapped(gtk_builder_get_object(builder, "buttonCancel"), 
				 "clicked",
				 G_CALLBACK(nsgtk_download_do),
				 nsgtk_download_store_cancel_item);
	g_signal_connect(G_OBJECT(nsgtk_download_window), "delete-event",
			 G_CALLBACK(nsgtk_download_hide), NULL);

	return NSERROR_OK;
}
Exemple #29
0
int main(int argc, char* argv[])
{
	regex_t fregex[2];

	gtk_init(&argc,&argv);

	// check the correct BASS was loaded
	if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
		Error("An incorrect version of BASS was loaded");
		return 0;
	}

	// Initialize the output device with 3D support
	if (!BASS_Init(-1,44100,BASS_DEVICE_3D,NULL,NULL)) {
		Error("Can't initialize device");
		return 0;
	}

	{
		BASS_INFO i;
		BASS_GetInfo(&i);
		if (i.speakers>2) {
			GtkWidget *dialog=gtk_message_dialog_new(NULL,0,
				GTK_MESSAGE_QUESTION,GTK_BUTTONS_YES_NO,"Multiple speakers were detected. Would you like to use them?");
			if (gtk_dialog_run(GTK_DIALOG(dialog))==GTK_RESPONSE_NO)
				BASS_SetConfig(BASS_CONFIG_3DALGORITHM,BASS_3DALG_OFF);
			gtk_widget_destroy(dialog);
		}
	}

	// Use meters as distance unit, real world rolloff, real doppler effect
	BASS_Set3DFactors(1,1,1);

	// initialize GUI
	glade=glade_xml_new(GLADE_PATH"3dtest.glade",NULL,NULL);
	if (!glade) return 0;
	win=GetWidget("window1");
	if (!win) return 0;
	glade_xml_signal_autoconnect(glade);
	g_signal_connect(gtk_tree_view_get_selection(GTK_TREE_VIEW(GetWidget("channels"))),"changed",G_CALLBACK(ListSelectionChange),NULL);

	{ // setup list
		GtkTreeView *list=GTK_TREE_VIEW(GetWidget("channels"));
		GtkTreeViewColumn *col=gtk_tree_view_column_new();
		gtk_tree_view_append_column(list,col);
		GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
		gtk_tree_view_column_pack_start(col,renderer,TRUE);
		gtk_tree_view_column_add_attribute(col, renderer, "text", 0);
		GtkListStore *liststore=gtk_list_store_new(1,G_TYPE_STRING);
		gtk_tree_view_set_model(list,GTK_TREE_MODEL(liststore));
		g_object_unref(liststore);
	}

	{ // initialize file selector
		GtkFileFilter *filter;
		filesel=gtk_file_chooser_dialog_new("Open File",GTK_WINDOW(win),GTK_FILE_CHOOSER_ACTION_OPEN,
			GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_OPEN,GTK_RESPONSE_ACCEPT,NULL);
		filter=gtk_file_filter_new();
		gtk_file_filter_set_name(filter,"Streamable files (wav/aif/mp3/mp2/mp1/ogg)");
		regcomp(&fregex[0],"\\.(mp[1-3]|ogg|wav|aif)$",REG_ICASE|REG_NOSUB|REG_EXTENDED);
		gtk_file_filter_add_custom(filter,GTK_FILE_FILTER_FILENAME,FileExtensionFilter,&fregex[0],NULL);
		gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(filesel),filter);
		filter=gtk_file_filter_new();
		gtk_file_filter_set_name(filter,"MOD music files (mo3/xm/mod/s3m/it/mtm/umx)");
		regcomp(&fregex[1],"\\.(mo3|xm|mod|s3m|it|umx)$",REG_ICASE|REG_NOSUB|REG_EXTENDED);
		gtk_file_filter_add_custom(filter,GTK_FILE_FILTER_FILENAME,FileExtensionFilter,&fregex[1],NULL);
		gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(filesel),filter);
		filter=gtk_file_filter_new();
		gtk_file_filter_set_name(filter,"All files");
		gtk_file_filter_add_pattern(filter,"*");
		gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(filesel),filter);
	}

	g_timeout_add(TIMERPERIOD,Update,NULL);

	UpdateButtons();

	gtk_main();

	gtk_widget_destroy(filesel);
	regfree(&fregex[0]);
	regfree(&fregex[1]);

	BASS_Free(); // close output

    return 0;
}
static void
account_categories_tree_view_prepare (hierarchy_data  *data)
{
    GSList *list;
    gchar *gnc_accounts_dir;
    gchar *locale_dir;
    GtkTreeView *tree_view;
    GtkListStore *model;
    GtkTreeViewColumn *column;
    GtkCellRenderer *renderer;
    GtkTreeSelection *selection;
    GtkTreePath *path;

    gnc_accounts_dir = gnc_path_get_accountsdir ();
    locale_dir = gnc_get_ea_locale_dir (gnc_accounts_dir);
    list = gnc_load_example_account_list (locale_dir);
    g_free (gnc_accounts_dir);
    g_free (locale_dir);

    /* Prepare the account_categories GtkTreeView with a model and with some columns */
    tree_view = data->categories_tree;
    model = gtk_list_store_new(NUM_COLUMNS, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING,
                               G_TYPE_STRING, G_TYPE_POINTER);
    gtk_tree_view_set_model (tree_view, GTK_TREE_MODEL(model));
    g_object_unref (model);

    g_slist_foreach(list, (GFunc)add_one_category, data);

    g_signal_connect (G_OBJECT (model), "row_changed",
                      G_CALLBACK (categories_selection_changed),
                      data);

    renderer = gtk_cell_renderer_toggle_new ();
    g_object_set (G_OBJECT (renderer), "activatable", TRUE, NULL);
    column = gtk_tree_view_column_new_with_attributes (_("Selected"),
             renderer,
             "active", COL_CHECKED,
             NULL);
    gtk_tree_view_append_column (tree_view, column);
    gtk_tree_view_column_set_sort_column_id (column, COL_CHECKED);
    g_signal_connect (G_OBJECT (renderer), "toggled",
                      G_CALLBACK (category_checkbox_toggled),
                      model);


    renderer = gtk_cell_renderer_text_new ();
    column = gtk_tree_view_column_new_with_attributes (_("Account Types"),
             renderer,
             "text", COL_TITLE,
             NULL);
    gtk_tree_view_append_column (tree_view, column);
    gtk_tree_view_column_set_sort_column_id (column, COL_TITLE);

//	renderer = gtk_cell_renderer_text_new ();
//	column = gtk_tree_view_column_new_with_attributes (_("Description"),
//							   renderer,
//							   "text", COL_SHORT_DESCRIPTION,
//							   NULL);
//	gtk_tree_view_append_column (tree_view, column);
//	gtk_tree_view_column_set_sort_column_id (column, COL_SHORT_DESCRIPTION);

    gtk_tree_view_set_headers_clickable(tree_view, TRUE);
    gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(model),
                                          COL_TITLE,
                                          GTK_SORT_ASCENDING);

    if (data->initial_category)
    {
        path = gtk_tree_row_reference_get_path(data->initial_category);
        selection = gtk_tree_view_get_selection(tree_view);
        gtk_tree_view_scroll_to_cell(tree_view, path, NULL, TRUE, 0.5, 0.5);
        gtk_tree_selection_select_path(selection, path);
        gtk_tree_path_free(path);
    }
}