static GtkCellEditable* ddb_cell_renderer_text_multiline_real_start_editing (GtkCellRenderer* base, GdkEvent* event, GtkWidget* widget, const gchar* path, GdkRectangle* background_area, GdkRectangle* cell_area, GtkCellRendererState flags) {
	DdbCellRendererTextMultiline * self;
	GtkCellEditable* result = NULL;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_;
	const gchar* _tmp2_;
	GtkTreePath* _tmp3_;
	GtkTreePath* p;
	GtkWidget* _tmp4_;
	GtkTreeView* _tmp5_;
	GtkTreeView* tv;
	GtkTreeView* _tmp6_;
	GtkTreeModel* _tmp7_ = NULL;
	GtkListStore* _tmp8_;
	GtkListStore* store;
	GtkTreeIter iter = {0};
	GtkListStore* _tmp9_;
	GtkTreePath* _tmp10_;
	GtkTreeIter _tmp11_ = {0};
	GValue v = {0};
	GtkListStore* _tmp12_;
	GtkTreeIter _tmp13_;
	GValue _tmp14_ = {0};
	gint _tmp15_ = 0;
	gint mult;
	DdbCellEditableTextView* _tmp16_;
	DdbCellEditableTextView* _tmp17_;
	gint _tmp18_;
	DdbCellEditableTextView* _tmp19_;
	const gchar* _tmp20_;
	gchar* _tmp21_;
	GtkTextBuffer* _tmp22_;
	GtkTextBuffer* buf;
	gchar* _tmp23_ = NULL;
	gchar* _tmp24_;
	gchar* _tmp25_;
	gboolean _tmp26_;
	DdbCellEditableTextView* _tmp31_;
	GtkTextBuffer* _tmp32_;
	DdbCellEditableTextView* _tmp33_;
	DdbCellEditableTextView* _tmp34_;
	gulong _tmp35_ = 0UL;
	DdbCellEditableTextView* _tmp36_;
	GdkRectangle _tmp37_;
	gint _tmp38_;
	GdkRectangle _tmp39_;
	gint _tmp40_;
	DdbCellEditableTextView* _tmp41_;
	DdbCellEditableTextView* _tmp42_;
	self = (DdbCellRendererTextMultiline*) base;
	g_return_val_if_fail (widget != NULL, NULL);
	g_return_val_if_fail (path != NULL, NULL);
	g_return_val_if_fail (background_area != NULL, NULL);
	g_return_val_if_fail (cell_area != NULL, NULL);
	g_object_get ((GtkCellRendererText*) self, "editable", &_tmp0_, NULL);
	_tmp1_ = _tmp0_;
	if (!_tmp1_) {
		result = GTK_CELL_EDITABLE (NULL);
		return result;
	}
	_tmp2_ = path;
	_tmp3_ = gtk_tree_path_new_from_string (_tmp2_);
	p = _tmp3_;
	_tmp4_ = widget;
	_tmp5_ = _g_object_ref0 (GTK_TREE_VIEW (_tmp4_));
	tv = _tmp5_;
	_tmp6_ = tv;
	_tmp7_ = gtk_tree_view_get_model (_tmp6_);
	_tmp8_ = _g_object_ref0 (GTK_LIST_STORE (_tmp7_));
	store = _tmp8_;
	_tmp9_ = store;
	_tmp10_ = p;
	gtk_tree_model_get_iter ((GtkTreeModel*) _tmp9_, &_tmp11_, _tmp10_);
	iter = _tmp11_;
	_tmp12_ = store;
	_tmp13_ = iter;
	gtk_tree_model_get_value ((GtkTreeModel*) _tmp12_, &_tmp13_, 3, &_tmp14_);
	G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
	v = _tmp14_;
	_tmp15_ = g_value_get_int (&v);
	mult = _tmp15_;
	_tmp16_ = ddb_cell_editable_text_view_new ();
	_tmp17_ = g_object_ref_sink (_tmp16_);
	_g_object_unref0 (self->priv->entry);
	self->priv->entry = _tmp17_;
	_tmp18_ = mult;
	if (_tmp18_ != 0) {
		g_object_set ((GtkCellRendererText*) self, "text", "", NULL);
	}
	_tmp19_ = self->priv->entry;
	_tmp20_ = path;
	_tmp21_ = g_strdup (_tmp20_);
	_g_free0 (_tmp19_->tree_path);
	_tmp19_->tree_path = _tmp21_;
	_tmp22_ = gtk_text_buffer_new (NULL);
	buf = _tmp22_;
	g_object_get ((GtkCellRendererText*) self, "text", &_tmp23_, NULL);
	_tmp24_ = _tmp23_;
	_tmp25_ = _tmp24_;
	_tmp26_ = _tmp25_ != NULL;
	_g_free0 (_tmp25_);
	if (_tmp26_) {
		GtkTextBuffer* _tmp27_;
		gchar* _tmp28_ = NULL;
		gchar* _tmp29_;
		gchar* _tmp30_;
		_tmp27_ = buf;
		g_object_get ((GtkCellRendererText*) self, "text", &_tmp28_, NULL);
		_tmp29_ = _tmp28_;
		_tmp30_ = _tmp29_;
		gtk_text_buffer_set_text (_tmp27_, _tmp30_, -1);
		_g_free0 (_tmp30_);
	}
	_tmp31_ = self->priv->entry;
	_tmp32_ = buf;
	gtk_text_view_set_buffer ((GtkTextView*) _tmp31_, _tmp32_);
	_tmp33_ = self->priv->entry;

    self->priv->in_entry_menu = FALSE;
    if (self->priv->entry_menu_popdown_timeout)
    {
        g_source_remove (self->priv->entry_menu_popdown_timeout);
        self->priv->entry_menu_popdown_timeout = 0;
    }

	g_signal_connect (_tmp33_, "editing-done", (GCallback) ddb_cell_renderer_text_multiline_gtk_cell_renderer_text_editing_done, self);
	_tmp34_ = self->priv->entry;
	_tmp35_ = g_signal_connect_after (_tmp34_, "focus-out-event", (GCallback) ddb_cell_renderer_text_multiline_gtk_cell_renderer_focus_out_event, self);

    self->priv->populate_popup_id =
        g_signal_connect (self->priv->entry, "populate-popup",
                G_CALLBACK (ddb_cell_renderer_text_multiline_populate_popup),
                self);

	self->priv->focus_out_id = _tmp35_;
	_tmp36_ = self->priv->entry;
	_tmp37_ = *cell_area;
	_tmp38_ = _tmp37_.width;
	_tmp39_ = *cell_area;
	_tmp40_ = _tmp39_.height;
	gtk_widget_set_size_request ((GtkWidget*) _tmp36_, _tmp38_, _tmp40_);
	_tmp41_ = self->priv->entry;
	gtk_widget_show ((GtkWidget*) _tmp41_);
	_tmp42_ = self->priv->entry;
	result = GTK_CELL_EDITABLE (_tmp42_);
	_g_object_unref0 (buf);
	G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
	_g_object_unref0 (store);
	_g_object_unref0 (tv);
	_gtk_tree_path_free0 (p);
	// evil hack! need to make an event for that
	extern int trkproperties_block_keyhandler;
	trkproperties_block_keyhandler = 1;
	return result;
}
Пример #2
0
extern void admin_edit_resv(GtkCellRendererText *cell,
			    const char *path_string,
			    const char *new_text,
			    gpointer data)
{
	GtkTreeStore *treestore = GTK_TREE_STORE(data);
	GtkTreePath *path = gtk_tree_path_new_from_string(path_string);
	GtkTreeIter iter;
	resv_desc_msg_t *resv_msg = xmalloc(sizeof(resv_desc_msg_t));

	char *temp = NULL;
	char *old_text = NULL;
	const char *type = NULL;

	int column = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cell),
						       "column"));

	if (!new_text || !strcmp(new_text, ""))
		goto no_input;

	gtk_tree_model_get_iter(GTK_TREE_MODEL(treestore), &iter, path);

	slurm_init_resv_desc_msg(resv_msg);
	gtk_tree_model_get(GTK_TREE_MODEL(treestore), &iter,
			   SORTID_NAME, &temp,
			   column, &old_text,
			   -1);
	resv_msg->name = xstrdup(temp);
	g_free(temp);

	type = _set_resv_msg(resv_msg, new_text, column);
	if (global_edit_error)
		goto print_error;

	if (got_edit_signal) {
		temp = got_edit_signal;
		got_edit_signal = NULL;
		_admin_resv(GTK_TREE_MODEL(treestore), &iter, temp);
		xfree(temp);
		goto no_input;
	}

	if (old_text && !strcmp(old_text, new_text)) {
		temp = g_strdup_printf("No change in value.");
	} else if (slurm_update_reservation(resv_msg)
		   == SLURM_SUCCESS) {
		gtk_tree_store_set(treestore, &iter, column, new_text, -1);
		temp = g_strdup_printf("Reservation %s %s changed to %s",
				       resv_msg->name,
				       type,
				       new_text);
	} else if (errno == ESLURM_DISABLED) {
		temp = g_strdup_printf(
			"Can only edit %s on reservations not yet started.",
			type);
	} else {
	print_error:
		temp = g_strdup_printf("Reservation %s %s can't be "
				       "set to %s",
				       resv_msg->name,
				       type,
				       new_text);
	}

	display_edit_note(temp);
	g_free(temp);

no_input:
	slurm_free_resv_desc_msg(resv_msg);

	gtk_tree_path_free (path);
	g_free(old_text);
	g_mutex_unlock(sview_mutex);
}
Пример #3
0
static void
gm_prefs_window_sound_events_list_build (GtkWidget *prefs_window)
{
  GmPreferencesWindow *pw = NULL;

  GtkTreeSelection *selection = NULL;
  GtkTreePath *path = NULL;
  GtkTreeModel *model = NULL;
  GtkTreeIter iter, selected_iter;

  bool enabled = FALSE;

  pw = gm_pw_get_pw (prefs_window);

  selection =
    gtk_tree_view_get_selection (GTK_TREE_VIEW (pw->sound_events_list));

  if (gtk_tree_selection_get_selected (selection, &model, &selected_iter))
    path = gtk_tree_model_get_path (model, &selected_iter);

  gtk_list_store_clear (GTK_LIST_STORE (model));

  /* Sound on incoming calls */
  enabled = gm_conf_get_bool (SOUND_EVENTS_KEY "enable_incoming_call_sound");
  gtk_list_store_append (GTK_LIST_STORE (model), &iter);
  gtk_list_store_set (GTK_LIST_STORE (model), &iter,
		      0, enabled,
		      1, _("Play sound on incoming calls"),
		      2, SOUND_EVENTS_KEY "incoming_call_sound",
		      3, SOUND_EVENTS_KEY "enable_incoming_call_sound",
                      4, "incoming_call_sound",
		      -1);

  enabled = gm_conf_get_bool (SOUND_EVENTS_KEY "enable_ring_tone_sound");
  gtk_list_store_append (GTK_LIST_STORE (model), &iter);
  gtk_list_store_set (GTK_LIST_STORE (model), &iter,
		      0, enabled,
		      1, _("Play ring tone"),
		      2, SOUND_EVENTS_KEY "ring_tone_sound",
		      3, SOUND_EVENTS_KEY "enable_ring_tone_sound",
                      4, "ring_tone_sound",
		      -1);

  enabled = gm_conf_get_bool (SOUND_EVENTS_KEY "enable_busy_tone_sound");
  gtk_list_store_append (GTK_LIST_STORE (model), &iter);
  gtk_list_store_set (GTK_LIST_STORE (model), &iter,
		      0, enabled,
		      1, _("Play busy tone"),
		      2, SOUND_EVENTS_KEY "busy_tone_sound",
		      3, SOUND_EVENTS_KEY "enable_busy_tone_sound",
		      4, "busy_tone_sound",
		      -1);

  enabled = gm_conf_get_bool (SOUND_EVENTS_KEY "enable_new_voicemail_sound");
  gtk_list_store_append (GTK_LIST_STORE (model), &iter);
  gtk_list_store_set (GTK_LIST_STORE (model), &iter,
		      0, enabled,
		      1, _("Play sound for new voice mails"),
		      2, SOUND_EVENTS_KEY "new_voicemail_sound",
		      3, SOUND_EVENTS_KEY "enable_new_voicemail_sound",
		      4, "new_voicemail_sound",
		      -1);

  enabled = gm_conf_get_bool (SOUND_EVENTS_KEY "enable_new_message_sound");
  gtk_list_store_append (GTK_LIST_STORE (model), &iter);
  gtk_list_store_set (GTK_LIST_STORE (model), &iter,
		      0, enabled,
		      1, _("Play sound for new instant messages"),
		      2, SOUND_EVENTS_KEY "new_message_sound",
		      3, SOUND_EVENTS_KEY "enable_new_message_sound",
		      4, "new_message_sound",
		      -1);

  if (!path)
    path = gtk_tree_path_new_from_string ("0");

  gtk_tree_view_set_cursor (GTK_TREE_VIEW (pw->sound_events_list),
			    path, NULL, false);
  gtk_tree_path_free (path);
}
Пример #4
0
static void accel_edited_callback(GtkCellRendererText *cell, const char *path_string, guint accel_key, 
				  GdkModifierType accel_mods, guint hardware_keycode, gpointer data)
{
	GtkTreeView *view = (GtkTreeView *)data;
	GtkTreeModel *model = NULL;
	GtkTreeIter iter = {0};
	GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
	GtkAccelKey *key_entry = NULL, temp_key = {0};
	GtkWidget *msg_dialog = NULL;
	gchar *temp_str = NULL;

	model = gtk_tree_view_get_model (view);
	gtk_tree_model_get_iter (model, &iter, path);
	gtk_tree_path_free (path);
	gtk_tree_model_get (model, &iter, HOTKEY_COLUMN, &key_entry, -1);

	/* sanity check and check to see if the same key combo was pressed again */
	if (key_entry == NULL || 
	(key_entry->accel_key == accel_key && 
	key_entry->accel_mods == accel_mods && 
	key_entry->accel_flags == hardware_keycode))
		return;

	/* CapsLock isn't supported as a keybinding modifier, so keep it from confusing us */
	accel_mods &= ~GDK_LOCK_MASK;

	temp_key.accel_key = accel_key;
	temp_key.accel_flags = hardware_keycode;
	temp_key.accel_mods   = accel_mods;


	/* Check for unmodified keys */
	if (temp_key.accel_mods == 0 && temp_key.accel_key != 0)
	{
		if ((temp_key.accel_key >= GDK_a && temp_key.accel_key <= GDK_z)
		   || (temp_key.accel_key >= GDK_A && temp_key.accel_key <= GDK_Z)
		   || (temp_key.accel_key >= GDK_0 && temp_key.accel_key <= GDK_9)
		   || (temp_key.accel_key >= GDK_kana_fullstop && temp_key.accel_key <= GDK_semivoicedsound)
		   || (temp_key.accel_key >= GDK_Arabic_comma && temp_key.accel_key <= GDK_Arabic_sukun)
		   || (temp_key.accel_key >= GDK_Serbian_dje && temp_key.accel_key <= GDK_Cyrillic_HARDSIGN)
		   || (temp_key.accel_key >= GDK_Greek_ALPHAaccent && temp_key.accel_key <= GDK_Greek_omega)
		   || (temp_key.accel_key >= GDK_hebrew_doublelowline && temp_key.accel_key <= GDK_hebrew_taf)
		   || (temp_key.accel_key >= GDK_Thai_kokai && temp_key.accel_key <= GDK_Thai_lekkao)
		   || (temp_key.accel_key >= GDK_Hangul && temp_key.accel_key <= GDK_Hangul_Special)
		   || (temp_key.accel_key >= GDK_Hangul_Kiyeog && temp_key.accel_key <= GDK_Hangul_J_YeorinHieuh)
		   || keyval_is_forbidden (temp_key.accel_key))
		{
			temp_str = gtk_accelerator_get_label (accel_key, accel_mods);

			msg_dialog = gtk_message_dialog_new (
						GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))),
						GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
						GTK_MESSAGE_WARNING,
						GTK_BUTTONS_OK, 
						STR_INVALID_HOTKEY, 
						temp_str);
			g_object_set(msg_dialog, "title", STR_INVALID_HOTKEY_TITLE, NULL);

			g_free (temp_str); temp_str = NULL;
			gtk_dialog_run (GTK_DIALOG (msg_dialog));
			gtk_widget_destroy (msg_dialog);
			msg_dialog = NULL;

			return;
		}
	}

	/* try registering the new key combo */
	if(grab_ungrab_with_ignorable_modifiers(&temp_key, TRUE))
	{
		/* unregistering previous hotkey is not necessary on Win32
		   since the same prev. hotkey is modified to the new one */
#ifndef G_OS_WIN32
		/* unregister the previous hotkey */
		grab_ungrab_with_ignorable_modifiers(key_entry, FALSE);
#endif

		/* set the value in the list store to the newly set key combo
		   so that it gets reflected in the Accel Cell Renderer */
		key_entry->accel_key = accel_key;
		key_entry->accel_flags = hardware_keycode;
		key_entry->accel_mods = accel_mods;
	}
	else
	{
		temp_str = gtk_accelerator_get_label (accel_key, accel_mods);

		msg_dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))),
							GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
							GTK_MESSAGE_WARNING,
							GTK_BUTTONS_OK, 
							STR_DUPLICATE_HOTKEY, 
							temp_str);
		g_object_set(msg_dialog, "title", STR_INVALID_HOTKEY_TITLE, NULL);

		g_free (temp_str); temp_str = NULL;
		gtk_dialog_run (GTK_DIALOG (msg_dialog));
		gtk_widget_destroy (msg_dialog);

		return;
	}
}
Пример #5
0
static void
cell_edited (GtkCellRendererText *cell,
             const gchar *path_string,
             const gchar *new_text,
             gpointer user_data)
{
	CEPageIP4 *self = CE_PAGE_IP4 (user_data);
	CEPageIP4Private *priv = CE_PAGE_IP4_GET_PRIVATE (self);
	GtkListStore *store = GTK_LIST_STORE (gtk_tree_view_get_model (priv->addr_list));
	GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
	GtkTreeIter iter;
	guint32 column;
	GtkTreeViewColumn *next_col;
	GtkCellRenderer *next_cell;
	gboolean can_cycle;
	int direction, tmp;

	/* Free auxiliary stuff */
	g_free (priv->last_edited);
	priv->last_edited = NULL;
	g_free (priv->last_path);
	priv->last_path = NULL;
	priv->last_column = -1;

	column = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (cell), "column"));
	gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, path);
	gtk_list_store_set (store, &iter, column, new_text, -1);

	/* Try to autodetect the prefix from the given address if we can */
	if (column == COL_ADDRESS && new_text && strlen (new_text)) {
		char *prefix = NULL;
		const char *guess_prefix = NULL;

		gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (store), &iter, path_string);
		gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, COL_PREFIX, &prefix, -1);
		if (!prefix || !strlen (prefix)) {
			if (!strncmp ("10.", new_text, 3))
				guess_prefix = "8";
			else if (!strncmp ("172.16.", new_text, 7))
				guess_prefix = "16";
			else if (!strncmp ("192.168.", new_text, 8))
				guess_prefix = "24";

			if (guess_prefix)
				gtk_list_store_set (store, &iter, COL_PREFIX, guess_prefix, -1);
		}
		g_free (prefix);
	}

	/* Move focus to the next/previous column */
	can_cycle = g_object_get_data (G_OBJECT (cell), DO_NOT_CYCLE_TAG) == NULL;
	direction = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), DIRECTION_TAG));
	g_object_set_data (G_OBJECT (cell), DIRECTION_TAG, NULL);
	g_object_set_data (G_OBJECT (cell), DO_NOT_CYCLE_TAG, NULL);
	if (direction == 0)  /* Move forward by default */
		direction = 1;

	tmp = column + direction;
	if (can_cycle)
		column = tmp < 0 ? COL_LAST : tmp > COL_LAST ? 0 : tmp;
	else
		column = tmp;
	next_col = gtk_tree_view_get_column (priv->addr_list, column);
	next_cell = column <= COL_LAST ? priv->addr_cells[column] : NULL;
	gtk_tree_view_set_cursor_on_cell (priv->addr_list, path, next_col, next_cell, TRUE);

	gtk_tree_path_free (path);
	ce_page_changed (CE_PAGE (self));
}
Пример #6
0
static void
cb_toggled_visible (G_GNUC_UNUSED GtkCellRendererToggle *cell,
		 gchar                 *path_string,
		 gpointer               data)
{
	SheetManager *state = data;
	GtkTreeModel *model = GTK_TREE_MODEL (state->model);
	GtkTreeIter iter;
	GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
	gboolean is_visible;
	Sheet *this_sheet;
	WorkbookSheetState *old_state;
	WorkbookControl *wbc = GNM_WBC (state->wbcg);
	Workbook *wb = wb_control_get_workbook (wbc);
	int cnt;

	if (!gtk_tree_model_get_iter (model, &iter, path)) {
		g_warning ("Did not get a valid iterator");
		gtk_tree_path_free (path);
		return;
	}

	gtk_tree_model_get (model, &iter,
			    SHEET_VISIBLE, &is_visible,
			    SHEET_POINTER, &this_sheet,
			    -1);

	if (is_visible) {
		cnt = sheet_order_cnt_visible (state);
		if (cnt <= 1) {
			go_gtk_notice_dialog (GTK_WINDOW (state->dialog), GTK_MESSAGE_ERROR,
					      _("At least one sheet must remain visible!"));
			gtk_tree_path_free (path);
			return;
		}
		gtk_list_store_set (GTK_LIST_STORE (model), &iter,
				    SHEET_VISIBLE, FALSE,
				    SHEET_VISIBLE_IMAGE, NULL,
				    -1);

	} else {
		gtk_list_store_set (GTK_LIST_STORE (model), &iter,
				    SHEET_VISIBLE, TRUE,
				    SHEET_VISIBLE_IMAGE,
				    state->image_visible,
				    -1);
	}
	gtk_tree_path_free (path);

	old_state = workbook_sheet_state_new (wb);
	g_object_set (this_sheet,
		      "visibility",
		      !is_visible ? GNM_SHEET_VISIBILITY_VISIBLE
		      : GNM_SHEET_VISIBILITY_HIDDEN,
		      NULL);

	cmd_reorganize_sheets (wbc, old_state, this_sheet);
	update_undo (state, wbc);

	if (is_visible)
		populate_sheet_list (state);
}
Пример #7
0
void
cell_edited_callback(GtkCellRendererText *cell,
                     const gchar         *path_string,
                     gchar               *new_text,
                     gpointer data)
{
	GtkTreeModel *model = (GtkTreeModel *)data;
	GtkTreePath *path = gtk_tree_path_new_from_string(path_string);
	GtkTreeIter iter;
	GtkTreeIter iter_name;

	gchar *col_name;
	char new_ip[20];

	strcpy(new_ip, new_text);

	gint column =
	        GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cell), "column"));

	gtk_tree_model_get_iter(model, &iter, path);

	gtk_tree_model_get_iter(model, &iter_name, path);
	gtk_tree_model_get(model, &iter_name, 0, &col_name, -1);

	switch (column) {
	case COLUMN_VALUE:
	{
		uint i = 0, index_offset = 0;
		gchar *old_text;

		gtk_tree_model_get(model, &iter, column, &old_text, -1);

		if (0 == strcmp(col_name, pktgen_ethernet_fields[3]))
			if ((atoi(new_text) > 4096) || (atoi(new_text) < 1)) {
				GtkWidget *dialog;
				dialog =
				        gtk_message_dialog_new(GTK_WINDOW(stream_window),
				                               GTK_DIALOG_DESTROY_WITH_PARENT,
				                               GTK_MESSAGE_INFO,
				                               GTK_BUTTONS_OK,
				                               "Invalid VLAN Id! It should be [1-4095]");
				gtk_window_set_title(GTK_WINDOW(dialog), "Pktgen");
				gtk_dialog_run(GTK_DIALOG(dialog));
				gtk_widget_destroy(dialog);
				return;
			}

		if ((0 ==
		     strcmp(col_name,
		            pktgen_ipv4_fields[9])) ||
		    (0 == strcmp(col_name, pktgen_ipv4_fields[10])) )
			if (!validate_ip_address(new_ip)) {
				GtkWidget *dialog;
				dialog =
				        gtk_message_dialog_new(GTK_WINDOW(stream_window),
				                               GTK_DIALOG_DESTROY_WITH_PARENT,
				                               GTK_MESSAGE_INFO,
				                               GTK_BUTTONS_OK,
				                               "The given IP is not a valid IP address!");
				gtk_window_set_title(GTK_WINDOW(dialog), "Pktgen");
				gtk_dialog_run(GTK_DIALOG(dialog));
				gtk_widget_destroy(dialog);
				return;
			}

		/* Validate the MAC address */
		if ((0 ==
		     strcmp(col_name,
		            pktgen_ethernet_fields[0])) ||
		    (0 == strcmp(col_name, pktgen_ethernet_fields[1])) ) {
			if (12 == strlen(new_text)) {
				gchar *ch;
				for (i = 0; i < strlen(new_text); i++) {
					ch = (new_text + i);

					if ((*ch >= 'a' &&
					     *ch <= 'f') ||
					    (*ch >= 'A' &&
					     *ch <= 'F') ||
					    (*ch >= '0' && *ch <= '9'))
						continue;
					else {
						GtkWidget *dialog;
						dialog = gtk_message_dialog_new(
						                GTK_WINDOW(stream_window),
						                GTK_DIALOG_DESTROY_WITH_PARENT,
						                GTK_MESSAGE_INFO,
						                GTK_BUTTONS_OK,
						                "Please input only hex values[0-9][a-f], special characters are not allowed!");
						gtk_window_set_title(GTK_WINDOW(dialog),
						                     "Pktgen");
						gtk_dialog_run(GTK_DIALOG(dialog));
						gtk_widget_destroy(dialog);

						return;
					}
				}
			} else {
				GtkWidget *dialog;
				dialog =
				        gtk_message_dialog_new(GTK_WINDOW(stream_window),
				                               GTK_DIALOG_DESTROY_WITH_PARENT,
				                               GTK_MESSAGE_INFO,
				                               GTK_BUTTONS_OK,
				                               "Please input 6 bytes of MAC address in hex pattern [e.g. 012345abcdef]");
				gtk_window_set_title(GTK_WINDOW(dialog), "Pktgen");
				gtk_dialog_run(GTK_DIALOG(dialog));
				gtk_widget_destroy(dialog);

				return;
			}
		}
		if ((0 !=
		     strcmp(old_text,
		            "<auto>")) &&
		    (0 !=
		     strcmp(old_text,
		            "IPv4")) && (0 != strcmp(old_text, "UDP")) ) {
			g_free(old_text);

			i = gtk_tree_path_get_indices(path)[0];

			switch (gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)))
			{
			case 0:
				index_offset = 0;
				break;

			case 1:
				index_offset = 4;
				break;

			case 2:
				index_offset = 15;
				break;
			}

			g_free(g_array_index(packet_info, protocol,
			                     (i + index_offset)).value);
			g_array_index(packet_info, protocol,
			              (i + index_offset)).value = g_strdup(new_text);

			gtk_list_store_set(GTK_LIST_STORE(model), &iter, column,
			                   g_array_index(packet_info,
			                                 protocol,
			                                 (i + index_offset)).value, -1);
		} else {
			GtkWidget *dialog;
			dialog =
			        gtk_message_dialog_new(GTK_WINDOW(stream_window),
			                               GTK_DIALOG_DESTROY_WITH_PARENT,
			                               GTK_MESSAGE_INFO,
			                               GTK_BUTTONS_OK,
			                               "Auto generated values can not be modified!");
			gtk_window_set_title(GTK_WINDOW(dialog), "Pktgen");
			gtk_dialog_run(GTK_DIALOG(dialog));
			gtk_widget_destroy(dialog);
		}
	}
	break;
	}

	gtk_tree_path_free(path);
}
Пример #8
0
/**
* Рекция на измеенение содержимого ячейки, порога
*/
void  	 Amt::ViewSillsImpl::cell_edited (GtkCellRendererText *cell, const gchar *path_string, const gchar *new_text ){
	/*Проверим что изменяем пороги не в группе питающая*/
	const char *limitGroup = gtk_combo_box_get_active_text( GTK_COMBO_BOX(_in_combo) );
	if (checkNChSills( limitGroup ) ){
	    Amt::std_message_dialog(GTK_MESSAGE_ERROR, "Группа порогов не допускает изменения значений.");
	    return;
	}
	GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW(_in_list ));
	GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
	GtkTreeIter iter;
	gint column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column"));
	if (column == riku::LIMIT_MAX_FAULT || column == riku::LIMIT_MIN_FAULT || column == riku::LIMIT_ISOL_FAULT || column == riku::LIMIT_OFF )
	    if (strcmp("crtc", Amt::std_password_dialog("Для изменения данных, требуется пароль администратора") )){
		Amt::std_message_dialog(GTK_MESSAGE_ERROR, "Не верный пароль был введен.");
		return;
	    }
	gtk_tree_model_get_iter (model, &iter, path);
	switch(column){
	    case riku::LIMIT_MAX_FAULT:
	    case riku::LIMIT_MIN_FAULT:
	    case riku::LIMIT_MAX_PRE_FAULT:
	    case riku::LIMIT_MIN_PRE_FAULT:
	    case riku::LIMIT_OFF:
	    case riku::LIMIT_MAX_Y:
	    case riku::LIMIT_MIN_Y:
	    case riku::LIMIT_STEP_Y:
	    case riku::LIMIT_ISOL_FAULT:
	    case riku::LIMIT_ISOL_PRE_FAULT:{
    		gfloat old_val;
    		gtk_tree_model_get (model, &iter, column, &old_val, -1);
		gfloat new_val = atof( replaseDot(new_text));		
		if (old_val != new_val){		
		    gtk_tree_store_set (GTK_TREE_STORE(model), &iter, column, new_val, -1);
		    /*Если произведена установка величины для объекта Группа, то проинсталлировать туже величину во всех итераторах данной группы*/
		    gchar* name;
		    gtk_tree_model_get (model, &iter, riku::LIMIT_NAME, &name, -1);
		    if (!strcmp(name, viewSillsImplGroupTitle )){
			updateGroupsSillsIter(model, column, new_val );
	    	    }
		    else{
			updateObjSillsIter(model, &iter, column, new_val, "VAC" );
			updateLimitDataInStdItem(model, &iter, column, new_val);
		    }
		    /*Запишем обновленный порог в файл */
		    saveSillsInFile(getRikuReg().getStdManager()->getAttributeText("path") );
		    g_free (name);
		}
		break;
	    }
	    case riku::LIMIT_COMMENT:{
		gchar* old_text;
		gtk_tree_model_get (model, &iter, column, &old_text, -1);
		if (strcmp(old_text, new_text)){
		    gtk_tree_store_set (GTK_TREE_STORE(model), &iter, column, new_text, -1);
		    gchar* unit;
		    gtk_tree_model_get (model, &iter, riku::LIMIT_NAME, &unit, -1);
		    if (strcmp(unit, viewSillsImplGroupTitle)){
		    	riku::stdItem _stdItem;
			if (_in_manager->getItemByUnit(unit, _stdItem)){
			/*Обновим значение коменнтария*/
			    _stdItem.limits.comment = new_text;
			/*Установим новое описание объекта*/
			    _in_manager->setItemByUnit(unit, _stdItem);
			/*Запишем обновленный порог в файл */
			    saveSillsInFile(getRikuReg().getStdManager()->getAttributeText("path") );
			}
		    }
		}
		g_free (old_text);
		break;
	    }
	}
}
Пример #9
0
NedMidiRecordConfigDialog::NedMidiRecordConfigDialog(GtkWindow *parent, int num, int denom, int midi_pgm,
                        int tempo_inverse, int volume, bool triplet, bool f_piano, bool dnt_split, int keysig) :
m_num(num), m_denom(denom), m_pgm(midi_pgm), m_tempo_inverse(tempo_inverse), m_metro_volume(volume), m_triplet(triplet), m_f_piano(f_piano), m_dnt_split(dnt_split), m_keysig(keysig) {
	int i;
	GtkWidget *dialog;
	GtkWidget *time_signature_frame;
	GtkWidget *numerator_label;
	GtkWidget *denominator_label;
	GtkWidget *time_signature_vbox;
	GtkWidget *time_signature_upper_hbox;
	GtkWidget *time_signature_lower_hbox;
	GtkWidget *right_vbox;
	GtkWidget *instrument_scroll;
	GtkWidget *upper_hbox;
	GtkListStore *instrumend_list_store;
	GtkTreeIter iter;
	GtkCellRenderer *instrument_renderer;
	GtkTreeViewColumn *instrument_column;
	GtkTreeViewColumn *instrument_num_column;
	GtkTreePath* instrument_tree_path;
	GtkWidget *tempo_frame;
	GtkWidget *key_frame;
	GtkWidget *key_frame_left_vbox;
	GtkWidget *key_frame_right_vbox;
	GtkWidget *radio_hbox;
	GtkWidget *main_vbox;
	GtkWidget *metro_volume_frame;
	char Str[128];

	dialog = gtk_dialog_new_with_buttons(_("Config Record"), parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
		GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);

	g_signal_connect(dialog, "response", G_CALLBACK (OnClose), (void *) this);

	time_signature_frame = gtk_frame_new(_("time signature"));
	time_signature_vbox = gtk_vbox_new(FALSE, 5);
	time_signature_upper_hbox = gtk_hbox_new(FALSE, 5);
	time_signature_lower_hbox = gtk_hbox_new(FALSE, 5);
	numerator_label = gtk_label_new(_("Numerator:"));
	denominator_label = gtk_label_new(_("Denominator:"));
	m_numerator = gtk_spin_button_new_with_range (1.0, 20.0, 1.0);
	gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_numerator), m_num);
	m_denominator = gtk_combo_box_new_text();
	gtk_combo_box_append_text(GTK_COMBO_BOX(m_denominator), "2");
	gtk_combo_box_append_text(GTK_COMBO_BOX(m_denominator), "4");
	gtk_combo_box_append_text(GTK_COMBO_BOX(m_denominator), "8");
	gtk_combo_box_append_text(GTK_COMBO_BOX(m_denominator), "16");
	if (m_denom < 4) {
		gtk_combo_box_set_active(GTK_COMBO_BOX(m_denominator), 0);
	}
	else if (m_denom < 8) {
		gtk_combo_box_set_active(GTK_COMBO_BOX(m_denominator), 1);
	}
	else if (m_denom < 16) {
		gtk_combo_box_set_active(GTK_COMBO_BOX(m_denominator), 2);
	}
	else {
		gtk_combo_box_set_active(GTK_COMBO_BOX(m_denominator), 3);
	}
	gtk_box_pack_start (GTK_BOX (time_signature_upper_hbox), numerator_label, FALSE, FALSE, 0);
	gtk_box_pack_end (GTK_BOX (time_signature_upper_hbox), m_numerator, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (time_signature_lower_hbox), denominator_label, FALSE, FALSE, 0);
	gtk_box_pack_end (GTK_BOX (time_signature_lower_hbox), m_denominator, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (time_signature_vbox), time_signature_upper_hbox, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (time_signature_vbox), time_signature_lower_hbox, FALSE, FALSE, 0);
	gtk_container_add (GTK_CONTAINER(time_signature_frame), time_signature_vbox);

	m_with_triplet_button = gtk_toggle_button_new_with_label(_("triplet recognition"));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_with_triplet_button), m_triplet);
	m_force_piano_button = gtk_toggle_button_new_with_label(_("force piano"));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_force_piano_button), m_f_piano);
	m_dont_split_button = gtk_toggle_button_new_with_label(_("don't split tracks"));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_dont_split_button), m_dnt_split);
	if (m_dnt_split) {
		gtk_widget_set_sensitive(m_force_piano_button, FALSE);
	}
	else if (m_f_piano) {
		gtk_widget_set_sensitive(m_dont_split_button, FALSE);
	}
	g_signal_connect(m_force_piano_button, "toggled", G_CALLBACK (OnPianoForcePressed), (void *) this);
	g_signal_connect(m_dont_split_button, "toggled", G_CALLBACK (OnDontSplitPressed), (void *) this);

	right_vbox = gtk_vbox_new(FALSE, 5);
	gtk_box_pack_start (GTK_BOX(right_vbox), time_signature_frame, FALSE, FALSE, 0);

	gtk_box_pack_start (GTK_BOX(right_vbox), m_with_triplet_button, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX(right_vbox), m_force_piano_button, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX(right_vbox), m_dont_split_button, FALSE, FALSE, 0);

	instrumend_list_store = gtk_list_store_new (2, G_TYPE_INT, G_TYPE_STRING);

	for (i = 0; i < NedResource::getNumInstruments(); i++) {
		gtk_list_store_append (instrumend_list_store, &iter);
		gtk_list_store_set (instrumend_list_store, &iter, 0, i, 1, gettext(NedResource::GM_Instruments[i]), -1);
	}
	m_instrument_list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(instrumend_list_store));
	instrument_renderer = gtk_cell_renderer_text_new ();
	instrument_num_column = gtk_tree_view_column_new_with_attributes (_("no"), instrument_renderer, "text", 0, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (m_instrument_list), instrument_num_column);
	instrument_column = gtk_tree_view_column_new_with_attributes (_("instruments"), instrument_renderer, "text", 1, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (m_instrument_list), instrument_column);
	m_instrument_adjustment = gtk_adjustment_new (0.0, 0.0, NedResource::getNumInstruments(), 1.0,  10.0, 10.0);
	instrument_scroll = gtk_vscrollbar_new(GTK_ADJUSTMENT(m_instrument_adjustment));
	gtk_tree_view_set_vadjustment (GTK_TREE_VIEW (m_instrument_list), GTK_ADJUSTMENT(m_instrument_adjustment));
	gtk_widget_set_size_request(m_instrument_list, INSTRUMENTS_WIDGET_WIDTH, MIDI_RECORD_CONFIG_SHOW_WINDOW_HEIGHT);
	sprintf(Str, "%d", m_pgm);
	instrument_tree_path = gtk_tree_path_new_from_string(Str);
	gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW (m_instrument_list), instrument_tree_path, NULL, FALSE, 0.0, 0.0);
	gtk_tree_view_set_cursor(GTK_TREE_VIEW (m_instrument_list), instrument_tree_path, NULL, FALSE);
	g_signal_connect(dialog, "scroll-event", G_CALLBACK (OnScroll), (void *) this);

	tempo_frame = gtk_frame_new(_("tempo"));
	m_tempo_scale = gtk_vscale_new_with_range(0.1 * 60.0, 2.4 * 60.0, 0.4 * 60.0);
	gtk_range_set_inverted(GTK_RANGE(m_tempo_scale), TRUE);
	gtk_range_set_value(GTK_RANGE(m_tempo_scale), 60.0 * (double) m_tempo_inverse / 100000.0);
	gtk_container_add (GTK_CONTAINER(tempo_frame), m_tempo_scale);

	metro_volume_frame = gtk_frame_new(_("volume"));
	m_metro_volume_scale = gtk_vscale_new_with_range(0.0, 127.0, 1.0);
	gtk_range_set_inverted(GTK_RANGE(m_metro_volume_scale), TRUE);
	gtk_range_set_value(GTK_RANGE(m_metro_volume_scale), m_metro_volume);
	gtk_container_add (GTK_CONTAINER(metro_volume_frame), m_metro_volume_scale);


	key_frame = gtk_frame_new(_("key"));
	radio_hbox = gtk_hbox_new(FALSE, 2);
	key_frame_left_vbox = gtk_vbox_new(FALSE, 2);
	key_frame_right_vbox = gtk_vbox_new(FALSE, 2);
	m_sig_radio_buttons[0] =  gtk_radio_button_new_with_label (NULL, gettext(NedStaffContextDialog::m_keyTab[0]));
	gtk_box_pack_start (GTK_BOX (key_frame_left_vbox),  m_sig_radio_buttons[0], FALSE, FALSE, 0);
	for (i = -5; i < 7; i++) {
		m_sig_radio_buttons[i+6] = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (m_sig_radio_buttons[0]), gettext(NedStaffContextDialog::m_keyTab[i+6]));
		if (i < 0) {
			gtk_box_pack_start (GTK_BOX (key_frame_left_vbox), m_sig_radio_buttons[i+6], FALSE, FALSE, 0);
		}
		else {
			gtk_box_pack_start (GTK_BOX (key_frame_right_vbox), m_sig_radio_buttons[i+6], FALSE, FALSE, 0);
		}
	}
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (m_sig_radio_buttons[keysig+6]), TRUE);
	gtk_box_pack_start (GTK_BOX (radio_hbox), key_frame_left_vbox,  FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (radio_hbox), key_frame_right_vbox,  FALSE, FALSE, 0);
	gtk_container_add (GTK_CONTAINER(key_frame), radio_hbox);

	upper_hbox = gtk_hbox_new(FALSE, 5);

	gtk_box_pack_start (GTK_BOX(upper_hbox), m_instrument_list, TRUE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX(upper_hbox), instrument_scroll, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX(upper_hbox), right_vbox, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX(upper_hbox), tempo_frame, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX(upper_hbox), metro_volume_frame, FALSE, FALSE, 0);

	main_vbox = gtk_vbox_new(FALSE, 5);
	gtk_box_pack_start (GTK_BOX(main_vbox), upper_hbox, TRUE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX(main_vbox), key_frame, FALSE, FALSE, 0);

	gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), main_vbox);
	gtk_widget_show_all (dialog);
	gtk_dialog_run(GTK_DIALOG(dialog));

}
Пример #10
0
 TreePath::TreePath(const char *path) : TreePath(gtk_tree_path_new_from_string(path))
 {}
Пример #11
0
void u_cell_edited (GtkCellRendererText *cell, 
    const gchar *path_string, const gchar *new_text,
    gpointer data) {

  GtkTreeModel *model = (GtkTreeModel *)data;
  GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
  GtkTreeIter iter;
  UsersItem *u;

  gint column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column"));

  gtk_tree_model_get_iter (model, &iter, path);
  int i = gtk_tree_path_get_indices (path)[0];
  


  switch (column) {
    case UNAME_COL: {
                     char *old_text;
                     gtk_tree_model_get (model, &iter, column, &old_text, -1);
                     if (old_text != NULL)
                       g_free (old_text);
                     g_print (gtk_tree_path_to_string (path));
                     gtk_list_store_set (GTK_LIST_STORE (model), &iter, column, new_text, -1);
                     g_print ("Changed to: %s\n", new_text);

                     break;
                   }
    case UFULLNAME_COL: {
                    char *old_text;
                     gtk_tree_model_get (model, &iter, column, &old_text, -1);
                     if (old_text != NULL)
                       g_free (old_text);
                     gtk_tree_path_get_indices (path)[0];
                     gtk_list_store_set (GTK_LIST_STORE (model), &iter, column, new_text, -1);
                     g_print ("Changed to: %s\n", new_text);
                     break;
    }
    case UHOMEPATH_COL: {


                    char *old_text;
                     gtk_tree_model_get (model, &iter, column, &old_text, -1);
                     if (old_text != NULL)
                       g_free (old_text);
                     gtk_tree_path_get_indices (path)[0];
                     gtk_list_store_set (GTK_LIST_STORE (model), &iter, column, new_text, -1);
                     g_print ("Changed to: %s\n", new_text);
                     break;
    }
    case USHELL_COL: {
                     char *old_text;
                     if (old_text !=NULL) 
                       gtk_tree_model_get (model, &iter, column, &old_text, -1);
                       g_free (old_text);
                     gtk_list_store_set (GTK_LIST_STORE (model), &iter, column, new_text, -1);
                     g_print ("Changed to: %s\n", new_text);
                     }
  }



}
Пример #12
0
void usldoks_create_list (class usldoks_data *data)
{
class iceb_gdite_data gdite;
iceb_gdite(&gdite,0,data->window);

GtkListStore *model=NULL;
GtkTreeIter iter;
SQLCURSOR cur;
SQLCURSOR cur1;
char strsql[512];
char bros[500];
int  kolstr=0;
SQL_str row;
iceb_u_str zagolov;

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(usldoks_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(usldoks_vibor),data);

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


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

sprintf(bros,"tp,datd,podr,kontr,nomd,nomnn,kodop,pod,pro,ktoi,nomdp,vrem,dover,nds,sumkor,sumnds,pn,mo from Usldokum");

sprintf(strsql,"select %s where datd >= '%d-01-01' order by datd asc",
bros,data->gn);

if(data->dn != 0)
  sprintf(strsql,"select %s where datd >= '%d-%02d-%02d' order by datd asc",
  bros,data->gn,data->mn,data->dn);

if(data->dn != 0 && data->dk != 0)
  sprintf(strsql,"select %s where datd >= '%d-%02d-%02d' and datd <= '%d-%02d-%02d' \
order by datd asc",bros,data->gn,data->mn,data->dn,data->gk,data->mk,data->dk);

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;

float kolstr1=0.;
while(cur.read_cursor(&row) != 0)
 {
  iceb_pbar(gdite.bar,kolstr,++kolstr1);
//  printf("%s %s %s %s\n",row[0],row[1],row[2],row[3]);
  
   if(usldoks_prov_row(row,data) != 0)
    continue;

  //Метка записи
  ss[COL_METKAZ].new_plus("");
  if(row[0][0] == '1')
   ss[COL_METKAZ].new_plus("+");
  else
   ss[COL_METKAZ].new_plus("-");

  if(row[7][0] == '0')
   ss[COL_METKAZ].plus("?");
  if(row[8][0] == '0')
   ss[COL_METKAZ].plus("*");
  if(row[17][0] == '0')
   ss[COL_METKAZ].plus("$");

  //Дата документа
  ss[COL_DATAD].new_plus(iceb_u_sqldata(row[1]));
  
  //Номер документа
  ss[COL_NOMDOK].new_plus(iceb_u_toutf(row[4]));

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

  //Код операции
  ss[COL_KODOP].new_plus(iceb_u_toutf(row[6]));

  //код подразделения
  ss[COL_PODR].new_plus(iceb_u_toutf(row[2]));

  //Номер налоговой накладной
  ss[COL_NOMNALNAK].new_plus(iceb_u_toutf(row[5]));

  //Номер накладной парного документа
  ss[COL_NOMPD].new_plus(iceb_u_toutf(row[10]));

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

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

  
  gtk_list_store_append (model, &iter);

  gtk_list_store_set (model, &iter,
  COL_METKAZ,ss[COL_METKAZ].ravno(),
  COL_DATAD,ss[COL_DATAD].ravno(),
  COL_NOMDOK,ss[COL_NOMDOK].ravno(),
  COL_KONTR,ss[COL_KONTR].ravno(),
  COL_KODOP,ss[COL_KODOP].ravno(),
  COL_PODR,ss[COL_PODR].ravno(),
  COL_NOMNALNAK,ss[COL_NOMNALNAK].ravno(),
  COL_NOMPD,ss[COL_NOMPD].ravno(),
  COL_DATA_VREM,ss[COL_DATA_VREM].ravno(),
  COL_KTO,ss[COL_KTO].ravno(),
  NUM_COLUMNS,data->kolzap,
  -1);

  data->kolzap++;
 }

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

g_object_unref (GTK_TREE_MODEL (model));

usldoks_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[SFK3]),FALSE);//Недоступна
  gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[FK5]),FALSE);//Недоступна
  gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[FK6]),FALSE);//Недоступна
 }
else
 {
  gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[SFK2]),TRUE);//Доступна
  gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[SFK3]),TRUE);//Доступна
  gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[FK5]),TRUE);//Доступна
  gtk_widget_set_sensitive(GTK_WIDGET(data->knopka[FK6]),TRUE);//Доступна
 }

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

if(data->kolzap > 0)
 {
  if(data->snanomer  > data->kolzap-1)
     data->snanomer= data->kolzap-1;
  if(data->snanomer  < 0)
     data->snanomer=0;
      
  printf("poz=%d\n",data->snanomer);

  sprintf(strsql,"%d",data->snanomer);
  GtkTreePath *path=gtk_tree_path_new_from_string(strsql);

//  gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW (data->treeview),path,NULL,TRUE,0,0);
  gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW (data->treeview),path,NULL,FALSE,0,0);

  gtk_tree_view_set_cursor(GTK_TREE_VIEW (data->treeview),path,NULL,FALSE);
  gtk_tree_path_free(path);
//  data->snanomer=-2;
 }

iceb_u_str strpoi;  
strpoi.plus("");

if(data->poi.metka_pros == 1)
 strpoi.new_plus(gettext("Просмотр только неподтверждённых документов"));
if(data->poi.metka_pros == 2)
 strpoi.new_plus(gettext("Просмотр только документов без проводок"));
 
if(data->poi.metka_poi == 1 || data->poi.metka_opl != 0)
 {

// printf("Формирование заголовка с реквизитами поиска.\n");
  if(data->poi.metka_pros != 0)      
   strpoi.ps_plus(gettext("Поиск"));
  else
   strpoi.new_plus(gettext("Поиск"));
  strpoi.plus(" !!!");

  iceb_str_poisk(&strpoi,data->poi.nomdok.ravno(),gettext("Номер документа"));
  iceb_str_poisk(&strpoi,data->poi.datan.ravno(),gettext("Дата начала"));
  iceb_str_poisk(&strpoi,data->poi.datak.ravno(),gettext("Дата конца"));
  iceb_str_poisk(&strpoi,data->poi.kontr.ravno(),gettext("Код контрагента"));
  iceb_str_poisk(&strpoi,data->poi.naim_kontr.ravno(),gettext("Наименование контрагента"));
  iceb_str_poisk(&strpoi,data->poi.kodop.ravno(),gettext("Код операции"));
  iceb_str_poisk(&strpoi,data->poi.kodpod.ravno(),gettext("Код подразделения"));
  iceb_str_poisk(&strpoi,data->poi.nalnak.ravno(),gettext("Номер налоговой накладной"));
  iceb_str_poisk(&strpoi,data->poi.dover.ravno(),gettext("Доверенность"));

  if(data->poi.pr_ras.ravno_pr() == 1)
    strpoi.ps_plus(gettext("Только приходы"));
  if(data->poi.pr_ras.ravno_pr() == 2)
    strpoi.ps_plus(gettext("Только расходы"));
    
  if(data->poi.metka_opl == 1)
   strpoi.ps_plus(gettext("Только оплаченные"));
  if(data->poi.metka_opl == 2)
   strpoi.ps_plus(gettext("Только неоплаченные"));
 }

if(strpoi.getdlinna() > 1)
 {
  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
prepare_list (AppearanceData *data, GtkWidget *list, ThemeType type, GCallback callback)
{
  GtkListStore *store;
  GList *l, *themes = NULL;
  GtkCellRenderer *renderer;
  GtkTreeViewColumn *column;
  GtkTreeModel *sort_model;
  GdkPixbuf *thumbnail;
  const gchar *key;
  ThumbnailGenFunc generator;
  ThemeThumbnailFunc thumb_cb;
  ThemeConvData *conv_data;
  GSettings *settings;

  switch (type)
  {
    case THEME_TYPE_GTK:
      themes = mate_theme_info_find_by_type (MATE_THEME_GTK_2);
      thumbnail = data->gtk_theme_icon;
      settings = data->interface_settings;
      key = GTK_THEME_KEY;
      generator = (ThumbnailGenFunc) generate_gtk_theme_thumbnail_async;
      thumb_cb = (ThemeThumbnailFunc) gtk_theme_thumbnail_cb;
      break;

    case THEME_TYPE_WINDOW:
      themes = mate_theme_info_find_by_type (MATE_THEME_MARCO);
      thumbnail = data->window_theme_icon;
      settings = data->marco_settings;
      key = MARCO_THEME_KEY;
      generator = (ThumbnailGenFunc) generate_marco_theme_thumbnail_async;
      thumb_cb = (ThemeThumbnailFunc) marco_theme_thumbnail_cb;
      break;

    case THEME_TYPE_ICON:
      themes = mate_theme_icon_info_find_all ();
      thumbnail = data->icon_theme_icon;
      settings = data->interface_settings;
      key = ICON_THEME_KEY;
      generator = (ThumbnailGenFunc) generate_icon_theme_thumbnail_async;
      thumb_cb = (ThemeThumbnailFunc) icon_theme_thumbnail_cb;
      break;

    case THEME_TYPE_CURSOR:
      themes = mate_theme_cursor_info_find_all ();
      thumbnail = NULL;
      settings = data->mouse_settings;
      key = CURSOR_THEME_KEY;
      generator = NULL;
      thumb_cb = NULL;
      break;

    default:
      /* we don't deal with any other type of themes here */
      return;
  }

  store = gtk_list_store_new (NUM_COLS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);

  for (l = themes; l; l = g_list_next (l))
  {
    MateThemeCommonInfo *theme = (MateThemeCommonInfo *) l->data;
    GtkTreeIter i;

    if (type == THEME_TYPE_CURSOR) {
      thumbnail = ((MateThemeCursorInfo *) theme)->thumbnail;
    } else {
      generator (theme, thumb_cb, data, NULL);
    }

    gtk_list_store_insert_with_values (store, &i, 0,
                                       COL_LABEL, theme->readable_name,
                                       COL_NAME, theme->name,
                                       COL_THUMBNAIL, thumbnail,
                                       -1);

    if (type == THEME_TYPE_CURSOR && thumbnail) {
      g_object_unref (thumbnail);
      thumbnail = NULL;
    }
  }
  g_list_free (themes);

  sort_model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (store));
  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model),
                                        COL_LABEL, GTK_SORT_ASCENDING);

  if (type == THEME_TYPE_CURSOR)
    gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (sort_model), COL_LABEL,
                                     (GtkTreeIterCompareFunc) cursor_theme_sort_func,
                                     NULL, NULL);

  gtk_tree_view_set_model (GTK_TREE_VIEW (list), GTK_TREE_MODEL (sort_model));

  renderer = gtk_cell_renderer_pixbuf_new ();
  g_object_set (renderer, "xpad", 3, "ypad", 3, NULL);

  column = gtk_tree_view_column_new ();
  gtk_tree_view_column_pack_start (column, renderer, FALSE);
  gtk_tree_view_column_add_attribute (column, renderer, "pixbuf", COL_THUMBNAIL);
  gtk_tree_view_append_column (GTK_TREE_VIEW (list), column);

  renderer = gtk_cell_renderer_text_new ();

  column = gtk_tree_view_column_new ();
  gtk_tree_view_column_pack_start (column, renderer, FALSE);
  gtk_tree_view_column_add_attribute (column, renderer, "text", COL_LABEL);
  gtk_tree_view_append_column (GTK_TREE_VIEW (list), column);

  conv_data = g_new (ThemeConvData, 1);
  conv_data->data = data;
  conv_data->thumbnail = thumbnail;
  
  /* set useful data for callbacks */
  g_object_set_data (G_OBJECT (list), THEME_DATA, conv_data);
  g_object_set_data (G_OBJECT (list), GSETTINGS_SETTINGS, settings);
  g_object_set_data (G_OBJECT (list), GSETTINGS_KEY, g_strdup(key));
  
  /* select in treeview the theme set in gsettings */
  GtkTreeModel *treemodel;
  treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (list));
  gchar *theme = g_settings_get_string (settings, key);
  gchar *path = find_string_in_model (treemodel, theme, COL_NAME);
  if (path)
  {
    GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (list));
    GtkTreePath *treepath = gtk_tree_path_new_from_string (path);
    gtk_tree_selection_select_path (selection, treepath);
    gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (list), treepath, NULL, FALSE, 0, 0);
    gtk_tree_path_free (treepath);
    g_free (path);
  }
  if (theme)
    g_free (theme);
  
  /* connect to gsettings change event */
  gchar *signal_name = g_strdup_printf("changed::%s", key);
  g_signal_connect (settings, signal_name,
      G_CALLBACK (treeview_gsettings_changed_callback), list);
  g_free (signal_name);

  /* connect to treeview change event */
  g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (list)),
      "changed", G_CALLBACK (treeview_selection_changed_callback), list);
}
Пример #14
0
/* 
 * watch expression has been changed
 */
static void on_watch_changed(GtkCellRendererText *renderer, gchar *path, gchar *new_text, gpointer user_data)
{
	/* get iterator to the changed row */
	GtkTreeIter  iter;
	GtkTreePath *tree_path = gtk_tree_path_new_from_string (path);
	gtk_tree_model_get_iter (
		 gtk_tree_view_get_model(GTK_TREE_VIEW(wtree)),
		 &iter,
		 tree_path);
	
	/* get oldvalue */
	gchar* oldvalue;
	gtk_tree_model_get (
		wmodel,
		&iter,
		W_NAME, &oldvalue,
       -1);
	gchar *internal = NULL;
		gtk_tree_model_get (
		wmodel,
		&iter,
		W_INTERNAL, &internal,
		-1);

	/* check if it is empty row */
	gboolean is_empty_row = !gtk_tree_path_compare (tree_path, wtree_empty_path());

   	gchar *striped = g_strstrip(g_strdup(new_text));
	if (!strlen(striped) &&
		!is_empty_row &&
		dialogs_show_question(_("Delete variable?")))
	{
		/* if new value is empty string on non-empty row
		 * offer to delete watch */
		gtk_tree_store_remove(wstore, &iter);
		if (DBS_STOPPED == debug_state)
			active_module->remove_watch(internal);

		config_set_debug_changed();
	}
	else if (strcmp(oldvalue, striped))
    {
		/* new value is non empty */

		/* insert new row if changing was the last empty row */
		GtkTreeIter newiter;
		if (is_empty_row)
			gtk_tree_store_insert_before(wstore, &newiter, NULL, &iter);
		
		/* set expression */
		variable_set_name_only(wstore, is_empty_row ? &newiter : &iter, striped);

		/* if debug is active - remove old watch and add new one */
		if (DBS_STOPPED == debug_state)
		{
			active_module->remove_watch(internal);
			variable *newvar = active_module->add_watch(striped);
			change_watch(GTK_TREE_VIEW(wtree), is_empty_row ? &newiter : &iter, newvar);
		}
		
		/* if new watch has been added - set selection to the new created row */
		if (is_empty_row)
		{
			GtkTreePath *_path = gtk_tree_model_get_path(wmodel, &newiter);
			GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(wtree));
			gtk_tree_selection_unselect_all(selection);
			gtk_tree_selection_select_path(selection, _path);
			gtk_tree_path_free(_path);
		}

		config_set_debug_changed();
	}
	
	/* free resources */
	gtk_tree_path_free(tree_path);
	g_free(oldvalue);
	g_free(internal);
	g_free(striped);
}
Пример #15
0
static void
accel_edited_callback (GtkCellRendererAccel *cell,
                       gchar                *path_string,
                       guint                 keyval,
                       GdkModifierType       mask,
                       guint                 hardware_keycode,
                       GtkTreeView          *view)
{
	GtkTreeModel *model;
	GtkTreePath *path;
	GtkTreeIter iter;
	KeyEntry *ke;
	GtkAccelGroupEntry *entries;
	guint n_entries;
	char *str;

	model = gtk_tree_view_get_model (view);

	path = gtk_tree_path_new_from_string (path_string);
	if (!path)
		return;

	if (!gtk_tree_model_get_iter (model, &iter, path))
	{
		gtk_tree_path_free (path);
		return;
	}
	gtk_tree_path_free (path);

	gtk_tree_model_get (model, &iter, KEYVAL_COLUMN, &ke, -1);

	/* sanity check */
	if (ke == NULL)
		return;

	/* Check if we already have an entry using this accel */
	entries = gtk_accel_group_query (notification_group, keyval, mask, &n_entries);
	if (n_entries > 0)
	{
		if (entries[0].accel_path_quark != g_quark_from_string (ke->accel_path))
		{
			GtkWidget *dialog;
			char *name;
			KeyEntry *other_key;

			name = gtk_accelerator_get_label (keyval, mask);
			other_key = entries[0].closure->data;
			g_assert (other_key);

			dialog =
			    gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))),
			                            GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
			                            GTK_MESSAGE_WARNING,
			                            GTK_BUTTONS_OK,
			                            _("The shortcut key “%s” is already bound to the “%s” action"),
			                            name,

other_key->user_visible_name ? _(other_key->user_visible_name) : other_key->gsettings_key);
			g_free (name);

			g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
			gtk_window_present (GTK_WINDOW (dialog));
		}

		return;
	}

	str = binding_name (keyval, mask);

	_terminal_debug_print (TERMINAL_DEBUG_ACCELS,
	                       "Edited path %s keyval %s, setting GSettings to %s\n",
	                       ke->accel_path,
	                       gdk_keyval_name (keyval) ? gdk_keyval_name (keyval) : "null",
	                       str);
#ifdef MATE_ENABLE_DEBUG
	_TERMINAL_DEBUG_IF (TERMINAL_DEBUG_ACCELS)
	{
		GtkAccelKey old_key;

		if (gtk_accel_map_lookup_entry (ke->accel_path, &old_key))
		{
			_terminal_debug_print (TERMINAL_DEBUG_ACCELS,
			                       "  Old entry of path %s is keyval %s mask %x\n",
			                       ke->accel_path, gdk_keyval_name (old_key.accel_key), old_key.accel_mods);
		}
		else
		{
			_terminal_debug_print (TERMINAL_DEBUG_ACCELS,
			                       "  Failed to look up the old entry of path %s\n",
			                       ke->accel_path);
		}
	}
#endif

	g_settings_set_string (settings_keybindings,
	                       ke->gsettings_key,
	                       str);
	g_free (str);
}
Пример #16
0
static void
on_handler_edited (GtkCellRendererText *renderer,
                   gchar *path,
                   gchar *handler,
                   gpointer user_data)
{
  GladeSignalEditor *self = GLADE_SIGNAL_EDITOR (user_data);
  GtkTreePath *tree_path = gtk_tree_path_new_from_string (path);
  GtkTreeIter iter;
  gchar *old_handler;
  GladeSignal *signal;
  gboolean dummy;

  g_return_if_fail (self->priv->widget != NULL);
	
  gtk_tree_model_get_iter (self->priv->model,
			   &iter,
			   tree_path);

  gtk_tree_model_get (self->priv->model, &iter,
		      GLADE_SIGNAL_COLUMN_HANDLER, &old_handler, 
		      GLADE_SIGNAL_COLUMN_SIGNAL, &signal, -1);

  dummy = glade_signal_is_dummy (signal);
	
  /* False alarm ? */
  if (handler && !g_str_equal (old_handler, handler))
    {
      if (!dummy)
	{
	  if (strlen (handler))
	    {
	      /* change an existing signal handler */
	      GladeSignal *old_signal;
	      GladeSignal *new_signal;
				
	      gtk_tree_model_get (self->priv->model,
				  &iter,
				  GLADE_SIGNAL_COLUMN_SIGNAL,
				  &old_signal, -1);

	      new_signal = glade_signal_clone (old_signal);

	      /* Change the new signal handler */
	      glade_signal_set_handler (new_signal, handler);

	      glade_command_change_signal (self->priv->widget, old_signal, new_signal);

              g_object_unref (old_signal);
	      g_object_unref (new_signal);
	    }
	  else
	    {
	      GladeSignal *deleted_signal;
	      gtk_tree_model_get (self->priv->model,
				  &iter,
				  GLADE_SIGNAL_COLUMN_SIGNAL,
				  &deleted_signal, -1);
				
				
	      /* Delete signal */
	      glade_command_remove_signal (self->priv->widget, deleted_signal);
	    }
	}
      else if (strlen (handler))
	{
	  GladeSignal *new_signal;
			
	  /* Get the signal name */
	  gtk_tree_model_get (self->priv->model, &iter,
			      GLADE_SIGNAL_COLUMN_SIGNAL, &signal,
			      -1);
			
	  /* Add a new signal handler */
	  new_signal = glade_signal_new (glade_signal_get_class (signal),
                                         handler, NULL, FALSE, FALSE);
          glade_signal_set_detail (new_signal, glade_signal_get_detail (signal));
	  glade_command_add_signal (self->priv->widget, new_signal);
          glade_signal_set_detail (signal, NULL);
	  g_object_unref (new_signal);

          glade_signal_editor_take_target_focus_path (self, tree_path);
          /* make sure we do not free the path here as
           * glade_signal_editor_take_target_focus_path() takes ownership
           **/
          tree_path = NULL;
	}
    }

  g_object_unref (signal);
  g_free (old_handler);
  gtk_tree_path_free (tree_path);
}
Пример #17
0
enum {
  VISIBLE_COLUMN,
  TITLE_COLUMN,
  FORMAT_COLUMN,
  DATA_COLUMN,
  N_COLUMN /* The number of columns */
};

/* Visible toggled */
static void
visible_toggled(GtkCellRendererToggle *cell _U_, gchar *path_str, gpointer data)
{
  GtkTreeModel    *model = (GtkTreeModel *)data;
  GtkTreeIter      iter;
  GtkTreePath     *path = gtk_tree_path_new_from_string(path_str);
  GList           *clp;
  fmt_data        *cfmt;

  gtk_tree_model_get_iter(model, &iter, path);
  gtk_tree_model_get(model, &iter, DATA_COLUMN, &clp, -1);

  cfmt = (fmt_data *) clp->data;
  if (cfmt->visible)
    cfmt->visible = FALSE;
  else
    cfmt->visible = TRUE;

  gtk_list_store_set(GTK_LIST_STORE(model), &iter, VISIBLE_COLUMN, cfmt->visible, -1);
  cfile.cinfo.columns_changed = TRUE;
Пример #18
0
void loadKeymap(GtkListStore *model) {
	DIR *kbdir = NULL;
	struct dirent *entry;
	GtkTreeIter iter;
	gint count = 0;
	GtkTreePath *path;
	gint ipath = 0, ipath_en = 1;

	/* fill the list */
	kbdir = opendir(KBPATH);
	if(kbdir == NULL) {
//		gnome_warning_dialog(g_strdup_printf(
//			_("Unable to find keyboad definitions: %s"),
//			KBPATH));
		l_message_dialog(GTK_MESSAGE_WARNING, 
		                 g_strdup_printf(_("Unable to find keyboad definitions: %s"),
		                                 KBPATH));
	}

	if(kbdir != NULL) {
		while((entry = readdir(kbdir)) != NULL) {
			if(entry->d_name[0] == '.')
				continue;
			if(!l_strcasecmp(entry->d_name, "common"))
				continue;
			if(!l_strcasecmp(entry->d_name, "modifiers"))
				continue;

			gtk_list_store_append(GTK_LIST_STORE(model), &iter);
			gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0,
				g_strdup(g_ascii_strup(entry->d_name, -1)), -1);

			count++;

			if(SHASH("keymap") != NULL) {
				if(!l_strcasecmp(SHASH("keymap"), entry->d_name))
					ipath = count;
			}
			if(!l_strcasecmp("EN", entry->d_name))
				ipath_en = count;
		}
	}

	if(kbdir != NULL)
		closedir(kbdir);

	if(count <= 0) {
		g_warning(_("Unable to find keyboad definitions: %s"),
			KBPATH);
		gtk_list_store_append(GTK_LIST_STORE(model), &iter);
		gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0,
			g_strdup("EN"), -1);
	}

	if(SHASH("keymap") != NULL) {
		path = gtk_tree_path_new_from_string(
			g_strdup_printf("%d", (ipath > 0) ? ipath-1 : ipath_en-1));
		if(path != NULL) {
			gtk_tree_view_set_cursor(GTK_TREE_VIEW(tree_keymap),
				path, NULL, FALSE);
		}
	} else {
		path = gtk_tree_path_new_from_string(
			g_strdup_printf("%d", ipath_en-1));
		if(path != NULL) {
			gtk_tree_view_set_cursor(GTK_TREE_VIEW(tree_keymap),
				path, NULL, FALSE);
		}
	}

	return;
}
Пример #19
0
/******************************************************************************
* gtk_ListStoreSetValue(list,path_string,  ncol, val)
******************************************************************************/
int
clip_GTK_LISTSTORESETVALUE(ClipMachine * cm)
{
	C_object *cslist = _fetch_co_arg(cm);
        gchar      *path = _clip_parc(cm, 2);
        gint	  column = _clip_parni(cm, 3);
	ClipVar     *val = _clip_par(cm, 4);;
	GtkTreeIter iter;
        ClipArrVar *utypes;
	GValue value;
        C_object *cobj;
	gchar *str;
	int j, n;
	double d;

        CHECKARG2(1, MAP_t, NUMERIC_t);CHECKCOBJ(cslist, GTK_IS_LIST_STORE(cslist->object));
        CHECKARG(2, CHARACTER_t);
        CHECKARG(3, NUMERIC_t);

	gtk_tree_model_get_iter(GTK_TREE_MODEL(GTK_LIST_STORE(cslist->object)),
        	&iter, gtk_tree_path_new_from_string(path));

        utypes = (ClipArrVar *)_clip_vptr(_clip_mget(cm, &cslist->obj, HASH_UTYPES));
	column --;

	memset(&value, 0, sizeof(value));
	switch ((int)utypes->items[column].n.d)
	{
	case TREE_TYPE_NUMERIC:
		g_value_init(&value, G_TYPE_INT);
		if (val->t.type == NUMERIC_t)
			g_value_set_int(&value, (int)val->n.d);
		else
		{
			n = _clip_strtod(val->s.str.buf, &j);
			g_value_set_int(&value, n);
		}
		break;
	case TREE_TYPE_NUMERIC_FLOAT:
		g_value_init(&value, G_TYPE_FLOAT);
		if (val->t.type == NUMERIC_t)
			g_value_set_float(&value, val->n.d);
		else
		{
			d = _clip_strtod(val->s.str.buf, &j);
			g_value_set_float(&value, d);
		}
		break;
	case TREE_TYPE_STRING:
		str = val->s.str.buf;
		LOCALE_TO_UTF(str);
		g_value_init(&value,  G_TYPE_STRING);
		g_value_set_string(&value, str);
		FREE_TEXT(str);
		break;
	case TREE_TYPE_LOGICAL:
		g_value_init(&value,  G_TYPE_BOOLEAN);
		g_value_set_boolean(&value, val->l.val);
		break;
	case TREE_TYPE_PIXBUF:
		g_value_init(&value,  GDK_TYPE_PIXBUF);
	        cobj = _fetch_cobject(cm, val);
	        g_value_set_object(&value, cobj->object);
		break;
	case TREE_TYPE_DATE:
		g_value_init(&value,  G_TYPE_STRING);
		if (val->t.type == DATE_t)
			str = _clip_date_to_str(val->lv.l, cm->date_format);
		else
			str = _clip_date_to_str(_clip_str_to_date(val->s.str.buf, cm->date_format, cm->epoch), cm->date_format);
		g_value_set_string(&value, str);
		break;
	}
	gtk_list_store_set_value(GTK_LIST_STORE(cslist->object), &iter, column, &value);

	return 0;
err:
	return 1;
}
Пример #20
0
/*
 * env tree view value changed handler 
 */
static void on_value_changed(GtkCellRendererText *renderer, gchar *path, gchar *new_text, gpointer user_data)
{
	gchar *striped;
	GtkTreeIter  iter;
	GtkTreePath *tree_path = gtk_tree_path_new_from_string (path);
	GtkTreePath *empty_path = gtk_tree_row_reference_get_path(empty_row);
	gboolean empty = !gtk_tree_path_compare(tree_path, empty_path);
	gtk_tree_path_free(empty_path);

	gtk_tree_model_get_iter (
		 model,
		 &iter,
		 tree_path);
	
	striped = g_strstrip(g_strdup(new_text));
	if (!strlen(striped))
	{
		/* if new value is empty string, if it's a new row - do nothig
		 otheerwise - offer to delete a variable */
		if (empty)
			gtk_list_store_set(store, &iter, NAME, "", -1);
		else
		{
			if (dialogs_show_question(_("Delete variable?")))
			{
				delete_selected_rows();
				config_set_debug_changed();

				gtk_widget_grab_focus(tree);
			}
		}
	}
	else
	{
		/* if old variable - change value, otherwise - add another empty row below */
		gchar* oldvalue;
		gtk_tree_model_get (
			model,
			&iter,
			VALUE, &oldvalue,
		   -1);

		if (strcmp(oldvalue, striped))
		{
			gtk_list_store_set(store, &iter, VALUE, striped, -1);
			if (empty)
				add_empty_row();
			
			g_object_set (renderer_value, "editable", FALSE, NULL);
			config_set_debug_changed();
		}
		
		g_free(oldvalue);
	}
	
	if (empty)
		entering_new_var = FALSE;

	gtk_tree_path_free(tree_path);
	g_free(striped);

	gtk_tree_path_free(being_edited_value);
}
Пример #21
0
static void fx_many_item_toggled(GtkCellRendererToggle *UNUSED(cell)
		, char* path_str , gpointer data)
{
	FxMany* fxmany = (FxMany*)data;
	GtkTreeView* tree = GTK_TREE_VIEW(fxmany->tree);
	GtkTreeModel* model = gtk_tree_view_get_model(tree);
	GtkTreeView* ctree = GTK_TREE_VIEW(fxmany->selected);
	GtkTreeModel* cmodel = gtk_tree_view_get_model(ctree);
	GtkTreePath* path = gtk_tree_path_new_from_string(path_str);
	GtkTreeIter iter;
	gboolean checked , checked1;
	char* name;
	char* sipuri;
	char* uri;
	char labeltext[128];
	GdkPixbuf* pb;

	GtkTreeIter cIter;
	GtkTreeIter childiter;

	gtk_tree_model_get_iter(model , &iter , path);
	gtk_tree_model_get(model , &iter
					 , S_SIPURI_COL , &sipuri
					 , S_CHECK_COL  , &checked
					 , -1);
	checked ^= 1;

	if(checked)
	{
		if(gtk_tree_path_get_depth(path) > 1){
			gtk_tree_model_get(model , &iter
							 , S_NAME_COL   , &name
							 , S_PIXBUF_COL , &pb
							 , -1);
			gtk_tree_store_append(GTK_TREE_STORE(cmodel) , &cIter , NULL);
			gtk_tree_store_set(GTK_TREE_STORE(cmodel) , &cIter 
							 , C_PIXBUF_COL           , pb
							 , C_NAME_COL             , name
							 , C_SIPURI_COL           , sipuri
							 , -1);
			fxmany->chooseCount ++;

			free(name);
			free(sipuri);
			g_object_unref(pb);
		}else{
			if(gtk_tree_model_iter_children(model , &childiter , &iter)){
				do{
					gtk_tree_model_get(model , &childiter
									 , S_CHECK_COL  , &checked1
									 , S_NAME_COL   , &name
									 , S_SIPURI_COL , &sipuri
									 , S_PIXBUF_COL , &pb
									 , -1);
					if(!checked1){
						gtk_tree_store_append(GTK_TREE_STORE(cmodel) , &cIter , NULL);
						gtk_tree_store_set(GTK_TREE_STORE(cmodel) , &cIter 
										 , C_PIXBUF_COL           , pb
										 , C_NAME_COL             , name
										 , C_SIPURI_COL           , sipuri
										 , -1);
						fxmany->chooseCount ++;
						gtk_tree_store_set(GTK_TREE_STORE(model) , &childiter
								, S_CHECK_COL , TRUE , -1);
					}
					free(name);
					free(sipuri);
					g_object_unref(pb);
				}while(gtk_tree_model_iter_next(model , &childiter));
			}
		}
	}
	else
	{
		if(gtk_tree_path_get_depth(path) > 1){
			gtk_tree_model_get_iter_root(cmodel , &cIter);
			do{
				gtk_tree_model_get(cmodel       , &cIter 
								 , C_SIPURI_COL , &uri
								 , -1);
				if(strcmp(sipuri , uri) == 0){
					free(uri);
					break;
				}
			}while(gtk_tree_model_iter_next(cmodel , &cIter));
			gtk_tree_store_remove(GTK_TREE_STORE(cmodel) , &cIter);
			fxmany->chooseCount --;
		}else{
			if(gtk_tree_model_iter_children(model , &childiter , &iter)){
				do{
					gtk_tree_model_get(model , &childiter 
							, S_CHECK_COL , &checked1
							, S_SIPURI_COL , &sipuri , -1);

					if(!checked1)
						continue;

					gtk_tree_model_get_iter_root(cmodel , &cIter);

					do{
						gtk_tree_model_get(cmodel       , &cIter 
										 , C_SIPURI_COL , &uri
										 , -1);
						if(strcmp(sipuri , uri) == 0){
							free(uri);
							break;
						}
					}while(gtk_tree_model_iter_next(cmodel , &cIter));

					gtk_tree_store_remove(GTK_TREE_STORE(cmodel) , &cIter);
					fxmany->chooseCount --;
					gtk_tree_store_set(GTK_TREE_STORE(model) , &childiter
							, S_CHECK_COL , FALSE , -1);

					free(sipuri);

				}while(gtk_tree_model_iter_next(model , &childiter));
			}
		}
	}
	gtk_tree_store_set(GTK_TREE_STORE(model) , &iter
					 , S_CHECK_COL , checked 
					 , -1);

	gtk_tree_path_free(path);
	snprintf(labeltext, sizeof(labeltext) - 1 ,
			_("Choosed [<span color=\"red\">%d</span>] contacts, "
			"[<span color=\"red\">%d</span>] more available"),
		     fxmany->chooseCount , 10000 - fxmany->chooseCount);
	gtk_label_set_markup(GTK_LABEL(fxmany->label) , labeltext);

}
Пример #22
0
/*
 * env tree view value editing started
 */
static void on_value_editing_started(GtkCellRenderer *renderer, GtkCellEditable *editable, gchar *path, gpointer user_data)
{
	being_edited_value = gtk_tree_path_new_from_string(path);
}
Пример #23
0
static void
string_edited (GtkCellRendererText *renderer,
	       gchar               *path,
	       gchar               *new_text,
	       GladeEditorProperty *eprop)
{
  GladeEPropStringList *eprop_string_list = GLADE_EPROP_STRING_LIST (eprop);
  GtkTreePath          *tree_path = gtk_tree_path_new_from_string (path);
  GtkTreeIter           iter;
  gboolean              dummy;
  guint                 index;
  GladeProperty        *property = glade_editor_property_get_property (eprop);
  GList                *string_list = NULL;

  gtk_tree_model_get_iter (eprop_string_list->model, &iter, tree_path);
  gtk_tree_model_get (eprop_string_list->model, &iter,
		      COLUMN_INDEX, &index,
		      COLUMN_DUMMY, &dummy,
		      -1);

  glade_property_get (property, &string_list);

  if (string_list)
    string_list = glade_string_list_copy (string_list);

  if (dummy)
    {
      if (new_text && new_text[0] && strcmp (new_text, _("<Type Here>")) != 0)
	string_list = 
	  glade_string_list_append (string_list,
				    new_text, NULL, NULL, 
				    eprop_string_list->translatable,
				    NULL);
    }
  else if (new_text && new_text[0])
    {
      GladeString *string = 
	g_list_nth_data (string_list, index);

      g_free (string->string);
      string->string = g_strdup (new_text);
    }
  else
    {
      GList *node = g_list_nth (string_list, index);
      glade_string_free (node->data);
      string_list = 
	g_list_delete_link (string_list, node);
    }

  eprop_string_list->editing_index = index;

  if (eprop_string_list->pending_string_list)
    glade_string_list_free (eprop_string_list->pending_string_list);
  eprop_string_list->pending_string_list = string_list;

  if (eprop_string_list->update_id == 0)
    eprop_string_list->update_id = 
      g_idle_add ((GSourceFunc) update_string_list_idle, eprop);

  gtk_tree_path_free (tree_path);
}
Пример #24
0
void AP_UnixDialog_Styles::_populateCList(void)
{
	const PD_Style * pStyle;
	const gchar * name = NULL;

	size_t nStyles = getDoc()->getStyleCount();
	xxx_UT_DEBUGMSG(("DOM: we have %d styles\n", nStyles));
	
	if (m_listStyles == NULL) {
		m_listStyles = gtk_list_store_new (1, G_TYPE_STRING);
		GtkTreeModel *sort = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (m_listStyles));
		gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort), 0, GTK_SORT_ASCENDING);
		gtk_tree_view_set_model (GTK_TREE_VIEW(m_tvStyles), sort);
		g_object_unref (G_OBJECT (sort));
		g_object_unref (G_OBJECT (m_listStyles));
	} else {
		gtk_list_store_clear (m_listStyles);
	}
	
	GtkTreeViewColumn *column = gtk_tree_view_get_column (GTK_TREE_VIEW(m_tvStyles), 0);
	if (!column) 
	{
		column = gtk_tree_view_column_new_with_attributes ("Style", gtk_cell_renderer_text_new (), "text", 0, NULL);
		gtk_tree_view_append_column(GTK_TREE_VIEW(m_tvStyles), column);
	}

	GtkTreeIter iter;
	GtkTreeIter *pHighlightIter = NULL;
	UT_GenericVector<PD_Style*> *pStyles = NULL;
	getDoc()->enumStyles(pStyles);
	for (UT_uint32 i = 0; i < nStyles; i++)
	{
		pStyle = pStyles->getNthItem(i);

		// style has been deleted probably
		if (!pStyle)
			continue;

		name = pStyle->getName();

		if ((m_whichType == ALL_STYLES) || 
			(m_whichType == USED_STYLES && pStyle->isUsed()) ||
			(m_whichType == USER_STYLES && pStyle->isUserDefined()) ||
			(!strcmp(m_sNewStyleName.utf8_str(), name))) /* show newly created style anyways */
		{
			gtk_list_store_append(m_listStyles, &iter);
			gtk_list_store_set(m_listStyles, &iter, 0, name, -1);
			
			if (!strcmp(m_sNewStyleName.utf8_str(), name)) {
				pHighlightIter = gtk_tree_iter_copy(&iter);
			}
		}
	}
	DELETEP(pStyles);

	GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(m_tvStyles));
	if (pHighlightIter) {
		// select new/modified
		gtk_tree_selection_select_iter(selection, pHighlightIter);
		gtk_tree_iter_free(pHighlightIter);
	}
	else {
		// select first
		GtkTreePath *path = gtk_tree_path_new_from_string("0");
		gtk_tree_selection_select_path(selection, path);
		gtk_tree_path_free(path);
	}
	
	// selection "changed" doesn't fire here, so hack manually
	s_tvStyles_selection_changed (selection, (gpointer)(this));
}
Пример #25
0
/******************************************************************************
* gtk_TreeStoreSetValue(tree,path_string,  ncol, val)
******************************************************************************/
int
clip_GTK_TREESTORESETVALUE(ClipMachine * ClipMachineMemory)
{
   C_object *cstree = _fetch_co_arg(ClipMachineMemory);

   gchar    *path = _clip_parc(ClipMachineMemory, 2);

   gint      column = _clip_parni(ClipMachineMemory, 3);

   ClipVar  *val = _clip_par(ClipMachineMemory, 4);;
   GtkTreeIter iter;

   ClipArrVar *utypes;

   GValue    value;

   C_object *cobj;

   gchar    *str;

   int       j, n;

   double    d;

   CHECKARG2(1, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType);
   CHECKCOBJ(cstree, GTK_IS_TREE_STORE(cstree->object));
   CHECKARG(2, CHARACTER_type_of_ClipVarType);
   CHECKARG(3, NUMERIC_type_of_ClipVarType);

   gtk_tree_model_get_iter(GTK_TREE_MODEL(GTK_TREE_STORE(cstree->object)), &iter, gtk_tree_path_new_from_string(path));

   utypes = (ClipArrVar *) _clip_vptr(_clip_mget(ClipMachineMemory, &cstree->obj, HASH_UTYPES));
   column--;

   memset(&value, 0, sizeof(value));
   switch ((int) utypes->ClipVar_items_of_ClipArrVar[column].ClipNumVar_n_of_ClipVar.double_of_ClipNumVar)
    {
    case TREE_TYPE_NUMERIC:
       g_value_init(&value, G_TYPE_INT);
       if (val->ClipType_t_of_ClipVar.ClipVartype_type_of_ClipType == NUMERIC_type_of_ClipVarType)
	  g_value_set_int(&value, (int) val->ClipNumVar_n_of_ClipVar.double_of_ClipNumVar);
       else
	{
	   n = _clip_strtod(val->ClipStrVar_s_of_ClipVar.ClipBuf_str_of_ClipStrVar.buf_of_ClipBuf, &j);
	   g_value_set_int(&value, n);
	}
       break;
    case TREE_TYPE_NUMERIC_FLOAT:
       g_value_init(&value, G_TYPE_FLOAT);
       if (val->ClipType_t_of_ClipVar.ClipVartype_type_of_ClipType == NUMERIC_type_of_ClipVarType)
	  g_value_set_float(&value, val->ClipNumVar_n_of_ClipVar.double_of_ClipNumVar);
       else
	{
	   d = _clip_strtod(val->ClipStrVar_s_of_ClipVar.ClipBuf_str_of_ClipStrVar.buf_of_ClipBuf, &j);
	   g_value_set_float(&value, d);
	}
       break;
    case TREE_TYPE_STRING:
       str = val->ClipStrVar_s_of_ClipVar.ClipBuf_str_of_ClipStrVar.buf_of_ClipBuf;
       LOCALE_TO_UTF(str);
       g_value_init(&value, G_TYPE_STRING);
       g_value_set_string(&value, str);
       FREE_TEXT(str);
       break;
    case TREE_TYPE_LOGICAL:
       g_value_init(&value, G_TYPE_BOOLEAN);
       g_value_set_boolean(&value, val->ClipLogVar_l_of_ClipVar.value_of_ClipLogVar);
       break;
    case TREE_TYPE_DATE:
       g_value_init(&value, G_TYPE_STRING);
       if (val->ClipType_t_of_ClipVar.ClipVartype_type_of_ClipType == DATE_type_of_ClipVarType)
	  str = _clip_date_to_str(val->ClipLongVar_lv_of_ClipVar.long_of_ClipLongVar, ClipMachineMemory->date_format);
       else
	  str =
	   _clip_date_to_str(_clip_str_to_date
			     (val->ClipStrVar_s_of_ClipVar.ClipBuf_str_of_ClipStrVar.buf_of_ClipBuf,
			      ClipMachineMemory->date_format, ClipMachineMemory->epoch), ClipMachineMemory->date_format);
       g_value_set_string(&value, str);
       break;
    case TREE_TYPE_PIXBUF:
       g_value_init(&value, GDK_TYPE_PIXBUF);
       cobj = _fetch_cobject(ClipMachineMemory, val);
       g_value_set_object(&value, cobj->object);
       break;
    }
   gtk_tree_store_set_value(GTK_TREE_STORE(cstree->object), &iter, column, &value);

   return 0;
 err:
   return 1;
}
Пример #26
0
static void
toggled_callback (GtkCellRendererToggle *celltoggle,
                  gchar                 *path_string,
                  GtkTreeView           *tree_view)
{
  GtkTreeModel *model = NULL;
  GtkTreeModelSort *sort_model = NULL;
  GtkTreePath *path;
  GtkTreeIter iter;
  gboolean active = FALSE;
  
  g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));

  model = gtk_tree_view_get_model (tree_view);
  
  if (GTK_IS_TREE_MODEL_SORT (model))
    {
      sort_model = GTK_TREE_MODEL_SORT (model);
      model = gtk_tree_model_sort_get_model (sort_model);
    }

  if (model == NULL)
    return;

  if (sort_model)
    {
      g_warning ("FIXME implement conversion from TreeModelSort iter to child model iter");
      return;
    }
      
  path = gtk_tree_path_new_from_string (path_string);
  if (!gtk_tree_model_get_iter (model,
                                &iter, path))
    {
      g_warning ("%s: bad path?", G_STRLOC);
      return;
    }
  gtk_tree_path_free (path);
  
  if (GTK_IS_LIST_STORE (model))
    {
      gtk_tree_model_get (GTK_TREE_MODEL (model),
                          &iter,
                          BOOL_COLUMN,
                          &active,
                          -1);
      
      gtk_list_store_set (GTK_LIST_STORE (model),
                          &iter,
                          BOOL_COLUMN,
                          !active,
                          -1);
    }
  else if (GTK_IS_TREE_STORE (model))
    {
      gtk_tree_model_get (GTK_TREE_MODEL (model),
                          &iter,
                          BOOL_COLUMN,
                          &active,
                          -1);
            
      gtk_tree_store_set (GTK_TREE_STORE (model),
                          &iter,
                          BOOL_COLUMN,
                          !active,
                          -1);
    }
  else
    g_warning ("don't know how to actually toggle value for model type %s",
               g_type_name (G_TYPE_FROM_INSTANCE (model)));
}
/* Constrcut side bar widget. */
static GtkWidget *
libre_impuesto_window_construct_sidebar (LibreImpuesto *impuesto,
					 LibreImpuestoWindow *impuesto_window)
{
  GtkStack * stack;
  GtkWidget *switcher;
  GtkTreePath *tree_path;
  GtkTreeStore * tree_store;
  GtkTreeViewColumn *column;
  GtkTreeSelection *selection;
  GtkCellRenderer *cell_renderer;
  GtkWidget *paned, *box_switcher, *widget, *frame, *scroll;


  paned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);

  g_object_bind_property (impuesto_window, "sidebar-visible",
			  paned, "visible",
			  G_BINDING_SYNC_CREATE);

  box_switcher = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);

  switcher = gtk_stack_switcher_new ();
  g_object_set_data(G_OBJECT(impuesto_window), "switcher", switcher);
  gtk_orientable_set_orientation (GTK_ORIENTABLE (switcher), 
				  GTK_ORIENTATION_VERTICAL);
  gtk_box_pack_end (GTK_BOX (box_switcher), switcher, FALSE, FALSE, 0);

  stack = GTK_STACK (gtk_stack_new ());
  gtk_stack_set_homogeneous ( stack, TRUE);
  gtk_box_pack_end (GTK_BOX (box_switcher), GTK_WIDGET(stack), TRUE, TRUE, 0);

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

  
  tree_store = libre_impuesto_get_tree_data_general( impuesto );
  widget = gtk_tree_view_new_with_model (GTK_TREE_MODEL(tree_store)); 

  column = gtk_tree_view_column_new();
  gtk_tree_view_column_set_title (column,_( "Libre Impuestos"));

  cell_renderer = gtk_cell_renderer_pixbuf_new ();
  gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
  gtk_tree_view_column_add_attribute (column, cell_renderer, "pixbuf", 0);

  cell_renderer = gtk_cell_renderer_text_new ();
  gtk_tree_view_column_pack_start (column, cell_renderer, TRUE);
  gtk_tree_view_column_add_attribute (column, cell_renderer, "text", 1);

  gtk_tree_view_append_column (GTK_TREE_VIEW(widget), column);

  gtk_tree_view_expand_all(GTK_TREE_VIEW(widget));

  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(widget));
  g_signal_connect_swapped ( selection, "changed",
			     G_CALLBACK (node_tree_selection_changed_cb), 
			     G_OBJECT (impuesto_window));


  gtk_container_add (GTK_CONTAINER (scroll), widget);

  gtk_container_add_with_properties (GTK_CONTAINER (stack), scroll, 
				     "name", _("Generales"),
				     "title",_("General Options"),
				     "icon-name", GTK_STOCK_HOME,
				     NULL);


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

  tree_store = libre_impuesto_get_tree_data_formulario( impuesto );
  widget = gtk_tree_view_new_with_model (GTK_TREE_MODEL(tree_store)); 

  column = gtk_tree_view_column_new();
  gtk_tree_view_column_set_title (column, _("Electronic Forms"));

  cell_renderer = gtk_cell_renderer_pixbuf_new ();
  gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
  gtk_tree_view_column_add_attribute (column, cell_renderer, "pixbuf", 0);

  cell_renderer = gtk_cell_renderer_text_new ();
  gtk_tree_view_column_pack_start (column, cell_renderer, TRUE);
  gtk_tree_view_column_add_attribute (column, cell_renderer, "text", 1);

  gtk_tree_view_append_column (GTK_TREE_VIEW(widget), column);

  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(widget));
  g_signal_connect_swapped ( selection, "changed",
			     G_CALLBACK (node_tree_selection_changed_cb), 
			     G_OBJECT (impuesto_window));

  gtk_container_add (GTK_CONTAINER (scroll), widget);

  gtk_container_add_with_properties (GTK_CONTAINER (stack), scroll, 
				     "name", _("Modulos"),
				     "title",_( "Electronic Forms"),
				     "icon-name", GTK_STOCK_HOME,
				     NULL);

  tree_path = gtk_tree_path_new_from_string ("0");
  gtk_tree_view_expand_row (GTK_TREE_VIEW(widget), tree_path, FALSE);


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

  tree_store = libre_impuesto_get_tree_data_consultor( impuesto );
  widget = gtk_tree_view_new_with_model (GTK_TREE_MODEL(tree_store)); 

  column = gtk_tree_view_column_new();
  gtk_tree_view_column_set_title (column,_("Consultores"));

  cell_renderer = gtk_cell_renderer_pixbuf_new ();
  gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
  gtk_tree_view_column_add_attribute (column, cell_renderer, "pixbuf", 0);

  cell_renderer = gtk_cell_renderer_text_new ();
  gtk_tree_view_column_pack_start (column, cell_renderer, TRUE);
  gtk_tree_view_column_add_attribute (column, cell_renderer, "text", 1);

  gtk_tree_view_append_column (GTK_TREE_VIEW(widget), column);

  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(widget));
  g_signal_connect_swapped ( selection, "changed",
			     G_CALLBACK (node_tree_selection_changed_cb), 
			     G_OBJECT (impuesto_window));

  gtk_container_add (GTK_CONTAINER (scroll), widget);

  gtk_container_add_with_properties (GTK_CONTAINER (stack), scroll, 
				     "name", _("Consultores"),
				     "title",_( "Consultores"),
				     "icon-name", GTK_STOCK_HOME,
				     NULL);

  tree_path = gtk_tree_path_new_from_string ("0");
  gtk_tree_view_expand_row (GTK_TREE_VIEW(widget), tree_path, FALSE);

  gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), GTK_STACK (stack));

  gtk_paned_pack1 ( GTK_PANED(paned), box_switcher, TRUE, FALSE );

  gtk_widget_show_all (box_switcher);

  frame = gtk_frame_new (NULL);
  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);

  widget = gtk_drawing_area_new ();
  gtk_widget_set_name (widget, "logo");

  /*gtk_widget_set_size_request (widget, 
			       gdk_pixbuf_get_width (logo), 
			       gdk_pixbuf_get_height (logo));*/

  gtk_widget_set_size_request (widget, -1, 50);

  g_signal_connect (widget, "draw",
		    G_CALLBACK (draw_area_cb), NULL);

  gtk_container_add (GTK_CONTAINER (frame), widget);

  gtk_paned_pack2 (GTK_PANED(paned), frame, TRUE, FALSE);

  return paned;

}
Пример #28
0
static void quick_opener()
{
	GtkWidget *entry, *label, *hbox;
	GtkTreeViewColumn *path_column, *name_column;
	GtkCellRenderer *renderLeft, *renderRight;

	dialog = gtk_dialog_new_with_buttons(_("Quick Open:"),
		GTK_WINDOW(geany->main_widgets->window),
		GTK_DIALOG_DESTROY_WITH_PARENT,NULL);
	gtk_window_set_default_size(GTK_WINDOW(dialog), 500, 250);

	gtk_dialog_add_button(GTK_DIALOG(dialog),_("_Open"), GTK_RESPONSE_APPLY);
	gtk_dialog_add_button(GTK_DIALOG(dialog),_("_Cancel"), GTK_RESPONSE_CANCEL);
	
	hbox=gtk_hbox_new(FALSE, 0);
	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),hbox, FALSE, FALSE, 0);

	label=gtk_label_new(_("File:"));
	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);

	entry = gtk_entry_new();
	g_signal_connect(entry, "key-press-event", G_CALLBACK(onkeypress), NULL);
	g_signal_connect(entry, "key-release-event", G_CALLBACK(onkeyrelease), NULL);

	gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 2);
	
	//Table:
	
	list = gtk_tree_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
	tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(list));
	GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
	gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);

	path_column = gtk_tree_view_column_new();
	gtk_tree_view_append_column(GTK_TREE_VIEW(tree), path_column);
	name_column = gtk_tree_view_column_new();
	gtk_tree_view_append_column(GTK_TREE_VIEW(tree), name_column);
	
	renderRight = gtk_cell_renderer_text_new();
	gtk_cell_renderer_set_alignment(renderRight, 1.0, 0.0);
	gtk_cell_renderer_set_padding(renderRight, 0, 1);
	g_object_set(renderRight, "foreground", "#777", "foreground-set", TRUE, NULL);
	
	renderLeft = gtk_cell_renderer_text_new();
	gtk_cell_renderer_set_padding(renderLeft, 0, 1);
	
	gtk_tree_view_column_pack_start(path_column, renderRight, TRUE);
	gtk_tree_view_column_add_attribute(path_column, renderRight, "text", 0);
	gtk_tree_view_column_pack_start(name_column, renderLeft, TRUE);
	gtk_tree_view_column_add_attribute(name_column, renderLeft, "text", 1);

	g_object_unref(list);
	gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), FALSE);

	//Scrollable:
	scrollable = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollable), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_container_add(GTK_CONTAINER(scrollable), tree);
	g_signal_connect(tree, "key-press-event", G_CALLBACK(tree_keypress), entry);

	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), scrollable, TRUE, TRUE, 10);
	gtk_widget_show_all(dialog);
	
	adjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(scrollable));
	first = gtk_tree_path_new_from_string("0");
	second = gtk_tree_path_new_from_string("1");

	gint response = gtk_dialog_run(GTK_DIALOG(dialog));
	if(response == GTK_RESPONSE_APPLY) {
		submit();
	}
	gtk_widget_destroy(dialog);
}
void
bmd_cell_edited (GtkCellRendererText *cell,
	     const gchar         *path_string,
	     const gchar         *new_text,
	     gpointer             data)
{
	GtkTreeModel *model = (GtkTreeModel *) data;
	GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
	GtkTreeIter iter;

	gint column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column"));

	gtk_tree_model_get_iter (model, &iter, path);

	switch (column) {
	case COLUMN_ITEM_NUMBER: {
		gint i;

		i = gtk_tree_path_get_indices (path) [0];
		g_array_index (articles, Item, i).number = atoi (new_text);

		gtk_list_store_set (GTK_LIST_STORE (model), &iter, column,
				    g_array_index (articles, Item, i).number, -1);
	}
	break;

	case COLUMN_ITEM_TITLE: {
		gint i;
		gchar *old_text;

		gtk_tree_model_get (model, &iter, column, &old_text, -1);
		g_free (old_text);

		i = gtk_tree_path_get_indices (path) [0];
		g_free (g_array_index (articles, Item, i).title);
		g_array_index (articles, Item, i).title = g_strdup (new_text);

		gtk_list_store_set (GTK_LIST_STORE (model), &iter, column,
				    g_array_index (articles, Item, i).title, -1);
	}
	break;

	case COLUMN_ITEM_AUTHOR: {
		gint i;
		gchar *old_text;

		gtk_tree_model_get (model, &iter, column, &old_text, -1);
		g_free (old_text);

		i = gtk_tree_path_get_indices (path) [0];
		g_free (g_array_index (articles, Item, i).author);
		g_array_index (articles, Item, i).author = g_strdup (new_text);

		gtk_list_store_set (GTK_LIST_STORE (model), &iter, column,
				    g_array_index (articles, Item, i).author, -1);
	}
	break;

	case COLUMN_ITEM_PAGES: {
		gint i;

		i = gtk_tree_path_get_indices (path) [0];
		g_array_index (articles, Item, i).pages = atoi (new_text);

		gtk_list_store_set (GTK_LIST_STORE (model), &iter, column,
				    g_array_index (articles, Item, i).pages, -1);
	}
	break;

	}

	gtk_tree_path_free (path);
}
Пример #30
0
// added a call to DisplaySymbols() so window updates right away
void Callback_TextEdited(GtkCellRendererText *cell, gchar *path_string,
		      gchar *new_text, gpointer data) {

	int OffsetArray = -999;
	StrSymbol * pSymbol;
	GtkTreeModel *treemodel = (GtkTreeModel *)ListStore;
	GtkTreeIter iter;

	/* Convert the string path to the row that has changed to a GtkIter */
	gtk_tree_model_get_iter (treemodel, &iter, gtk_tree_path_new_from_string (path_string));

	/* Update the GtkTreeModel with the new value */
	gtk_tree_model_get (treemodel, &iter,
						NUM_ARRAY, &OffsetArray,
						-1);
	gtk_list_store_set( ListStore, &iter,
					data, new_text, -1);
//printf( "path=%s, new_text=%s, data_column=%d, offset_array=%d\n",path_string, new_text, (int)data, OffsetArray );
	pSymbol = &SymbolArray[ OffsetArray ];
	switch( (long)data )
	{
		case VAR_NAME:
			if ( new_text[ 0 ]!='%' )
			{
				ShowMessageBox(_("Error"),_("A variable name always start with '%' character !"),_("Ok"));
			}
			else
			{
				if (TextParserForAVar( new_text, NULL, NULL, NULL, TRUE/*PartialNames*/ ) )
				{
					strncpy( pSymbol->VarName, new_text, LGT_VAR_NAME-1 );
					pSymbol->VarName[ LGT_VAR_NAME-1 ] = '\0';
					gtk_list_store_set( ListStore, &iter, data, pSymbol->VarName, -1);
					if ( pSymbol->Symbol[0]=='\0' )
						strcpy( pSymbol->Symbol, "***" );
					InfosGene->AskConfirmationToQuit = TRUE;
				}
				else
				{
					if (ErrorMessageVarParser)
						ShowMessageBox( _("Error"), ErrorMessageVarParser, _("Ok") );
					else
						ShowMessageBox( _("Error"), _("Unknown variable..."), _("Ok") );
				}
			}
			break;
		case SYMBOL:
			strncpy( pSymbol->Symbol, new_text, LGT_SYMBOL_STRING-1 );
			pSymbol->Symbol[ LGT_SYMBOL_STRING-1 ] = '\0';
			gtk_list_store_set( ListStore, &iter, data, pSymbol->Symbol, -1);
			InfosGene->AskConfirmationToQuit = TRUE;
			break; 
		case COMMENT:
			strncpy( pSymbol->Comment, new_text, LGT_SYMBOL_COMMENT-1 );
			pSymbol->Comment[ LGT_SYMBOL_COMMENT-1 ] = '\0';
			gtk_list_store_set( ListStore, &iter, data, pSymbol->Comment, -1);
			InfosGene->AskConfirmationToQuit = TRUE;
			break;
	}
DisplaySymbols();
}