コード例 #1
0
static void
thunar_folder_file_destroyed (ThunarFileMonitor *file_monitor,
                              ThunarFile        *file,
                              ThunarFolder      *folder)
{
  GList  files;
  GList *lp;

  _thunar_return_if_fail (THUNAR_IS_FILE (file));
  _thunar_return_if_fail (THUNAR_IS_FOLDER (folder));
  _thunar_return_if_fail (THUNAR_IS_FILE_MONITOR (file_monitor));

  /* check if the corresponding file was destroyed */
  if (G_UNLIKELY (folder->corresponding_file == file))
    {
      /* the folder is useless now */
      gtk_object_destroy (GTK_OBJECT (folder));
    }
  else
    {
      /* check if we have that file */
      lp = g_list_find (folder->files, file);
      if (G_LIKELY (lp != NULL))
        {
          /* remove the file from our list */
          folder->files = g_list_delete_link (folder->files, lp);

          /* tell everybody that the file is gone */
          files.data = file; files.next = files.prev = NULL;
          g_signal_emit (G_OBJECT (folder), folder_signals[FILES_REMOVED], 0, &files);

          /* drop our reference to the file */
          g_object_unref (G_OBJECT (file));
        }
    }
}
コード例 #2
0
ファイル: draw-context.c プロジェクト: benjohnson2001/base
gint
sp_pen_context_root_handler (SPEventContext *ec, GdkEvent *event)
{
	SPDrawContext *dc;
	SPPenContext *pc;
	SPDesktop *dt;
	NRPointF p;
	gint ret;
	SPDrawAnchor *anchor;
	NRPointF fp;

	dc = SP_DRAW_CONTEXT (ec);
	pc = SP_PEN_CONTEXT (ec);
	dt = ec->desktop;

	ret = FALSE;

	switch (event->type) {
	case GDK_BUTTON_PRESS:
		if (event->button.button == 1) {
#if 0
			/* Grab mouse, so release will not pass unnoticed */
			dc->grab = SP_CANVAS_ITEM (dt->acetate);
			sp_canvas_item_grab (dc->grab, SPDC_EVENT_MASK, NULL, event->button.time);
#endif
			/* Find desktop coordinates */
			sp_desktop_w2d_xy_point (dt, &fp, event->button.x, event->button.y);
			p.x = fp.x;
			p.y = fp.y;
			/* Test, whether we hit any anchor */
			anchor = test_inside (dc, event->button.x, event->button.y);

			switch (pc->mode) {
			case SP_PEN_CONTEXT_MODE_CLICK:
				/* In click mode we add point on release */
				switch (pc->state) {
				case SP_PEN_CONTEXT_POINT:
				case SP_PEN_CONTEXT_CONTROL:
				case SP_PEN_CONTEXT_CLOSE:
					break;
				case SP_PEN_CONTEXT_STOP:
					/* This is allowed, if we just cancelled curve */
					pc->state = SP_PEN_CONTEXT_POINT;
					break;
				default:
					break;
				}
				break;
			case SP_PEN_CONTEXT_MODE_DRAG:
				switch (pc->state) {
				case SP_PEN_CONTEXT_STOP:
					/* This is allowed, if we just cancelled curve */
				case SP_PEN_CONTEXT_POINT:
					if (dc->npoints == 0) {
						/* Set start anchor */
						dc->sa = anchor;
						if (anchor) {
							/* Adjust point to anchor if needed */
							p = anchor->dp;
						} else {
							/* Create green anchor */
							dc->green_anchor = sp_draw_anchor_new (dc, dc->green_curve, TRUE, p.x, p.y);
						}
						spdc_pen_set_point (pc, &p, event->motion.state);
					} else {
						/* Set end anchor */
						dc->ea = anchor;
						spdc_pen_set_point (pc, &p, event->motion.state);
						if (dc->green_anchor && dc->green_anchor->active) {
							pc->state = SP_PEN_CONTEXT_CLOSE;
							ret = TRUE;
							break;
						}
					}
					pc->state = SP_PEN_CONTEXT_CONTROL;
					ret = TRUE;
					break;
				case SP_PEN_CONTEXT_CONTROL:
					g_warning ("Button down in CONTROL state");
					break;
				case SP_PEN_CONTEXT_CLOSE:
					g_warning ("Button down in CLOSE state");
					break;
				default:
					break;
				}
				break;
			default:
				break;
			}
		}
		break;
	case GDK_MOTION_NOTIFY:
#if 1
		if ((event->motion.state & GDK_BUTTON1_MASK) && !dc->grab) {
			/* Grab mouse, so release will not pass unnoticed */
			dc->grab = SP_CANVAS_ITEM (dt->acetate);
			sp_canvas_item_grab (dc->grab, SPDC_EVENT_MASK, NULL, event->button.time);
		}
#endif
		/* Find desktop coordinates */
		sp_desktop_w2d_xy_point (dt, &fp, event->motion.x, event->motion.y);
		p.x = fp.x;
		p.y = fp.y;
		/* Test, whether we hit any anchor */
		anchor = test_inside (dc, event->button.x, event->button.y);
		if (!anchor) {
			/* Snap only if not hitting anchor */
			spdc_endpoint_snap (dc, &p, event->motion.state);
		}

		switch (pc->mode) {
		case SP_PEN_CONTEXT_MODE_CLICK:
			switch (pc->state) {
			case SP_PEN_CONTEXT_POINT:
				if (dc->npoints != 0) {
					/* Only set point, if we are already appending */
					/* fixme: Snapping */
					spdc_pen_set_point (pc, &p, event->motion.state);
					ret = TRUE;
				}
				break;
			case SP_PEN_CONTEXT_CONTROL:
			case SP_PEN_CONTEXT_CLOSE:
				/* Placing controls is last operation in CLOSE state */
				/* fixme: Snapping */
				spdc_pen_set_ctrl (pc, &p, event->motion.state);
				ret = TRUE;
				break;
			case SP_PEN_CONTEXT_STOP:
				/* This is perfectly valid */
				break;
			default:
				break;
			}
			break;
		case SP_PEN_CONTEXT_MODE_DRAG:
			switch (pc->state) {
			case SP_PEN_CONTEXT_POINT:
				if (dc->npoints > 0) {
					/* Only set point, if we are already appending */
					/* fixme: Snapping */
					spdc_pen_set_point (pc, &p, event->motion.state);
					ret = TRUE;
				}
				break;
			case SP_PEN_CONTEXT_CONTROL:
			case SP_PEN_CONTEXT_CLOSE:
				/* Placing controls is last operation in CLOSE state */
				/* fixme: Snapping */
				spdc_pen_set_ctrl (pc, &p, event->motion.state);
				ret = TRUE;
				break;
			case SP_PEN_CONTEXT_STOP:
				/* This is perfectly valid */
				break;
			default:
				break;
			}
			break;
		default:
			break;
		}
		break;
	case GDK_BUTTON_RELEASE:
		if (event->button.button == 1) {
			/* Find desktop coordinates */
			sp_desktop_w2d_xy_point (dt, &fp, event->motion.x, event->motion.y);
			p.x = fp.x;
			p.y = fp.y;
			/* Test, whether we hit any anchor */
			anchor = test_inside (dc, event->button.x, event->button.y);

			switch (pc->mode) {
			case SP_PEN_CONTEXT_MODE_CLICK:
				switch (pc->state) {
				case SP_PEN_CONTEXT_POINT:
					if (dc->npoints == 0) {
						/* Start new thread only with button release */
						if (anchor) {
							p = anchor->dp;
						}
						dc->sa = anchor;
						spdc_pen_set_point (pc, &p, event->motion.state);
					} else {
						/* Set end anchor here */
						dc->ea = anchor;
					}
					pc->state = SP_PEN_CONTEXT_CONTROL;
					ret = TRUE;
					break;
				case SP_PEN_CONTEXT_CONTROL:
					/* End current segment */
					spdc_pen_finish_segment (pc, &p, event->button.state);
					pc->state = SP_PEN_CONTEXT_POINT;
					ret = TRUE;
					break;
				case SP_PEN_CONTEXT_CLOSE:
					/* End current segment */
					spdc_pen_finish_segment (pc, &p, event->button.state);
					spdc_pen_finish (pc, TRUE);
					pc->state = SP_PEN_CONTEXT_POINT;
					ret = TRUE;
					break;
				case SP_PEN_CONTEXT_STOP:
					/* This is allowed, if we just cancelled curve */
					pc->state = SP_PEN_CONTEXT_POINT;
					ret = TRUE;
					break;
				default:
					break;
				}
				break;
			case SP_PEN_CONTEXT_MODE_DRAG:
				switch (pc->state) {
				case SP_PEN_CONTEXT_POINT:
				case SP_PEN_CONTEXT_CONTROL:
					spdc_pen_finish_segment (pc, &p, event->button.state);
					break;
				case SP_PEN_CONTEXT_CLOSE:
					spdc_pen_finish_segment (pc, &p, event->button.state);
					spdc_pen_finish (pc, TRUE);
					break;
				case SP_PEN_CONTEXT_STOP:
					/* This is allowed, if we just cancelled curve */
					break;
				default:
					break;
				}
				pc->state = SP_PEN_CONTEXT_POINT;
				ret = TRUE;
				break;
			default:
				break;
			}
#if 1
			if (dc->grab) {
				/* Release grab now */
				sp_canvas_item_ungrab (dc->grab, event->button.time);
				dc->grab = NULL;
			}
#endif
			ret = TRUE;
		}
		break;
	case GDK_2BUTTON_PRESS:
		spdc_pen_finish (pc, FALSE);
		ret = TRUE;
		break;
	case GDK_KEY_PRESS:
		/* fixme: */
		switch (event->key.keyval) {
		case GDK_Return:
			spdc_pen_finish (pc, FALSE);
			ret = TRUE;
			break;
		case GDK_Escape:
			pc->state = SP_PEN_CONTEXT_STOP;
			spdc_reset_colors (dc);
			sp_canvas_item_hide (pc->c0);
			sp_canvas_item_hide (pc->c1);
			sp_canvas_item_hide (pc->cl0);
			sp_canvas_item_hide (pc->cl1);
			ret = TRUE;
			break;
		case GDK_BackSpace:
			if (sp_curve_is_empty (dc->green_curve)) {
				/* Same as cancel */
				pc->state = SP_PEN_CONTEXT_STOP;
				spdc_reset_colors (dc);
				sp_canvas_item_hide (pc->c0);
				sp_canvas_item_hide (pc->c1);
				sp_canvas_item_hide (pc->cl0);
				sp_canvas_item_hide (pc->cl1);
				ret = TRUE;
				break;
			} else {
				NRPointF pt;
				ArtBpath *p;
				gint e;
				/* Reset red curve */
				sp_curve_reset (dc->red_curve);
				/* Destroy topmost green bpath */
				gtk_object_destroy (GTK_OBJECT (dc->green_bpaths->data));
				dc->green_bpaths = g_slist_remove (dc->green_bpaths, dc->green_bpaths->data);
				/* Get last segment */
				p = SP_CURVE_BPATH (dc->green_curve);
				e = SP_CURVE_LENGTH (dc->green_curve);
				if (e < 2) {
					g_warning ("Green curve length is %d", e);
					break;
				}
				dc->p[0].x = p[e - 2].x3;
				dc->p[0].y = p[e - 2].y3;
				dc->p[1].x = p[e - 1].x1;
				dc->p[1].y = p[e - 1].y1;
				if (dc->npoints < 4) {
					pt.x = p[e - 1].x3;
					pt.y = p[e - 1].y3;
				} else {
					pt.x = dc->p[3].x;
					pt.y = dc->p[3].y;
				}
				dc->npoints = 2;
				sp_curve_backspace (dc->green_curve);
				sp_canvas_item_hide (pc->c0);
				sp_canvas_item_hide (pc->c1);
				sp_canvas_item_hide (pc->cl0);
				sp_canvas_item_hide (pc->cl1);
				pc->state = SP_PEN_CONTEXT_POINT;
				spdc_pen_set_point (pc, &pt, event->motion.state);
				ret = TRUE;
			}
			break;
		default:
			break;
		}
		break;
	default:
		break;
	}

	if (!ret) {
		if (((SPEventContextClass *) pen_parent_class)->root_handler)
			return ((SPEventContextClass *) pen_parent_class)->root_handler (ec, event);
	}

	return ret;
}
コード例 #3
0
ファイル: gtkam-save.c プロジェクト: ndim/gtkam
static void
on_ok_clicked (GtkButton *button, GtkamSave *save)
{
	guint i, count, j = 1;
	int result = -1;
	GtkWidget *s, *dialog;
	unsigned int id = 0;
	GtkamSaveData *data;
	gchar *progname, *command;
	GError *error = NULL;

	if (count_items (save) == 0) {
		if (!save->priv->err_shown) {
			
			dialog = gtkam_error_new (result, NULL,
					GTK_WIDGET (save), _("There is nothing to be saved."));
			gtk_widget_show (dialog);
		}

		return;
	}
			
	store_save_settings(save);
	gtk_widget_hide (GTK_WIDGET (save));

	count = g_slist_length (save->priv->data);
	if (count == 1)
		s = gtkam_cancel_new (_("Downloading file"));
	else
		s = gtkam_cancel_new (_("Downloading %i files"), count);
	gtk_window_set_transient_for (GTK_WINDOW (s), save->priv->main_window);
	gtk_widget_show (s);

	if (count > 1)
		id = gp_context_progress_start (
			GTKAM_CANCEL (s)->context->context, count,
			_("Downloading %i files..."), count);

	if (!save->priv->toggle_filename_camera->active)
		j = gtk_spin_button_get_value_as_int (
				GTK_SPIN_BUTTON (save->priv->spin_entry));
	
	for (i = 0; i < count; i++) {
		data = g_slist_nth_data (save->priv->data, i);

		/* Check for shutdown */
		if (!GTKAM_IS_SAVE (save))
			return;

		if (save->priv->toggle_normal &&
		    save->priv->toggle_normal->active)
			result = get_file (save, data->camera,
				  data->folder, data->name,
				  GP_FILE_TYPE_NORMAL, i + j,
				  GTKAM_CANCEL (s)->context);
		if (save->priv->toggle_preview &&
		    save->priv->toggle_preview->active &&
		    (!result < 0))
			result = get_file (save, data->camera,
				  data->folder, data->name,
				  GP_FILE_TYPE_PREVIEW, i + j,
				  GTKAM_CANCEL (s)->context);
		if (save->priv->toggle_raw &&
		    save->priv->toggle_raw->active &&
		    (!result < 0))
			result = get_file (save, data->camera,
				  data->folder, data->name, GP_FILE_TYPE_RAW,
				  i + j, GTKAM_CANCEL (s)->context);
		if (save->priv->toggle_audio &&
		    save->priv->toggle_audio->active &&
		    (!result < 0))
			result = get_file (save, data->camera,
				  data->folder, data->name, GP_FILE_TYPE_AUDIO,
				  i + j, GTKAM_CANCEL (s)->context);
		if (save->priv->toggle_exif &&
		    save->priv->toggle_exif->active &&
		    (!result < 0))
			result = get_file (save, data->camera,
				  data->folder, data->name, GP_FILE_TYPE_EXIF,
				  i + j, GTKAM_CANCEL (s)->context);

		if (result < 0)
		{
			if (count > 1)
				gp_context_progress_stop (GTKAM_CANCEL (s)->context->context, id);
			if (!save->priv->err_shown) {
				dialog = gtkam_error_new (result, GTKAM_CANCEL (s)->context,
						GTK_WIDGET (save), _("Problem getting '%s' "
						"from folder '%s'."),
						data->name, data->folder);
				gtk_widget_show (dialog);
				save->priv->err_shown = TRUE;
			}
	
			gtk_object_destroy (GTK_OBJECT (s));
			gtk_object_destroy (GTK_OBJECT (save));
			return;
		}
		
		if (count > 1)
			gp_context_progress_update (
				GTKAM_CANCEL (s)->context->context, id, i + 1);
		gp_context_idle (GTKAM_CANCEL (s)->context->context);
		if (gp_context_cancel (GTKAM_CANCEL (s)->context->context) ==
				GP_CONTEXT_FEEDBACK_CANCEL)
			break;
	}
	if (count > 1)
		gp_context_progress_stop (
				GTKAM_CANCEL (s)->context->context, id);
	
	gtk_object_destroy (GTK_OBJECT (s));

	/* If file(s) were saved and a program specified, load the program
   passing the filenames */
	if (result >= 0)
	{
		progname = gtk_entry_get_text (save->priv->program);

		if (progname && progname[0] != '\0') {
			command = g_strdup_printf ("%s%s", progname, save->priv->filelist->str);

			/* FIXME Report any arising errors */
			if (!g_spawn_command_line_async (command, &error)) {
				g_warning ("Error running command\n");
				g_error_free (error);
			}
			
			g_free (command);
			g_string_free (save->priv->filelist, TRUE);
		} 
	}
	
	gtk_object_destroy (GTK_OBJECT (save));
}
コード例 #4
0
ファイル: new_req_window.c プロジェクト: jcape/gnoMint
G_MODULE_EXPORT void on_new_req_commit_clicked (GtkButton *widg,
			       gpointer user_data) 
{
	TlsCreationData *csr_creation_data = NULL;

	GtkWidget *widget = NULL;
	GtkWindow *window = NULL;
	gint active = -1;
	gchar *text = NULL;
	GtkTreeModel *tree_model = NULL;
	GtkTreeIter tree_iter;
	
	csr_creation_data = g_new0 (TlsCreationData, 1);

        if (new_req_ca_id_valid)
                csr_creation_data->parent_ca_id_str = g_strdup_printf ("'%"G_GUINT64_FORMAT"'", new_req_ca_id);

	widget = GTK_WIDGET(gtk_builder_get_object (new_req_window_gtkb, "country_combobox1"));
	active = gtk_combo_box_get_active (GTK_COMBO_BOX(widget));

	if (active < 0) {
			csr_creation_data->country = NULL;
	} else {
		tree_model = gtk_combo_box_get_model (GTK_COMBO_BOX(widget));
		gtk_combo_box_get_active_iter (GTK_COMBO_BOX(widget), &tree_iter);
		gtk_tree_model_get (tree_model, &tree_iter, 1, &text, -1);

		csr_creation_data->country = g_strdup (text);
		
	}
		
	widget = GTK_WIDGET(gtk_builder_get_object (new_req_window_gtkb, "st_entry1"));
	text = (gchar *) gtk_entry_get_text (GTK_ENTRY(widget));
	if (strlen (text))
		csr_creation_data->state = g_strdup (text);
	else
		csr_creation_data->state = NULL;

	widget = GTK_WIDGET(gtk_builder_get_object (new_req_window_gtkb, "city_entry1"));
	text = (gchar *) gtk_entry_get_text (GTK_ENTRY(widget));
	if (strlen (text))
		csr_creation_data->city = g_strdup (text);
	else
		csr_creation_data->city = NULL;

	widget = GTK_WIDGET(gtk_builder_get_object (new_req_window_gtkb, "o_entry1"));
	text = (gchar *) gtk_entry_get_text (GTK_ENTRY(widget));
	if (strlen (text))
		csr_creation_data->org = g_strdup (text);
	else
		csr_creation_data->org = NULL;

	widget = GTK_WIDGET(gtk_builder_get_object (new_req_window_gtkb, "ou_entry1"));
	text = (gchar *) gtk_entry_get_text (GTK_ENTRY(widget));
	if (strlen (text))
		csr_creation_data->ou = g_strdup (text);
	else
		csr_creation_data->ou = NULL;

	widget = GTK_WIDGET(gtk_builder_get_object (new_req_window_gtkb, "cn_entry1"));
	text = (gchar *) gtk_entry_get_text (GTK_ENTRY(widget));
	if (strlen (text))
		csr_creation_data->cn = g_strdup (text);
	else
		csr_creation_data->cn = NULL;

	widget = GTK_WIDGET(gtk_builder_get_object (new_req_window_gtkb, "dsa_radiobutton1"));
	active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget));
	csr_creation_data->key_type = active;

	widget = GTK_WIDGET(gtk_builder_get_object (new_req_window_gtkb, "keylength_spinbutton1"));
	active = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(widget));
	csr_creation_data->key_bitlength = active;

	if (ca_file_is_password_protected()) {
		csr_creation_data->password = pkey_manage_ask_password();

                if (! csr_creation_data->password) {
                        /* The user hasn't provided a valid password */
                        return;
                }
        }

	window = GTK_WINDOW(gtk_builder_get_object (new_req_window_gtkb, "new_req_window"));
	gtk_object_destroy(GTK_OBJECT(window));

	creation_process_window_csr_display (csr_creation_data);	

}
コード例 #5
0
ファイル: ui-utils.c プロジェクト: aosm/gutenprint
/**
 * stpui_help_free:
 *
 * This function frees the memory used by the #GtkTooltips created by
 * stpui_help_init().
 **/
void
stpui_help_free (void)
{
  gtk_object_destroy (GTK_OBJECT (tool_tips));
  gtk_object_unref   (GTK_OBJECT (tool_tips));
}
コード例 #6
0
ファイル: gnmap.c プロジェクト: tung/nethack360-statuscolors
void
ghack_reinit_map_window()
{
    GnomeCanvasImage *bg;
    double width, height, x, y;
    int i;

    /* ghack_map_clear(NULL, NULL); */

    width = COLNO * ghack_glyph_width();
    height = ROWNO * ghack_glyph_height();

    gnome_canvas_set_scroll_region(GNOME_CANVAS(ghack_map.canvas), 0, 0,
                                   width + 2 * ghack_glyph_width(),
                                   height + 2 * ghack_glyph_height());

    /* remove everything currently in the canvas map */
    gtk_object_destroy(GTK_OBJECT(myCanvasGroup));

    /* Put some groups back */
    myCanvasGroup = GNOME_CANVAS_GROUP(gnome_canvas_item_new(
                                           gnome_canvas_root(GNOME_CANVAS(ghack_map.canvas)),
                                           gnome_canvas_group_get_type(), "x", 0.0, "y", 0.0, NULL));

    /* Tile the map background with a pretty image */
    if (background != NULL) {
        /* Tile the map background */
        for (y = 0; y < height + background->rgb_height;
                y += background->rgb_height) {
            for (x = 0; x < width + background->rgb_width;
                    x += background->rgb_width) {
                bg = GNOME_CANVAS_IMAGE(gnome_canvas_item_new(
                                            myCanvasGroup, gnome_canvas_image_get_type(), "x",
                                            (double) x, "y", (double) y, "width",
                                            (double) background->rgb_width, "height",
                                            (double) background->rgb_height, "image", background,
                                            "anchor", (GtkAnchorType) GTK_ANCHOR_CENTER, NULL));
                gnome_canvas_item_lower_to_bottom(GNOME_CANVAS_ITEM(bg));
            }
        }
    }

    /* ghack_map.map is an array of canvas images.  Each cell of
     * the array will contain one tile.  Here, we create the
     * space for the cells and then create the cells for easy
     * access later.
    */
    for (i = 0, y = 0; y < height; y += ghack_glyph_height()) {
        for (x = 0; x < width; x += ghack_glyph_width()) {
            ghack_map.map[i++] = GNOME_CANVAS_IMAGE(gnome_canvas_item_new(
                    myCanvasGroup, gnome_canvas_image_get_type(), "x", (double) x,
                    "y", (double) y, "width", (double) ghack_glyph_width(),
                    "height", (double) ghack_glyph_height(), "anchor",
                    GTK_ANCHOR_NORTH_WEST, NULL));
        }
    }

    if (petmark != NULL) {
        /* ghack_map.overlay is an array of canvas images used to
         * overlay tile images...
        */
        for (i = 0, y = 0; y < height; y += ghack_glyph_height()) {
            for (x = 0; x < width; x += ghack_glyph_width()) {
                ghack_map.overlay[i] =
                    GNOME_CANVAS_IMAGE(gnome_canvas_item_new(
                                           myCanvasGroup, gnome_canvas_image_get_type(), "x",
                                           (double) x, "y", (double) y, "width",
                                           (double) petmark->rgb_width, "height",
                                           (double) petmark->rgb_height, "image", petmark,
                                           "anchor", GTK_ANCHOR_NORTH_WEST, NULL));
                gnome_canvas_item_lower_to_bottom(
                    GNOME_CANVAS_ITEM(ghack_map.overlay[i++]));
            }
        }
    }

    ghack_map_cliparound(NULL, u.ux, u.uy, NULL);
    ghack_map_cursor_to(NULL, u.ux, u.uy, NULL);
    gnome_canvas_update_now(ghack_map.canvas);
    doredraw();
}
コード例 #7
0
ファイル: gevasevh_group_selector.c プロジェクト: Limsik/e17
static void clean( GtkgEvasObjCollection* c )
{
    if( !c ) return;
    gtk_object_destroy( GTK_OBJECT(c) );
//    gtk_object_unref( GTK_OBJECT(c) );
}
コード例 #8
0
ファイル: wire-item.c プロジェクト: Miuler/oregano
static void
wire_delete_callback (Wire *wire, WireItem *item)
{
	gtk_object_destroy (GTK_OBJECT (item));
}
コード例 #9
0
ファイル: anypaper_preview.c プロジェクト: mogaal/anypaper
static void show_preview_quit ( GtkWidget *widget, AnypaperPreview *preview)
{
	timeout_destroy(preview->priv->source);
	gtk_object_destroy(GTK_OBJECT(preview->priv->window));
}
コード例 #10
0
static void gmpc_meta_data_widgets_similar_songs_metadata_changed (GmpcMetaDataWidgetsSimilarSongs* self, GmpcMetaWatcher* gmw2, const mpd_Song* song, MetaDataType type, MetaDataResult _result_, const MetaData* met) {
	gint _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (gmw2 != NULL);
	g_return_if_fail (song != NULL);
	_tmp0_ = g_utf8_collate (self->priv->song->artist, song->artist);
	if (_tmp0_ != 0) {
		return;
	}
	if (type != META_SONG_SIMILAR) {
		return;
	}
	if (self->priv->pchild != NULL) {
		gtk_object_destroy ((GtkObject*) self->priv->pchild);
	}
	if (_result_ == META_DATA_FETCHING) {
		const gchar* _tmp1_ = NULL;
		GtkLabel* _tmp2_ = NULL;
		GtkLabel* label;
		GtkWidget* _tmp3_;
		_tmp1_ = _ ("Fetching .. ");
		_tmp2_ = (GtkLabel*) gtk_label_new (_tmp1_);
		label = g_object_ref_sink (_tmp2_);
		gtk_misc_set_alignment ((GtkMisc*) label, 0.0f, 0.0f);
		gtk_container_add ((GtkContainer*) self, (GtkWidget*) label);
		_tmp3_ = _g_object_ref0 ((GtkWidget*) label);
		_g_object_unref0 (self->priv->pchild);
		self->priv->pchild = _tmp3_;
		_g_object_unref0 (label);
	} else {
		if (_result_ == META_DATA_UNAVAILABLE) {
			const gchar* _tmp4_ = NULL;
			GtkLabel* _tmp5_ = NULL;
			GtkLabel* label;
			GtkWidget* _tmp6_;
			_tmp4_ = _ ("Unavailable");
			_tmp5_ = (GtkLabel*) gtk_label_new (_tmp4_);
			label = g_object_ref_sink (_tmp5_);
			gtk_misc_set_alignment ((GtkMisc*) label, 0.0f, 0.0f);
			gtk_container_add ((GtkContainer*) self, (GtkWidget*) label);
			_tmp6_ = _g_object_ref0 ((GtkWidget*) label);
			_g_object_unref0 (self->priv->pchild);
			self->priv->pchild = _tmp6_;
			_g_object_unref0 (label);
		} else {
			gboolean _tmp7_;
			_tmp7_ = meta_data_is_text_list (met);
			if (_tmp7_) {
				MetaData* _tmp8_ = NULL;
				guint _tmp9_;
				_tmp8_ = meta_data_dup_steal (met);
				_meta_data_free0 (self->priv->copy);
				self->priv->copy = _tmp8_;
				_tmp9_ = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, _gmpc_meta_data_widgets_similar_songs_update_sim_song_gsource_func, g_object_ref (self), g_object_unref);
				self->priv->idle_add = _tmp9_;
				return;
			} else {
				const gchar* _tmp10_ = NULL;
				GtkLabel* _tmp11_ = NULL;
				GtkLabel* label;
				GtkWidget* _tmp12_;
				_tmp10_ = _ ("Unavailable");
				_tmp11_ = (GtkLabel*) gtk_label_new (_tmp10_);
				label = g_object_ref_sink (_tmp11_);
				gtk_misc_set_alignment ((GtkMisc*) label, 0.0f, 0.0f);
				gtk_container_add ((GtkContainer*) self, (GtkWidget*) label);
				_tmp12_ = _g_object_ref0 ((GtkWidget*) label);
				_g_object_unref0 (self->priv->pchild);
				self->priv->pchild = _tmp12_;
				_g_object_unref0 (label);
			}
		}
	}
	gtk_widget_show_all ((GtkWidget*) self);
}
コード例 #11
0
static gboolean gmpc_meta_data_widgets_similar_songs_update_sim_song (GmpcMetaDataWidgetsSimilarSongs* self) {
	gboolean result = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	if (self->priv->current == NULL) {
		GList* _tmp0_ = NULL;
		GtkProgressBar* _tmp1_ = NULL;
		_tmp0_ = meta_data_get_text_list (self->priv->copy);
		self->priv->current = _tmp0_;
		_tmp1_ = (GtkProgressBar*) gtk_progress_bar_new ();
		_g_object_unref0 (self->priv->pchild);
		self->priv->pchild = (GtkWidget*) g_object_ref_sink (_tmp1_);
		gtk_container_add ((GtkContainer*) self, self->priv->pchild);
		gtk_widget_show_all ((GtkWidget*) self);
	}
	gtk_progress_bar_pulse (GTK_PROGRESS_BAR (self->priv->pchild));
	if (self->priv->current != NULL) {
		gchar* _tmp2_;
		gchar* entry;
		_tmp2_ = g_strdup ((const gchar*) self->priv->current->data);
		entry = _tmp2_;
		if (entry != NULL) {
			gchar** _tmp3_;
			gchar** _tmp4_ = NULL;
			gchar** split;
			gint split_length1;
			gint _split_size_;
			_tmp4_ = _tmp3_ = g_strsplit (entry, "::", 2);
			split = _tmp4_;
			split_length1 = _vala_array_length (_tmp3_);
			_split_size_ = _vala_array_length (_tmp3_);
			if (split_length1 == 2) {
				gchar** _tmp5_;
				gchar** _tmp6_ = NULL;
				gchar** art_split;
				gint art_split_length1;
				gint _art_split_size_;
				MpdData* _tmp8_ = NULL;
				MpdData* data;
				mpd_database_search_start (connection, FALSE);
				_tmp6_ = _tmp5_ = g_strsplit (split[0], " ", 0);
				art_split = _tmp6_;
				art_split_length1 = _vala_array_length (_tmp5_);
				_art_split_size_ = _vala_array_length (_tmp5_);
				{
					gchar** artist_collection;
					int artist_collection_length1;
					int artist_it;
					artist_collection = art_split;
					artist_collection_length1 = art_split_length1;
					for (artist_it = 0; artist_it < art_split_length1; artist_it = artist_it + 1) {
						gchar* _tmp7_;
						gchar* artist;
						_tmp7_ = g_strdup (artist_collection[artist_it]);
						artist = _tmp7_;
						{
							mpd_database_search_add_constraint (connection, MPD_TAG_ITEM_ARTIST, artist);
							_g_free0 (artist);
						}
					}
				}
				mpd_database_search_add_constraint (connection, MPD_TAG_ITEM_TITLE, split[1]);
				_tmp8_ = mpd_database_search_commit (connection);
				data = _tmp8_;
				if (data != NULL) {
					MpdData* _tmp9_;
					_tmp9_ = data;
					data = NULL;
					self->priv->item = mpd_data_concatenate (self->priv->item, _tmp9_);
				}
				_mpd_data_free0 (data);
				art_split = (_vala_array_free (art_split, art_split_length1, (GDestroyNotify) g_free), NULL);
			}
			split = (_vala_array_free (split, split_length1, (GDestroyNotify) g_free), NULL);
		}
		self->priv->current = self->priv->current->next;
		if (self->priv->current != NULL) {
			result = TRUE;
			_g_free0 (entry);
			return result;
		}
		_g_free0 (entry);
	}
	gtk_object_destroy ((GtkObject*) self->priv->pchild);
	if (self->priv->item != NULL) {
		GmpcMpdDataModel* _tmp10_ = NULL;
		GmpcMpdDataModel* model;
		MpdData* _tmp11_;
		GmpcMpdDataTreeview* _tmp12_ = NULL;
		GmpcMpdDataTreeview* tree;
		GtkWidget* _tmp13_;
		_tmp10_ = gmpc_mpddata_model_new ();
		model = _tmp10_;
		self->priv->item = misc_mpddata_remove_duplicate_songs (self->priv->item);
		_tmp11_ = self->priv->item;
		self->priv->item = NULL;
		gmpc_mpddata_model_set_mpd_data (model, _tmp11_);
		_tmp12_ = gmpc_mpddata_treeview_new ("similar-song", TRUE, (GtkTreeModel*) model);
		tree = g_object_ref_sink (_tmp12_);
		gmpc_mpddata_treeview_enable_click_fix (tree);
		g_signal_connect_object ((GtkWidget*) tree, "button-release-event", (GCallback) _gmpc_meta_data_widgets_similar_songs_tree_right_menu_gtk_widget_button_release_event, self, 0);
		g_signal_connect_object ((GtkTreeView*) tree, "row-activated", (GCallback) _gmpc_meta_data_widgets_similar_songs_tree_row_activated_gtk_tree_view_row_activated, self, 0);
		gtk_container_add ((GtkContainer*) self, (GtkWidget*) tree);
		_tmp13_ = _g_object_ref0 ((GtkWidget*) tree);
		_g_object_unref0 (self->priv->pchild);
		self->priv->pchild = _tmp13_;
		_g_object_unref0 (tree);
		_g_object_unref0 (model);
	} else {
		const gchar* _tmp14_ = NULL;
		GtkLabel* _tmp15_ = NULL;
		GtkLabel* label;
		GtkWidget* _tmp16_;
		_tmp14_ = _ ("Unavailable");
		_tmp15_ = (GtkLabel*) gtk_label_new (_tmp14_);
		label = g_object_ref_sink (_tmp15_);
		gtk_misc_set_alignment ((GtkMisc*) label, 0.0f, 0.0f);
		gtk_container_add ((GtkContainer*) self, (GtkWidget*) label);
		_tmp16_ = _g_object_ref0 ((GtkWidget*) label);
		_g_object_unref0 (self->priv->pchild);
		self->priv->pchild = _tmp16_;
		_g_object_unref0 (label);
	}
	_meta_data_free0 (self->priv->copy);
	self->priv->copy = NULL;
	self->priv->idle_add = (guint) 0;
	gtk_widget_show_all ((GtkWidget*) self);
	result = FALSE;
	return result;
}
コード例 #12
0
ファイル: gui.c プロジェクト: ekoontz/graphviz
int update_graph_properties(Agraph_t * graph)	//updates graph from gui
{
    FILE *file;
    int respond = 0;
    int id = 0;
    //check the graph name  should not be duplicated graph names
    for (id = 0; id < view->graphCount; id++) {
	if (graph != view->g[id]) {
	    if (strcasecmp
		(gtk_entry_get_text ((GtkEntry *)
		  glade_xml_get_widget(xml, "entryGraphName")),
		 GD_GraphName(view->g[id])) ==
		0) {

		Dlg = (GtkMessageDialog *) gtk_message_dialog_new(NULL,
								  GTK_DIALOG_MODAL,
								  GTK_MESSAGE_WARNING,
								  GTK_BUTTONS_OK,
								  "There is another graph with this name!");
		respond = gtk_dialog_run((GtkDialog *) Dlg);
		gtk_object_destroy((GtkObject *) Dlg);
		return 0;

	    }

	}
    }

    //check if file is changed
    if (strcasecmp
	(gtk_entry_get_text
	 ((GtkEntry *) glade_xml_get_widget(xml, "entryGraphFileName")),
	 GD_GraphFileName(graph)) != 0) {


	if ((file =
	     fopen(gtk_entry_get_text
		   ((GtkEntry *)
		    glade_xml_get_widget(xml, "entryGraphFileName")),
		   "r"))) {
	    fclose(file);
	    Dlg = (GtkMessageDialog *) gtk_message_dialog_new(NULL,
							      GTK_DIALOG_MODAL,
							      GTK_MESSAGE_QUESTION,
							      GTK_BUTTONS_YES_NO,
							      "File name you have entered already exists\n,this will cause overwriting on existing file.\nAre you sure?");
	    respond = gtk_dialog_run((GtkDialog *) Dlg);
	    gtk_object_destroy((GtkObject *) Dlg);

	    if (respond == GTK_RESPONSE_NO)
		return 0;
	}
	//now check if filename is legal, try to open it to write
	if ((file =
	     fopen(gtk_entry_get_text
		   ((GtkEntry *)
		    glade_xml_get_widget(xml, "entryGraphFileName")),
		   "w")))
	    fclose(file);
	else {
	    Dlg = (GtkMessageDialog *) gtk_message_dialog_new(NULL,
							      GTK_DIALOG_MODAL,
							      GTK_MESSAGE_WARNING,
							      GTK_BUTTONS_OK,
							      "File name is invalid or I/O error!");

	    respond = gtk_dialog_run((GtkDialog *) Dlg);
	    gtk_object_destroy((GtkObject *) Dlg);
	    GTK_DIALOG(Dlg);

	    return 0;
	}

    }


    //if it comes so far graph deserves new values

    GD_GraphName(graph) =
	(char *) gtk_entry_get_text((GtkEntry *)
				    glade_xml_get_widget(xml,
							 "entryGraphName"));
    GD_GraphFileName(graph) =
	(char *) gtk_entry_get_text((GtkEntry *)
				    glade_xml_get_widget(xml,
							 "entryGraphFileName"));

    GD_AlwaysShow(graph) =
	gtk_toggle_button_get_active((GtkToggleButton *)
				     glade_xml_get_widget(xml,
							  "chkVisible"));
    GD_Locked(graph) =
	gtk_toggle_button_get_active((GtkToggleButton *)
				     glade_xml_get_widget(xml,
							  "chkLocked"));
    GD_TopView(graph) =
	gtk_toggle_button_get_active((GtkToggleButton *)
				     glade_xml_get_widget(xml,
							  "chkTopView"));


    //check if the engine has been changed, if so do new layout
    if (GD_Engine(graph) != gtk_combo_box_get_active((GtkComboBox *)
				 glade_xml_get_widget(xml, "cbLayout"))) {
	Dlg =
	    (GtkMessageDialog *) gtk_message_dialog_new(NULL,
							GTK_DIALOG_MODAL,
							GTK_MESSAGE_QUESTION,
							GTK_BUTTONS_YES_NO,
							"You have changed the layout of the graph,this will change the graph layout\n all your position changes will be lost\n Are you sure?");
	respond = gtk_dialog_run((GtkDialog *) Dlg);
	if (respond == GTK_RESPONSE_YES)
	    do_graph_layout(graph,
			    gtk_combo_box_get_active((GtkComboBox *)
						     glade_xml_get_widget
						     (xml, "cbLayout")),
			    0);
	gtk_object_destroy((GtkObject *) Dlg);
    }
    return 1;
}
コード例 #13
0
ファイル: trashapplet.c プロジェクト: david-xie/mate-applets
static gboolean
confirm_delete_immediately (GtkWidget *parent_view,
                            gint num_files,
                            gboolean all)
{
  GdkScreen *screen;
  GtkWidget *dialog, *hbox, *vbox, *image, *label;
  gchar *str, *prompt, *detail;
  int response;

  screen = gtk_widget_get_screen (parent_view);

  dialog = gtk_dialog_new ();
  gtk_window_set_screen (GTK_WINDOW (dialog), screen);
  atk_object_set_role (gtk_widget_get_accessible (dialog), ATK_ROLE_ALERT);
  gtk_window_set_title (GTK_WINDOW (dialog), _("Delete Immediately?"));
  gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
  gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
  gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);

  gtk_widget_realize (dialog);
  gdk_window_set_transient_for (gtk_widget_get_window (GTK_WIDGET (dialog)),
                                gdk_screen_get_root_window (screen));
  gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);

  gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 14);

  hbox = gtk_hbox_new (FALSE, 12);
  gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
  gtk_widget_show (hbox);
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox,
                      FALSE, FALSE, 0);

  image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_QUESTION,
                                    GTK_ICON_SIZE_DIALOG);
  gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
  gtk_widget_show (image);
  gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);

  vbox = gtk_vbox_new (FALSE, 12);
  gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
  gtk_widget_show (vbox);

  if (all)
    {
      prompt = _("Cannot move items to trash, do you want to delete them immediately?");
      detail = g_strdup_printf ("None of the %d selected items can be moved to the Trash", num_files);
    }
  else
    {
      prompt = _("Cannot move some items to trash, do you want to delete these immediately?");
      detail = g_strdup_printf ("%d of the selected items cannot be moved to the Trash", num_files);
    }

  str = g_strconcat ("<span weight=\"bold\" size=\"larger\">",
                     prompt, "</span>", NULL);
  label = gtk_label_new (str);
  gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
  gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
  gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
  gtk_widget_show (label);
  g_free (str);

  label = gtk_label_new (detail);
  gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
  gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
  gtk_widget_show (label);
  g_free (detail);

  gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL,
                         GTK_RESPONSE_CANCEL);
  gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_DELETE,
                         GTK_RESPONSE_YES);
  gtk_dialog_set_default_response (GTK_DIALOG (dialog),
                                   GTK_RESPONSE_YES);

  response = gtk_dialog_run (GTK_DIALOG (dialog));

  gtk_object_destroy (GTK_OBJECT (dialog));

  return response == GTK_RESPONSE_YES;
}
コード例 #14
0
/*****************************************************************************
 * Run: Gtk+ thread
 *****************************************************************************
 * this part of the interface is in a separate thread so that we can call
 * gtk_main() from within it without annoying the rest of the program.
 *****************************************************************************/
static void Run( intf_thread_t *p_intf )
{
#ifndef NEED_GTK2_MAIN
    /* gtk_init needs to know the command line. We don't care, so we
     * give it an empty one */
    char  *p_args[] = { "", NULL };
    char **pp_args  = p_args;
    int    i_args   = 1;
    int    i_dummy;
#endif
    playlist_t        *p_playlist;
    GtkCellRenderer   *p_renderer = NULL;
    GtkTreeViewColumn *p_column   = NULL;
    GtkListStore      *p_filelist = NULL;
    GtkListStore      *p_playlist_store = NULL;

#ifndef NEED_GTK2_MAIN
    gtk_set_locale ();
    msg_Dbg( p_intf, "Starting pda GTK2+ interface" );
    gtk_init( &i_args, &pp_args );
#else
    /* Initialize Gtk+ */
    msg_Dbg( p_intf, "Starting pda GTK2+ interface thread" );
    gdk_threads_enter();
#endif

    /* Create some useful widgets that will certainly be used */
/* FIXME: magic path */
    add_pixmap_directory("share");
    add_pixmap_directory("/usr/share/vlc");

    /* Path for pixmaps under linupy 1.4 */
    add_pixmap_directory("/usr/local/share/pixmaps/vlc");
    /* Path for pixmaps under linupy 2.0 */
    add_pixmap_directory("/usr/share/pixmaps/vlc");

    p_intf->p_sys->p_window = create_pda();
    if (p_intf->p_sys->p_window == NULL)
    {
        msg_Err( p_intf, "unable to create pda interface" );
    }

    /* Store p_intf to keep an eye on it */
    gtk_object_set_data( GTK_OBJECT(p_intf->p_sys->p_window),
                         "p_intf", p_intf );

    /* Set the title of the main window */
    gtk_window_set_title( GTK_WINDOW(p_intf->p_sys->p_window),
                          VOUT_TITLE " (PDA Linux interface)");

    /* Get the notebook object */
    p_intf->p_sys->p_notebook = GTK_NOTEBOOK( gtk_object_get_data(
        GTK_OBJECT( p_intf->p_sys->p_window ), "notebook" ) );

    /* Get the slider object */
    p_intf->p_sys->p_slider = (GtkHScale*) lookup_widget( p_intf->p_sys->p_window, "timeSlider" );
    p_intf->p_sys->p_slider_label = (GtkLabel*) lookup_widget( p_intf->p_sys->p_window, "timeLabel" );
    if (p_intf->p_sys->p_slider == NULL)
        msg_Err( p_intf, "Time slider widget not found." );
    if (p_intf->p_sys->p_slider_label == NULL)
        msg_Err( p_intf, "Time label widget not found." );

    /* Connect the date display to the slider */
    p_intf->p_sys->p_adj = gtk_range_get_adjustment( GTK_RANGE(p_intf->p_sys->p_slider) );
    if (p_intf->p_sys->p_adj == NULL)
        msg_Err( p_intf, "Adjustment range not found." );
    g_signal_connect( GTK_OBJECT( p_intf->p_sys->p_adj ), "value_changed",
                         G_CALLBACK( E_(GtkDisplayDate) ), p_intf );
    p_intf->p_sys->f_adj_oldvalue = 0;
    p_intf->p_sys->i_adj_oldvalue = 0;

    /* BEGIN OF FILEVIEW GTK_TREE_VIEW */
    p_intf->p_sys->p_tvfile = NULL;
    p_intf->p_sys->p_tvfile = (GtkTreeView *) lookup_widget( p_intf->p_sys->p_window,
                                                             "tvFileList");
    if (NULL == p_intf->p_sys->p_tvfile)
       msg_Err(p_intf, "Error obtaining pointer to File List");

    /* Insert columns 0 */
    p_renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 0, (gchar *) N_("Filename"), p_renderer, NULL);
    p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvfile, 0 );
    gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 0 );
    gtk_tree_view_column_set_sort_column_id(p_column, 0);
    /* Insert columns 1 */
    p_renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 1, (gchar *) N_("Permissions"), p_renderer, NULL);
    p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvfile, 1 );
    gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 1 );
    gtk_tree_view_column_set_sort_column_id(p_column, 1);
    /* Insert columns 2 */
    p_renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 2, (gchar *) N_("Size"), p_renderer, NULL);
    p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvfile, 2 );
    gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 2 );
    gtk_tree_view_column_set_sort_column_id(p_column, 2);
    /* Insert columns 3 */
    p_renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 3, (gchar *) N_("Owner"), p_renderer, NULL);
    p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvfile, 3 );
    gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 3 );
    gtk_tree_view_column_set_sort_column_id(p_column, 3);
    /* Insert columns 4 */
    p_renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 4, (gchar *) N_("Group"), p_renderer, NULL);
    p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvfile, 4 );
    gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 4 );
    gtk_tree_view_column_set_sort_column_id(p_column, 4);

    /* Get new directory listing */
    p_filelist = gtk_list_store_new (5,
                G_TYPE_STRING, /* Filename */
                G_TYPE_STRING, /* permissions */
                G_TYPE_UINT64, /* File size */
                G_TYPE_STRING, /* Owner */
                G_TYPE_STRING);/* Group */
    ReadDirectory(p_intf, p_filelist, ".");
    gtk_tree_view_set_model(GTK_TREE_VIEW(p_intf->p_sys->p_tvfile), GTK_TREE_MODEL(p_filelist));
    g_object_unref(p_filelist);     /* Model will be released by GtkTreeView */
    gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(p_intf->p_sys->p_tvfile)),GTK_SELECTION_MULTIPLE);

    /* Column properties */
    gtk_tree_view_set_headers_visible(p_intf->p_sys->p_tvfile, TRUE);
    gtk_tree_view_columns_autosize(p_intf->p_sys->p_tvfile);
    gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(p_intf->p_sys->p_tvfile),TRUE);
    /* END OF FILEVIEW GTK_TREE_VIEW */

    /* BEGIN OF PLAYLIST GTK_TREE_VIEW */
    p_intf->p_sys->p_tvplaylist = NULL;
    p_intf->p_sys->p_tvplaylist = (GtkTreeView *) lookup_widget( p_intf->p_sys->p_window, "tvPlaylist");
    if (NULL == p_intf->p_sys->p_tvplaylist)
       msg_Err(p_intf, "Error obtaining pointer to Play List");

    /* Columns 1 */
    p_renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvplaylist, 0, (gchar *) N_("Filename"), p_renderer, NULL);
    p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvplaylist, 0 );
    gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 0 );
    gtk_tree_view_column_set_sort_column_id(p_column, 0);
    /* Column 2 */
    p_renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvplaylist, 1, (gchar *) N_("Time"), p_renderer, NULL);
    p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvplaylist, 1 );
    gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 1 );
    gtk_tree_view_column_set_sort_column_id(p_column, 1);
#if 0
    /* Column 3 - is a hidden column used for reliable deleting items from the underlying playlist */
    p_renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvplaylist, 2, (gchar *) N_("Index"), p_renderer, NULL);
    p_column = gtk_tree_view_get_column(p_intf->p_sys->p_tvplaylist, 2 );
    gtk_tree_view_column_add_attribute(p_column, p_renderer, "text", 2 );
    gtk_tree_view_column_set_sort_column_id(p_column, 2);
#endif
    /* update the playlist */
    p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
    p_playlist_store = gtk_list_store_new (3,
                G_TYPE_STRING, /* Filename */
                G_TYPE_STRING, /* Time */
                G_TYPE_UINT);  /* Hidden index */
    PlaylistRebuildListStore(p_playlist_store, p_playlist);
    gtk_tree_view_set_model(GTK_TREE_VIEW(p_intf->p_sys->p_tvplaylist), GTK_TREE_MODEL(p_playlist_store));
    g_object_unref(p_playlist_store);
    vlc_object_release(p_playlist); /* Free the playlist */
    gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(p_intf->p_sys->p_tvplaylist)),GTK_SELECTION_MULTIPLE);

    /* Column properties */
    gtk_tree_view_set_headers_visible(p_intf->p_sys->p_tvplaylist, TRUE);
    gtk_tree_view_columns_autosize(p_intf->p_sys->p_tvplaylist);
    gtk_tree_view_set_headers_clickable(p_intf->p_sys->p_tvplaylist, TRUE);
    /* END OF PLAYLIST GTK_TREE_VIEW */

    /* Hide the Preference TAB for now. */
    GtkWidget *p_preference_tab = NULL;
    p_preference_tab = gtk_notebook_get_nth_page(p_intf->p_sys->p_notebook,5);
    if (p_preference_tab != NULL)
      gtk_widget_hide(p_preference_tab);

    /* Show the control window */
    gtk_widget_show( p_intf->p_sys->p_window );

#ifdef NEED_GTK2_MAIN
    msg_Dbg( p_intf, "Manage GTK keyboard events using threads" );
    while( !p_intf->b_die )
    {
        Manage( p_intf );

        /* Sleep to avoid using all CPU - since some interfaces need to
         * access keyboard events, a 100ms delay is a good compromise */
        gdk_threads_leave();
        if (p_intf->p_libvlc->i_cpu & CPU_CAPABILITY_FPU)
            msleep( INTF_IDLE_SLEEP );
        else
            msleep( 1000 );
        gdk_threads_enter();
    }
#else
    msg_Dbg( p_intf, "Manage GTK keyboard events using timeouts" );
    /* Sleep to avoid using all CPU - since some interfaces needs to access
     * keyboard events, a 1000ms delay is a good compromise */
    if (p_intf->p_libvlc->i_cpu & CPU_CAPABILITY_FPU)
        i_dummy = gtk_timeout_add( INTF_IDLE_SLEEP / 1000, (GtkFunction)Manage, p_intf );
    else
        i_dummy = gtk_timeout_add( 1000, (GtkFunction)Manage, p_intf );

    /* Enter Gtk mode */
    gtk_main();
    /* Remove the timeout */
    gtk_timeout_remove( i_dummy );
#endif

    gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_window) );
#ifdef NEED_GTK2_MAIN
    gdk_threads_leave();
#endif
}
コード例 #15
0
ファイル: draw-context.c プロジェクト: benjohnson2001/base
static void
spdc_concat_colors_and_flush (SPDrawContext *dc, gboolean forceclosed)
{
	SPCurve *c;

	/* Concat RBG */
	c = dc->green_curve;

	/* Green */
	dc->green_curve = sp_curve_new_sized (64);
	while (dc->green_bpaths) {
		gtk_object_destroy (GTK_OBJECT (dc->green_bpaths->data));
		dc->green_bpaths = g_slist_remove (dc->green_bpaths, dc->green_bpaths->data);
	}
	/* Blue */
	sp_curve_append_continuous (c, dc->blue_curve, 0.0625);
	sp_curve_reset (dc->blue_curve);
	sp_canvas_bpath_set_bpath (SP_CANVAS_BPATH (dc->blue_bpath), NULL);
	/* Red */
	sp_curve_append_continuous (c, dc->red_curve, 0.0625);
	sp_curve_reset (dc->red_curve);
	sp_canvas_bpath_set_bpath (SP_CANVAS_BPATH (dc->red_bpath), NULL);

	/* Step A - test, whether we ended on green anchor */
	if (forceclosed || (dc->green_anchor && dc->green_anchor->active)) {
		g_print ("We hit green anchor, closing Green-Blue-Red\n");
		sp_curve_closepath_current (c);
		/* Closed path, just flush */
		spdc_flush_white (dc, c);
		sp_curve_unref (c);
		return;
	}

	/* Step B - both start and end anchored to same curve */
	if (dc->sa && dc->ea && (dc->sa->curve == dc->ea->curve)) {
		g_print ("We hit bot start and end of single curve, closing paths\n");
		if (dc->sa->start) {
			SPCurve *r;
			g_print ("Reversing curve\n");
			r = sp_curve_reverse (c);
			sp_curve_unref (c);
			c = r;
		}
		sp_curve_append_continuous (dc->sa->curve, c, 0.0625);
		sp_curve_unref (c);
		sp_curve_closepath_current (dc->sa->curve);
		spdc_flush_white (dc, NULL);
		return;
	}

	/* Step C - test start */
	if (dc->sa) {
		SPCurve *s;
		g_print ("Curve start hit anchor\n");
		s = dc->sa->curve;
		dc->white_curves = g_slist_remove (dc->white_curves, s);
		if (dc->sa->start) {
			SPCurve *r;
			g_print ("Reversing curve\n");
			r = sp_curve_reverse (s);
			sp_curve_unref (s);
			s = r;
		}
		sp_curve_append_continuous (s, c, 0.0625);
		sp_curve_unref (c);
		c = s;
	}

	/* Step D - test end */
	if (dc->ea) {
		SPCurve *e;
		g_print ("Curve end hit anchor\n");
		e = dc->ea->curve;
		dc->white_curves = g_slist_remove (dc->white_curves, e);
		if (!dc->ea->start) {
			SPCurve *r;
			g_print ("Reversing curve\n");
			r = sp_curve_reverse (e);
			sp_curve_unref (e);
			e = r;
		}
		sp_curve_append_continuous (c, e, 0.0625);
		sp_curve_unref (e);
	}

	spdc_flush_white (dc, c);

	sp_curve_unref (c);
}
コード例 #16
0
static const gchar*
tny_gnome_keyring_password_getter_get_password (TnyPasswordGetter *self, const gchar *aid, const gchar *prompt, gboolean *cancel)
{
	gchar *retval = NULL;
	GList *list;
	GnomeKeyringResult keyringret;
	gchar *keyring;

	gnome_keyring_get_default_keyring_sync (&keyring);

	keyringret = gnome_keyring_find_network_password_sync (aid, "Mail", 
		aid /* hostname */,
		"password", aid /* proto */, 
		"PLAIN", 0, &list);

	if ((keyringret != GNOME_KEYRING_RESULT_OK) || (list == NULL))
	{
		gboolean canc = FALSE;

		GnomePasswordDialog *dialog = GNOME_PASSWORD_DIALOG 
				(gnome_password_dialog_new
					(_("Enter password"), prompt,
					NULL, 
					NULL, TRUE));

		gnome_password_dialog_set_domain (dialog, "Mail");
		gnome_password_dialog_set_remember (dialog, 
			GNOME_PASSWORD_DIALOG_REMEMBER_FOREVER);

		gnome_password_dialog_set_readonly_username (dialog, TRUE);
		/* gnome_password_dialog_set_username (dialog, 
			tny_account_get_user (account)); */

		gnome_password_dialog_set_show_username (dialog, FALSE);
		gnome_password_dialog_set_show_remember (dialog, 
			gnome_keyring_is_available ());
		gnome_password_dialog_set_show_domain (dialog, FALSE);
		gnome_password_dialog_set_show_userpass_buttons (dialog, FALSE);

		canc = gnome_password_dialog_run_and_block (dialog);

		if (canc)
		{
			guint32 item_id;
			GnomePasswordDialogRemember r;

			retval = gnome_password_dialog_get_password (dialog);

			mlock (retval, strlen (retval));

			r = gnome_password_dialog_get_remember (dialog);

			if (r == GNOME_PASSWORD_DIALOG_REMEMBER_FOREVER)
			{
				gnome_keyring_set_network_password_sync (keyring,
					aid /* user */,
					"Mail", aid /* hostname */,
					"password", aid /* proto */, 
					"PLAIN", 0, retval, &item_id);
			}
		} else retval = NULL;

		*cancel = (!canc);

		/* this causes warnings, but should be done afaik */
		gtk_object_destroy (GTK_OBJECT (dialog));

		while (gtk_events_pending ())
			gtk_main_iteration ();

	} else {

		GnomeKeyringNetworkPasswordData *pwd_data;
		pwd_data = list->data;
		retval = g_strdup (pwd_data->password);

		*cancel = FALSE;

		gnome_keyring_network_password_list_free (list);
	}

	return retval;
}
コード例 #17
0
ファイル: selector.cpp プロジェクト: wdmchaft/DoonSketch
 ~SelectorPoint() {
     gtk_object_destroy(_rubber);
 }
コード例 #18
0
ファイル: gtkam-chooser.c プロジェクト: gphoto/gtkam
static GtkamCamera *
gtkam_chooser_get_camera (GtkamChooser *chooser)
{
	GtkWidget *dialog, *status;
	GPPortInfo info;
	Camera *camera;
	CameraAbilities abilities;
	const gchar *model, *port, *speed;
	gchar *port_path, *right, *tmp;
	int m, p, r;
	gboolean multi;
	GtkamCamera *c;

	model = gtk_entry_get_text (chooser->priv->entry_model);
	port  = gtk_entry_get_text (chooser->priv->entry_port);
	speed = gtk_entry_get_text (chooser->priv->entry_speed);
	multi = GTK_TOGGLE_BUTTON (chooser->priv->check_multi)->active;

	if (!port || !*port)
		port_path = g_strdup (_("None"));
	else {
		port_path = g_strdup (port);
		right = strrchr (port_path, ')');
		*right = '\0';
		tmp = g_strdup (strrchr (port_path, '(') + 1);
		g_free (port_path);
		port_path = tmp;
	}

	gp_camera_new (&camera);
#ifdef HAVE_GP_CAMERA_SET_TIMEOUT_FUNCS
	gp_camera_set_timeout_funcs (camera, start_timeout_func,
				     stop_timeout_func, NULL);
#endif

	/* Model? */
	m = gp_abilities_list_lookup_model (chooser->priv->al, model);
	gp_abilities_list_get_abilities (chooser->priv->al, m, &abilities);
	gp_camera_set_abilities (camera, abilities);

	/* Port? */
	if (strcmp (port_path, _("None"))) {
		p = gp_port_info_list_lookup_path (chooser->priv->il,
						   port_path);
		gp_port_info_list_get_info (chooser->priv->il, p, &info);
		gp_camera_set_port_info (camera, info);
	}

	/* Speed? */
	if (strcmp (speed, _("Best")))
		gp_camera_set_port_speed (camera, atoi (speed));

	/*
	 * Initialize the camera to check if it is really there. Exit
	 * afterwards because other applications could need the camera, too.
	 */
	status = gtkam_status_new (_("Initializing camera..."));
	gtkam_dialog_add_status (GTKAM_DIALOG (chooser), status);
	r = gp_camera_init (camera, GTKAM_STATUS (status)->context->context);
	if (multi)
		gp_camera_exit (camera, NULL);
	switch (r) {
	case GP_OK:
		break;
	case GP_ERROR_CANCEL:
		g_free (port_path);
		break;
	default:
		g_free (port_path);
		dialog = gtkam_error_new (r, GTKAM_STATUS (status)->context,
			NULL, _("Could not initialize camera."));
		gtk_window_set_transient_for (GTK_WINDOW (dialog),
					      GTK_WINDOW (chooser));
		gtk_widget_show (dialog);
		gp_camera_unref (camera);
		camera = NULL;
	}
	gtk_object_destroy (GTK_OBJECT (status));

	c = gtkam_camera_new (camera, multi);
	gp_camera_unref (camera);

	return (c);
}
コード例 #19
0
static gboolean
get_thumbnail_idle (gpointer data)
{
	GtkamList *list = GTKAM_LIST (data);
	GetThumbnailData *d;
	CameraFile *file;
	GtkWidget *s;
	GdkPixbuf *pixbuf;
	GdkPixbufLoader *loader;
	int result;
	const char *fd;
	unsigned long fs;
	gfloat factor;

	d = list->priv->head;
	if (d == NULL)
		return (FALSE);
	s = gtkam_status_new (_("Downloading thumbnail of '%s' from "
		"folder '%s'..."), d->name, d->folder);

	g_signal_emit (G_OBJECT (list), signals[NEW_STATUS], 0, s);
	gp_file_new (&file);
	result = gp_camera_file_get (d->camera->camera, d->folder, d->name,
			GP_FILE_TYPE_PREVIEW, file,
			GTKAM_STATUS (s)->context->context);
	if (d->camera->multi)
		gp_camera_exit (d->camera->camera, NULL);
	if (result >= 0) {
		gp_file_get_data_and_size (file, &fd, &fs);

		loader = gdk_pixbuf_loader_new ();
		gdk_pixbuf_loader_write (loader, fd, fs, NULL);
		gdk_pixbuf_loader_close (loader, NULL);
		pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
		gtk_list_store_set (list->priv->store, d->iter,
				    PREVIEW_ORIG_COLUMN, pixbuf, -1);
		factor = gtkam_list_get_zoom_factor (list);
		pixbuf = gdk_pixbuf_scale_simple (pixbuf,
			gdk_pixbuf_get_width (pixbuf) * factor,
			gdk_pixbuf_get_height (pixbuf) * factor,
			GDK_INTERP_BILINEAR);
		g_object_unref (G_OBJECT (loader));
		
		gtk_list_store_set (list->priv->store, d->iter,
				PREVIEW_COLUMN, pixbuf, -1);
		g_object_unref (G_OBJECT (pixbuf));
	} 
	
	gp_file_unref (file);
	gtk_object_destroy (GTK_OBJECT (s));

	if (result == GP_ERROR_CAMERA_BUSY)
		return (TRUE);

	g_object_unref (G_OBJECT (d->camera));
	g_free (d->name);
	g_free (d->folder);
	gtk_tree_iter_free (d->iter);
	list->priv->head = d->next;
	g_free (d);
	if (!list->priv->head)
		list->priv->tail = NULL;

	gtk_widget_destroy (s);
	
	if (list->priv->head == NULL)
		return (FALSE);
	else
		return (TRUE);
}
コード例 #20
0
ファイル: gtkam-chooser.c プロジェクト: gphoto/gtkam
static void
on_cancel_clicked (GtkButton *button, GtkamChooser *chooser)
{
	gtk_object_destroy (GTK_OBJECT (chooser));
}
コード例 #21
0
ファイル: gtkam-error.c プロジェクト: gphoto/gtkam
static void
on_error_ok_clicked (GtkButton *button, GtkamError *error)
{
	gtk_object_destroy (GTK_OBJECT (error));
}
コード例 #22
0
ファイル: class-inherit.c プロジェクト: rosedu/anjuta
/*----------------------------------------------------------------------------
 * Draw an expanded node. Function which simplifies cls_inherit_draw_graph().
 */
static void
cls_node_draw_expanded (ClsNode *cls_node)
{
	FooCanvasItem *canvas_item, *text_item;
	gint item_height, j;
	GList *members, *member;

	g_return_if_fail (cls_node->sym_manager != NULL);
	g_return_if_fail (cls_node->expansion_status == CLS_NODE_SEMI_EXPANDED ||
	                  cls_node->expansion_status == CLS_NODE_FULL_EXPANDED);
		
	if (cls_node->canvas_group)
		gtk_object_destroy (GTK_OBJECT (cls_node->canvas_group));
	cls_node->canvas_group =
		foo_canvas_item_new (foo_canvas_root
		                     (FOO_CANVAS (cls_node->canvas)),
		                     foo_canvas_group_get_type (),
		                     NULL);
	cls_node->drawn_expansion_status = cls_node->expansion_status;
	members = g_hash_table_get_values (cls_node->members);
	members = g_list_sort (members, (GCompareFunc)on_cls_node_item_compare);

	if (cls_node->expansion_status == CLS_NODE_SEMI_EXPANDED)
		item_height = cls_node->height / (g_list_length (members) + 2);
	else
		item_height = cls_node->height / (g_list_length (members) + 1);

	/* Class title */
	canvas_item =
		foo_canvas_item_new (FOO_CANVAS_GROUP (cls_node->canvas_group),
		                     foo_canvas_rect_get_type (),
		                     "x1", 0.0,
		                     "y1", 0.0,
		                     "x2", (gdouble) cls_node->width,
		                     "y2", (gdouble) item_height,
		                     "fill_color_gdk",
		                     &cls_node->plugin->style[STYLE_TITLE_BG],
		                     NULL);
	
	g_signal_connect (GTK_OBJECT (canvas_item), "event",
	                  G_CALLBACK (on_expanded_class_title_event),
					  cls_node);
	
	/* Arrow on the right of class title */
	create_canvas_arrow_item (FOO_CANVAS_GROUP (cls_node->canvas_group),
	                          CLS_ARROW_DIR_DOWN,
	                          &cls_node->plugin->style[STYLE_TITLE_FG],
	                          cls_node->width - item_height,
	                          0, cls_node->width, item_height);
	/* Class title text */
	text_item = 
		foo_canvas_item_new (FOO_CANVAS_GROUP (cls_node->canvas_group),
		                     foo_canvas_text_get_type (),
		                     "text", cls_node->sym_name,
		                     "justification", GTK_JUSTIFY_CENTER,
		                     "anchor", GTK_ANCHOR_CENTER,
		                     "x", (gdouble) 20.0,
		                     "y", (gdouble) (j + 0.5) * item_height,
		                     "fill_color_gdk",
		                     &cls_node->plugin->style[STYLE_TITLE_FG],
		                     "anchor", GTK_ANCHOR_W,
		                     NULL);
	g_object_set_data (G_OBJECT (canvas_item), "__text__", text_item);
	g_signal_connect (GTK_OBJECT (text_item), "event",
	                  G_CALLBACK (on_canvas_event_proxy),
					  canvas_item);
	
	/* Member items */
	j = 1;
	for (member = members; member; member = member->next) 
	{
		ClsNodeItem *node_item = (ClsNodeItem*) member->data;

		/* Member item background */
		node_item->canvas_node_item =
			foo_canvas_item_new (FOO_CANVAS_GROUP (cls_node->canvas_group),
			                     foo_canvas_rect_get_type (),
			                     "x1", 0.0,
			                     "y1", (gdouble) j * item_height,
			                     "x2", (gdouble) cls_node->width,
			                     "y2", (gdouble) (j + 1) * item_height,
			                     "fill_color_gdk",
			                     &cls_node->plugin->style[STYLE_ITEM_BG],
			                     NULL);
		g_signal_connect (GTK_OBJECT (node_item->canvas_node_item),
			              "event",
						  G_CALLBACK (on_expanded_class_item_event),
						  node_item);
	
		/* Member item text */
		text_item =
			foo_canvas_item_new (FOO_CANVAS_GROUP (cls_node->canvas_group),
			                     foo_canvas_text_get_type (),
			                     "text", node_item->label,
			                     "justification", GTK_JUSTIFY_CENTER,
			                     "anchor", GTK_ANCHOR_CENTER,
			                     "x", (gdouble) 20.0,
			                     "y", (gdouble) (j + 0.5) * item_height,
			                     "fill_color_gdk",
			                     &cls_node->plugin->style[STYLE_ITEM_FG],
			                     "anchor", GTK_ANCHOR_W,
			                     NULL);
		g_object_set_data (G_OBJECT (node_item->canvas_node_item),
		                   "__text__", text_item);
		g_signal_connect (GTK_OBJECT (text_item), "event",
		                  G_CALLBACK (on_canvas_event_proxy),
		                  node_item->canvas_node_item);

		/* Member item icon */
		if (node_item->icon)
			foo_canvas_item_new (FOO_CANVAS_GROUP (cls_node->canvas_group),
			                     foo_canvas_pixbuf_get_type(),
			                     "x", 2.0,
			                     "y",
			                     (gdouble) (j + 0.5) * item_height - 8,
			                     "pixbuf", node_item->icon,
			                     NULL);
		if (node_item->order == 0 || j == 1) /* Variables and methods border */
				create_canvas_line_item (FOO_CANVAS_GROUP (cls_node->canvas_group),
				                         &cls_node->plugin->style[STYLE_FG],
				                         0, j * item_height,
				                         cls_node->width, j * item_height);
		j++;
	}
	g_list_free (members);
	
	/* The last item for semi expanded item is "more" item */
	if (cls_node->expansion_status == CLS_NODE_SEMI_EXPANDED) 
	{
		/* More expand item background */
		canvas_item =
			foo_canvas_item_new (FOO_CANVAS_GROUP (cls_node->canvas_group),
			                     foo_canvas_rect_get_type (),
			                     "x1", 0.0,
			                     "y1", (gdouble) j * item_height,
			                     "x2", (gdouble) cls_node->width,
			                     "y2", (gdouble) (j + 1) * item_height,
			                     "fill_color_gdk",
			                     &cls_node->plugin->style[STYLE_TITLE_BG],
			                     NULL);
		
		g_signal_connect (GTK_OBJECT (canvas_item), "event",
			              G_CALLBACK (on_expanded_class_more_event),
						  cls_node);
	
		/* More expand item text */
		text_item = 
			foo_canvas_item_new (FOO_CANVAS_GROUP (cls_node->canvas_group),
			                     foo_canvas_text_get_type (),
			                     "text",  NODE_SHOW_ALL_MEMBERS_STR,
			                     "justification", GTK_JUSTIFY_CENTER,
			                     "anchor", GTK_ANCHOR_CENTER,
			                     "x", (gdouble) 20.0,
			                     "y", (gdouble) (j + 0.5) * item_height,
			                     "fill_color_gdk",
			                     &cls_node->plugin->style[STYLE_TITLE_FG],
			                     "anchor", GTK_ANCHOR_W,
			                     NULL);
		g_object_set_data (G_OBJECT (canvas_item), "__text__", text_item);
		g_signal_connect (GTK_OBJECT (text_item), "event",
			              G_CALLBACK (on_canvas_event_proxy),
			              canvas_item);

		create_canvas_line_item (FOO_CANVAS_GROUP (cls_node->canvas_group),
		                         &cls_node->plugin->style[STYLE_FG],
		                         0, j * item_height,
		                         cls_node->width, j * item_height);
	}
	
	/* make the outline bounds */
	foo_canvas_item_new (FOO_CANVAS_GROUP (cls_node->canvas_group),
	                     foo_canvas_rect_get_type (),
	                     "x1", (gdouble) 0.0,
	                     "y1", (gdouble) 0.0,
	                     "x2", (gdouble) cls_node->width,
	                     "y2", (gdouble) cls_node->height,
	                     "outline_color_gdk",
	                     &cls_node->plugin->style[STYLE_FG],
	                     NULL);
}
コード例 #23
0
ファイル: devselect.c プロジェクト: ksjoberg/sigrok
void dev_select_rescan(GtkAction *action, GtkWindow *parent)
{
	GtkComboBox *dev = g_object_get_data(G_OBJECT(parent), "devcombo");
	g_return_if_fail(dev != NULL);
	GtkListStore *devlist = GTK_LIST_STORE(gtk_combo_box_get_model(dev));
	GtkTreeIter iter;
	struct sr_device *device;
	struct sr_device_instance *sdi;
	gchar *sdevname = NULL;
	GSList *devices, *l;
	GtkUIManager *ui = g_object_get_data(G_OBJECT(parent), "ui_manager");
	GtkWidget *menuitem = gtk_ui_manager_get_widget(ui,
					"/menubar/DevMenu/DevSelectMenu");
	GtkMenuShell *devmenu = GTK_MENU_SHELL(gtk_menu_item_get_submenu(GTK_MENU_ITEM(menuitem)));
	GSList *radiolist = NULL;

	(void)action;

	/* Make a copy of the selected device's short name for comparison.
	 * We wish to select the same device after the refresh if possible.
	 */
	if (gtk_combo_box_get_active_iter(dev, &iter)) {
		gtk_tree_model_get(GTK_TREE_MODEL(devlist), &iter, 1, &device, -1);
		/* FIXME: Use something other than device->plugin->name */
		sdevname = g_strdup(device->plugin->name);
	}

	/* Destroy the old menu items */
	if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(devlist), &iter)) do {
		GtkMenuItem *item;
		gtk_tree_model_get(GTK_TREE_MODEL(devlist), &iter, 2, &item, -1);
		gtk_object_destroy(GTK_OBJECT(item));
	} while (gtk_tree_model_iter_next(GTK_TREE_MODEL(devlist), &iter));

	gtk_list_store_clear(devlist);

	/* Scan for new devices and update our list */
	/* TODO: Fix this in libsigrok first. */
	/*sr_device_scan();*/
	devices = sr_device_list();
	for (l = devices; l; l = l->next) {
		device = l->data;
		sdi = GET_DEVICE_INSTANCE(device);
		gchar *name = sdi->model ? sdi->model : sdi->vendor;
		if (!name)
			name = "(unknown)";

		menuitem = gtk_radio_menu_item_new_with_label(radiolist, name);
		gtk_widget_show(GTK_WIDGET(menuitem));
		if (!radiolist)
			radiolist = gtk_radio_menu_item_get_group(
					GTK_RADIO_MENU_ITEM(menuitem));
		g_signal_connect(menuitem, "toggled",
				G_CALLBACK(dev_menuitem_toggled), dev);
		gtk_menu_shell_prepend(devmenu, menuitem);

		gtk_list_store_append(devlist, &iter);
		gtk_list_store_set(devlist, &iter,
				0, name,
				1, device,
				2, menuitem,
				-1);

		if (sdevname && g_str_equal(sdevname, device->plugin->name))
			gtk_combo_box_set_active_iter(dev, &iter);
	}
	if (sdevname)
		g_free(sdevname);

	/* Select a default if nothing selected */
	if (!gtk_combo_box_get_active_iter(dev, &iter)) {
		if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(devlist), &iter))
			return;
		/* Skip demo if there's another available */
		GtkTreeIter first = iter;
		if (gtk_tree_model_iter_next(GTK_TREE_MODEL(devlist), &iter))
			gtk_combo_box_set_active_iter(dev, &iter);
		else
			gtk_combo_box_set_active_iter(dev, &first);
	}
}
コード例 #24
0
ファイル: class-inherit.c プロジェクト: rosedu/anjuta
static void
cls_node_draw_collapsed (ClsNode *cls_node) 
{
	FooCanvasItem *item, *text_item;
	gdouble text_width_value;

	g_return_if_fail (cls_node->agnode != NULL);
	g_return_if_fail (cls_node->canvas);
	g_return_if_fail (cls_node->expansion_status == CLS_NODE_COLLAPSED);

	/* Clean up members */
	g_hash_table_remove_all (cls_node->members);

	/* Switch to collapsed canvas item */
	if (cls_node->canvas_group)
		gtk_object_destroy (GTK_OBJECT (cls_node->canvas_group));
	cls_node->canvas_group =
		foo_canvas_item_new (foo_canvas_root
		                     (FOO_CANVAS (cls_node->canvas)),
		                     foo_canvas_group_get_type (),
		                     NULL);
	cls_node->drawn_expansion_status = CLS_NODE_COLLAPSED;
	
	item =
		foo_canvas_item_new (FOO_CANVAS_GROUP (cls_node->canvas_group),
		                     foo_canvas_rect_get_type (),
		                     "x1", (gdouble) 0.0,
		                     "y1", (gdouble) 0.0,
		                     "x2", (gdouble) cls_node->width,
		                     "y2", (gdouble) cls_node->height,
		                     "fill_color_gdk",
		                     &cls_node->plugin->style[STYLE_BG],
		                     "outline_color_gdk",
		                     &cls_node->plugin->style[STYLE_FG],
		                     NULL);
	g_signal_connect (GTK_OBJECT (item), "event",
					  G_CALLBACK (on_collapsed_class_event),
					  cls_node);

	/* --- text --- */
	text_item =
		foo_canvas_item_new (FOO_CANVAS_GROUP (cls_node->canvas_group),
		                     foo_canvas_text_get_type (),
		                     "text", cls_node->sym_name,
		                     "justification", GTK_JUSTIFY_CENTER,
		                     "anchor", GTK_ANCHOR_CENTER,
		                     "x", (gdouble) 0.0,
		                     "y", (gdouble) cls_node->height/2,
		                     "fill_color_gdk",
		                     &cls_node->plugin->style[STYLE_FG],
		                     "anchor", GTK_ANCHOR_W,        
		                     NULL );
	g_object_set_data (G_OBJECT (item), "__text__", text_item);
	g_signal_connect (GTK_OBJECT (text_item), "event",
	                  G_CALLBACK (on_canvas_event_proxy), item);
	
	/* center the text in the node... */
	g_object_get (text_item, "text_width", &text_width_value, NULL);
						
	foo_canvas_item_set (text_item,
	                     "x", (gdouble)((cls_node->width/2 - text_width_value/2)),
	                     NULL);
}
コード例 #25
0
ファイル: xo-selection.c プロジェクト: SteinerStefan/xournal
void finalize_selectregion(void)
{
  GList *itemlist;
  struct Item *item;
  ArtVpath *vpath;
  ArtSVP *lassosvp;
  int i, n;
  double *pt;
  
  ui.cur_item_type = ITEM_NONE;
  
  // build SVP for the lasso path
  n = ui.cur_path.num_points;
  vpath = g_malloc((n+2)*sizeof(ArtVpath));
  for (i=0; i<n; i++) { 
    vpath[i].x = ui.cur_path.coords[2*i];
    vpath[i].y = ui.cur_path.coords[2*i+1];
  }
  vpath[n].x = vpath[0].x; vpath[n].y = vpath[0].y;
  vpath[0].code = ART_MOVETO;
  for (i=1; i<=n; i++) vpath[i].code = ART_LINETO;
  vpath[n+1].code = ART_END;
  lassosvp = art_svp_from_vpath(vpath);
  g_free(vpath);

  // see which items we selected
  for (itemlist = ui.selection->layer->items; itemlist!=NULL; itemlist = itemlist->next) {
    item = (struct Item *)itemlist->data;
    if (hittest_item(lassosvp, item)) {
      // update the selection bbox
      if (ui.selection->items==NULL || ui.selection->bbox.left>item->bbox.left)
        ui.selection->bbox.left = item->bbox.left;
      if (ui.selection->items==NULL || ui.selection->bbox.right<item->bbox.right)
        ui.selection->bbox.right = item->bbox.right;
      if (ui.selection->items==NULL || ui.selection->bbox.top>item->bbox.top)
        ui.selection->bbox.top = item->bbox.top;
      if (ui.selection->items==NULL || ui.selection->bbox.bottom<item->bbox.bottom)
        ui.selection->bbox.bottom = item->bbox.bottom;
      // add the item
      ui.selection->items = g_list_append(ui.selection->items, item); 
    }
  }
  art_svp_free(lassosvp);
  
  if (ui.selection->items == NULL) {
    // if we clicked inside a text zone or image?
    pt = ui.cur_path.coords; 
    item = click_is_in_text_or_image(ui.selection->layer, pt[0], pt[1]);
    if (item!=NULL) {
      for (i=0; i<n; i++, pt+=2) {
        if (pt[0]<item->bbox.left || pt[0]>item->bbox.right || pt[1]<item->bbox.top || pt[1]>item->bbox.bottom)
          { item = NULL; break; }
      }
    }
    if (item!=NULL) {
      ui.selection->items = g_list_append(ui.selection->items, item);
      g_memmove(&(ui.selection->bbox), &(item->bbox), sizeof(struct BBox));
    }
  }

  if (ui.selection->items == NULL) reset_selection();
  else { // make a selection rectangle instead of the lasso shape
    gtk_object_destroy(GTK_OBJECT(ui.selection->canvas_item));
    ui.selection->canvas_item = gnome_canvas_item_new(ui.cur_layer->group,
      gnome_canvas_rect_get_type(), "width-pixels", 1, 
      "outline-color-rgba", 0x000000ff,
      "fill-color-rgba", 0x80808040,
      "x1", ui.selection->bbox.left, "x2", ui.selection->bbox.right, 
      "y1", ui.selection->bbox.top, "y2", ui.selection->bbox.bottom, NULL);
    make_dashed(ui.selection->canvas_item);
    ui.selection->type = ITEM_SELECTRECT;
  }

  update_cursor();
  update_copy_paste_enabled();
  update_font_button();
}
コード例 #26
0
void 
HandleSocketMessage(gpointer data, gpointer user_data)
{
    int instance, type;
    char mMsgBuf[1024];
    char *msg = (char *)data;

    int i = sscanf(msg, "%d,%d,%s", &instance, &type, mMsgBuf);

    NS_ASSERTION(i >= 2, "Wrong message format\n");

    // In case that the last message string argument contains spaces, sscanf 
    // returns before the first space. Below line returns the complete message
    // string.
    char* mMsgString = (char*)strchr(msg, ',');
    mMsgString++;
    mMsgString = (char*)strchr(mMsgString, ',');
    mMsgString++;

    GtkBrowser *pBrowser;
    switch (type) {
    case JEVENT_INIT:
        break;
    case JEVENT_CREATEWINDOW:
        {
            // only create new browser window when the instance does not exist
            if (instance < gBrowserArray.GetSize() && gBrowserArray[instance] != NULL)
                break;
            if (i != 3)
                break;
            int javaXId = atoi(mMsgString);
            NS_ASSERTION(javaXId, "Invalid X window handle\n");
            pBrowser = g_new0(GtkBrowser, 1);
            pBrowser->topLevelWindow = gtk_plug_new(javaXId);
            pBrowser->mozEmbed = gtk_moz_embed_new();
            if (pBrowser->mozEmbed) {
                gtk_container_add(GTK_CONTAINER(pBrowser->topLevelWindow), pBrowser->mozEmbed);
                install_mozembed_cb(pBrowser);
                gtk_moz_embed_set_chrome_mask(GTK_MOZ_EMBED(pBrowser->mozEmbed),
                    GTK_MOZ_EMBED_FLAG_DEFAULTCHROME);
                gtk_widget_realize(pBrowser->topLevelWindow);
                gtk_widget_show_all(pBrowser->topLevelWindow);
                pBrowser->id = instance;
                gBrowserArray.SetAtGrow(instance, pBrowser);
                SendSocketMessage(instance, CEVENT_INIT_WINDOW_SUCC);
            }

            gtk_signal_connect(GTK_OBJECT(pBrowser->topLevelWindow), 
                  "set-focus", GTK_SIGNAL_FUNC(set_focus_cb), pBrowser);

        }
        break;
    case JEVENT_DESTROYWINDOW:
        pBrowser = (GtkBrowser *)gBrowserArray[instance];
        if(pBrowser != NULL){
            gtk_widget_destroy(pBrowser->mozEmbed);
            gtk_object_destroy((GtkObject *)pBrowser->topLevelWindow);
            gBrowserArray.SetAt(instance, NULL);
        }
        SendSocketMessage(instance, CEVENT_DISTORYWINDOW_SUCC);
        break;
    case JEVENT_SHUTDOWN:
        gtk_main_quit();
        break;
    case JEVENT_SET_BOUNDS:
        {
            NS_ASSERTION(i == 3, "Wrong message format\n");
            int x, y, w, h;
            i = sscanf(mMsgString, "%d,%d,%d,%d", &x, &y, &w, &h);
            if (i == 4) {
                pBrowser = (GtkBrowser *)gBrowserArray[instance];
                NS_ASSERTION(pBrowser, "Can't get native browser instance\n");
                gtk_widget_set_usize(pBrowser->topLevelWindow, w, h);
            }
        }
        break;
    case JEVENT_NAVIGATE:
        NS_ASSERTION(i == 3, "Wrong message format\n");
        pBrowser = (GtkBrowser *)gBrowserArray[instance];
        NS_ASSERTION(pBrowser, "Can't get native browser instance\n");
        gtk_moz_embed_load_url(GTK_MOZ_EMBED(pBrowser->mozEmbed), mMsgString);
        break;
    case JEVENT_NAVIGATE_POST:
        NS_ASSERTION(i == 3, "Wrong message format\n");
        strncpy(gCachedURL, mMsgString, sizeof(gCachedURL));
        break;
    case JEVENT_NAVIGATE_POSTDATA:
        NS_ASSERTION(i == 3, "Wrong message format\n");
        pBrowser = (GtkBrowser *)gBrowserArray[instance];
        OpenURL(pBrowser, gCachedURL, mMsgString, POST_HEADER);
        break;
    case JEVENT_GOBACK:
        pBrowser = (GtkBrowser *)gBrowserArray[instance];
        NS_ASSERTION(pBrowser, "Can't get native browser instance\n");
        gtk_moz_embed_go_back(GTK_MOZ_EMBED(pBrowser->mozEmbed));
        break;
    case JEVENT_GOFORWARD:
        pBrowser = (GtkBrowser *)gBrowserArray[instance];
        NS_ASSERTION(pBrowser, "Can't get native browser instance\n");
        gtk_moz_embed_go_forward(GTK_MOZ_EMBED(pBrowser->mozEmbed));
        break;
    case JEVENT_REFRESH:
        pBrowser = (GtkBrowser *)gBrowserArray[instance];
        NS_ASSERTION(pBrowser, "Can't get native browser instance\n");
        gtk_moz_embed_reload(GTK_MOZ_EMBED(pBrowser->mozEmbed), GTK_MOZ_EMBED_FLAG_RELOADNORMAL);
        break;
    case JEVENT_STOP:
        pBrowser = (GtkBrowser *)gBrowserArray[instance];
        NS_ASSERTION(pBrowser, "Can't get native browser instance\n");
        gtk_moz_embed_stop_load(GTK_MOZ_EMBED(pBrowser->mozEmbed));
        break;
    case JEVENT_GETURL:
        {
            pBrowser = (GtkBrowser *)gBrowserArray[instance];
            NS_ASSERTION(pBrowser, "Can't get native browser instance\n");
            nsCOMPtr<nsIWebBrowser> webBrowser;
            gtk_moz_embed_get_nsIWebBrowser(GTK_MOZ_EMBED(pBrowser->mozEmbed), getter_AddRefs(webBrowser));
            nsCOMPtr<nsIWebNavigation> webNavigation(do_QueryInterface(webBrowser));
            nsCOMPtr<nsIURI> currentURI;
            webNavigation->GetCurrentURI(getter_AddRefs(currentURI));
            if (currentURI == NULL)
                SendSocketMessage(instance, CEVENT_RETURN_URL, "");
            else { 
            	nsEmbedCString uriString;
                currentURI->GetAsciiSpec(uriString);
                SendSocketMessage(instance, CEVENT_RETURN_URL, uriString.get());
            }
        }
        break;

    case JEVENT_FOCUSGAINED:
    case JEVENT_FOCUSLOST:
        {
            pBrowser = (GtkBrowser *)gBrowserArray[instance];
            NS_ASSERTION(pBrowser, "Can't get native browser instance\n");

            if (!pBrowser->topLevelWindow) {
                ReportError("Top level Window is Null!\n");
                break;
            }

            GtkWidget *widget = GTK_WIDGET (pBrowser->topLevelWindow);
            GdkEvent event;

            GtkWindowClass *parent_class = (GtkWindowClass*) gtk_type_class (GTK_TYPE_WINDOW);

            if (!widget) {
                ReportError("Failed to get browser's toplevel window !\n");
                break;
            }
            if (!parent_class) {
                ReportError("Failed to get gtk window class !\n");
                break;
            }

            event.focus_change.type = GDK_FOCUS_CHANGE;
            event.focus_change.window = widget->window;
            event.focus_change.send_event = TRUE;

            if (type == JEVENT_FOCUSGAINED) {
                event.focus_change.in = TRUE;
                GTK_WIDGET_CLASS (parent_class)->focus_in_event
                            (widget, (GdkEventFocus *)&event);
            }
            else {
                event.focus_change.in = FALSE;
                GTK_WIDGET_CLASS (parent_class)->focus_out_event
                            (widget, (GdkEventFocus *)&event);
            }
        }
        break;
    case JEVENT_GETCONTENT:
        {
            pBrowser = (GtkBrowser *)gBrowserArray[instance];
            NS_ASSERTION(pBrowser, "Can't get native browser instance\n");
            nsCOMPtr<nsIWebBrowser> webBrowser;
            gtk_moz_embed_get_nsIWebBrowser(GTK_MOZ_EMBED(pBrowser->mozEmbed), 
                    getter_AddRefs(webBrowser));
            nsCOMPtr<nsIWebNavigation> 
                webNavigation(do_QueryInterface(webBrowser));
                                                                                                            
            char *retStr = GetContent(webNavigation);
            if (retStr == NULL)
                SendSocketMessage(instance, CEVENT_GETCONTENT, "");
            else
                SendSocketMessage(instance, CEVENT_GETCONTENT, retStr);
        } 
        break;
    case JEVENT_SETCONTENT:
        {
            NS_ASSERTION(i == 3, "Wrong message format\n");
            pBrowser = (GtkBrowser *)gBrowserArray[instance];
            NS_ASSERTION(pBrowser, "Can't get native browser instance\n");
            nsCOMPtr<nsIWebBrowser> webBrowser;
            gtk_moz_embed_get_nsIWebBrowser(GTK_MOZ_EMBED(pBrowser->mozEmbed), 
                    getter_AddRefs(webBrowser));
            nsCOMPtr<nsIWebNavigation> 
                webNavigation(do_QueryInterface(webBrowser));
            
            SetContent(webNavigation, mMsgString);
        }
        break;
    case JEVENT_EXECUTESCRIPT:
        {
            NS_ASSERTION(i == 3, "Wrong message format\n");
            pBrowser = (GtkBrowser *)gBrowserArray[instance];
            NS_ASSERTION(pBrowser, "Can't get native browser instance\n");
            nsCOMPtr<nsIWebBrowser> webBrowser;
            gtk_moz_embed_get_nsIWebBrowser(GTK_MOZ_EMBED(pBrowser->mozEmbed), 
                    getter_AddRefs(webBrowser));
            nsCOMPtr<nsIWebNavigation> 
                webNavigation(do_QueryInterface(webBrowser));
                                                                                                            
            char *retStr = ExecuteScript(webNavigation, mMsgString);
            if (retStr == NULL)
                SendSocketMessage(instance, CEVENT_EXECUTESCRIPT, "");
            else
                SendSocketMessage(instance, CEVENT_EXECUTESCRIPT, retStr);
        } 
        break;
    }
}
コード例 #27
0
static void
control_destroy_cb (BonoboControl *control,
		    EYank *yank)
{
	gtk_object_destroy (GTK_OBJECT (yank));
}
コード例 #28
0
ファイル: e-minicard.c プロジェクト: ebbywiselyn/evolution
static void
e_minicard_field_destroy(EMinicardField *field)
{
	gtk_object_destroy(GTK_OBJECT(field->label));
	g_free(field);
}
コード例 #29
0
ファイル: gtkam-close.c プロジェクト: gphoto/gtkam
static void
on_close_close_clicked (GtkButton *button, GtkamClose *close)
{
	gtk_object_destroy (GTK_OBJECT (close));
}
コード例 #30
0
ファイル: maemo.c プロジェクト: CSRedRat/vlc
/*****************************************************************************
* Initialize and launch the interface
*****************************************************************************/
static void *Thread( void *obj )
{
    intf_thread_t *p_intf = (intf_thread_t *)obj;
    const char *p_args[] = { "vlc" };
    int i_args = sizeof(p_args)/sizeof(char *);
    char **pp_args  = (char **)p_args;

    HildonProgram *program;
    HildonWindow *window;
    GtkWidget *main_vbox, *bottom_hbox;
    GtkWidget *video, *seekbar;
    GtkWidget *play_button, *prev_button, *next_button;
    GtkWidget *stop_button, *playlist_button;

    gtk_init( &i_args, &pp_args );

    program = HILDON_PROGRAM( hildon_program_get_instance() );
    g_set_application_name( "VLC Media Player" );

    window = HILDON_WINDOW( hildon_window_new() );
    hildon_program_add_window( program, window );
    gtk_object_set_data( GTK_OBJECT( window ), "p_intf", p_intf );
    p_intf->p_sys->p_main_window = window;

    g_signal_connect( GTK_WIDGET(window), "key-press-event",
                      G_CALLBACK( key_cb ), p_intf );
    g_signal_connect (GTK_WIDGET(window), "delete_event",
                      GTK_SIGNAL_FUNC( quit_event), p_intf );

    // A little theming
    char *psz_rc_file = NULL;
    char *psz_data = config_GetDataDir( p_intf );
    if( asprintf( &psz_rc_file, "%s/maemo/vlc_intf.rc", psz_data ) != -1 )
    {
        gtk_rc_parse( psz_rc_file );
        free( psz_rc_file );
    }
    free( psz_data );

    // We create the main vertical box
    main_vbox = gtk_vbox_new( FALSE, 0 );
    gtk_container_add( GTK_CONTAINER( window ), main_vbox );

    // Menubar
    GtkWidget *main_menu = create_menu( p_intf );
#ifdef HAVE_MAEMO
    hildon_window_set_menu( HILDON_WINDOW( p_intf->p_sys->p_main_window ),
                            GTK_MENU( main_menu ) );
#else
    GtkWidget *menu_bar = gtk_menu_bar_new ();
    GtkWidget *item = gtk_menu_item_new_with_label ("Menu");
    gtk_menu_bar_append(menu_bar, item);
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), main_menu);
    gtk_widget_show_all (menu_bar);
    gtk_box_pack_start(GTK_BOX(main_vbox), menu_bar, FALSE, FALSE, 0);
#endif

    // We put first the embedded video
    video = gtk_event_box_new();
    GdkColor black = {0,0,0,0};
    gtk_widget_modify_bg(video, GTK_STATE_NORMAL, &black);
    p_intf->p_sys->p_video_window = video;
    gtk_box_pack_start( GTK_BOX( main_vbox ), video, TRUE, TRUE, 0 );

    create_playlist( p_intf );
    gtk_box_pack_start( GTK_BOX( main_vbox ), p_intf->p_sys->p_playlist_window, TRUE, TRUE, 0 );

    // We put the horizontal box which contains all the buttons
    p_intf->p_sys->p_control_window = bottom_hbox = gtk_hbox_new( FALSE, 0 );

    // We create the buttons
    play_button = gtk_button_new();
    gtk_button_set_image( GTK_BUTTON( play_button ),
                   gtk_image_new_from_stock( "vlc-play", GTK_ICON_SIZE_BUTTON ) );
    p_intf->p_sys->p_play_button = play_button;
    stop_button = gtk_button_new();
    gtk_button_set_image( GTK_BUTTON( stop_button ),
                          gtk_image_new_from_stock( "vlc-stop", GTK_ICON_SIZE_BUTTON ) );
    prev_button = gtk_button_new();
    gtk_button_set_image( GTK_BUTTON( prev_button ),
                      gtk_image_new_from_stock( "vlc-previous", GTK_ICON_SIZE_BUTTON ) );
    next_button = gtk_button_new();
    gtk_button_set_image( GTK_BUTTON( next_button ),
                      gtk_image_new_from_stock( "vlc-next", GTK_ICON_SIZE_BUTTON ) );
    playlist_button = gtk_button_new();
    gtk_button_set_image( GTK_BUTTON( playlist_button ),
                          gtk_image_new_from_stock( "vlc-playlist", GTK_ICON_SIZE_BUTTON ) );
    seekbar = hildon_seekbar_new();
    p_intf->p_sys->p_seekbar = HILDON_SEEKBAR( seekbar );

    // We add them to the hbox
    gtk_box_pack_start( GTK_BOX( bottom_hbox ), play_button, FALSE, FALSE, 0 );
    gtk_box_pack_start( GTK_BOX( bottom_hbox ), stop_button, FALSE, FALSE, 0 );
    gtk_box_pack_start( GTK_BOX( bottom_hbox ), prev_button, FALSE, FALSE, 0 );
    gtk_box_pack_start( GTK_BOX( bottom_hbox ), next_button, FALSE, FALSE, 0 );
    gtk_box_pack_start( GTK_BOX( bottom_hbox ), playlist_button, FALSE, FALSE, 0 );
    gtk_box_pack_start( GTK_BOX( bottom_hbox ), seekbar    , TRUE , TRUE , 5 );
    // We add the hbox to the main vbox
    gtk_box_pack_start( GTK_BOX( main_vbox ), bottom_hbox, FALSE, FALSE, 0 );

    g_signal_connect( play_button, "clicked", G_CALLBACK( play_cb ), NULL );
    g_signal_connect( stop_button, "clicked", G_CALLBACK( stop_cb ), NULL );
    g_signal_connect( prev_button, "clicked", G_CALLBACK( prev_cb ), NULL );
    g_signal_connect( next_button, "clicked", G_CALLBACK( next_cb ), NULL );
    g_signal_connect( playlist_button, "clicked", G_CALLBACK( playlist_cb ), NULL );
    g_signal_connect( seekbar, "change-value",
                      G_CALLBACK( seekbar_changed_cb ), NULL );

    gtk_widget_show_all( GTK_WIDGET( window ) );
    gtk_widget_hide_all( p_intf->p_sys->p_playlist_window );

#if 1
    /* HACK: Only one X11 client can subscribe to mouse button press events.
     * VLC currently handles those in the video display.
     * Force GTK to unsubscribe from mouse press and release events. */
    Display *dpy = GDK_WINDOW_XDISPLAY( gtk_widget_get_window(p_intf->p_sys->p_video_window) );
    Window w = GDK_WINDOW_XID( gtk_widget_get_window(p_intf->p_sys->p_video_window) );
    XWindowAttributes attr;

    XGetWindowAttributes( dpy, w, &attr );
    attr.your_event_mask &= ~(ButtonPressMask|ButtonReleaseMask);
    XSelectInput( dpy, w, attr.your_event_mask );
#endif

    // The embedded video is only ready after gtk_main and windows are shown
    g_idle_add( interface_ready, p_intf );

    gtk_main();

    delete_input( p_intf );
    delete_playlist( p_intf );

    gtk_object_destroy( GTK_OBJECT( main_menu ) );
    gtk_object_destroy( GTK_OBJECT( window ) );

    return NULL;
}