Exemple #1
0
JNIEXPORT void JNICALL
Java_org_gnome_gtk_GtkWindow_gtk_1window_1set_1gravity
(
	JNIEnv* env,
	jclass cls,
	jlong _self,
	jint _gravity
)
{
	GtkWindow* self;
	GdkGravity gravity;

	// convert parameter self
	self = (GtkWindow*) _self;

	// convert parameter gravity
	gravity = (GdkGravity) _gravity;

	// call function
	gtk_window_set_gravity(self, gravity);

	// cleanup parameter self

	// cleanup parameter gravity
}
static void
set_resize_gravity(HippoWindowGtk *window_gtk,
                   HippoGravity    resize_gravity)
{
    window_gtk->resize_gravity = resize_gravity;

#if 0
    /* We don't set the GdkGravity because we don't need it (our window
     * isn't decorated) and if GTK+ is made to automatically do the
     * sort of thing we do in hippo_window_gtk_check-resize(), the window
     * would get moved twice.
     */
    GdkGravity gdk_gravity = GDK_GRAVITY_NORTH_WEST;

    switch (resize_gravity) {
    case HIPPO_GRAVITY_NORTH_WEST:
        gdk_gravity = GDK_GRAVITY_NORTH_WEST;
        break;
    case HIPPO_GRAVITY_NORTH_EAST:
        gdk_gravity = GDK_GRAVITY_NORTH_EAST;
        break;
    case HIPPO_GRAVITY_SOUTH_EAST:
        gdk_gravity = GDK_GRAVITY_SOUTH_EAST;
        break;
    case HIPPO_GRAVITY_SOUTH_WEST:
        gdk_gravity = GDK_GRAVITY_SOUTH_WEST;
        break;
    }

    gtk_window_set_gravity(GTK_WINDOW(window_gtk), gdk_gravity);
#endif
}
void movetoright(struttura *str)
{
 if(str->position==2)
 {
	gtk_window_set_gravity(GTK_WINDOW(str->window),GDK_GRAVITY_SOUTH_EAST);
 	gtk_window_move(GTK_WINDOW(str->window),str->s_width-185,str->s_height-WINDOW_HEIGHT);
	str->position=3;
	gdk_window_process_all_updates ();
 }
 if(str->position==1)
 {
 	gtk_window_set_gravity(GTK_WINDOW(str->window),GDK_GRAVITY_SOUTH);
 	gtk_window_move(GTK_WINDOW(str->window),(str->s_width/2)-WINDOW_WIDTH,str->s_height-WINDOW_HEIGHT);
	str->position=2;
	gdk_window_process_all_updates ();
 }
}
void FullscreenVideoControllerGtk::createHud()
{
    m_hudWindow = gtk_window_new(GTK_WINDOW_POPUP);
    gtk_window_set_gravity(GTK_WINDOW(m_hudWindow), GDK_GRAVITY_SOUTH_WEST);
    gtk_window_set_type_hint(GTK_WINDOW(m_hudWindow), GDK_WINDOW_TYPE_HINT_NORMAL);

    m_hudMotionNotifySignalId = g_signal_connect(m_hudWindow, "motion-notify-event", G_CALLBACK(onFullscreenGtkMotionNotifyEvent), this);

#ifdef GTK_API_VERSION_2
    GtkWidget* hbox = gtk_hbox_new(FALSE, 4);
#else
    GtkWidget* hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
#endif
    gtk_container_add(GTK_CONTAINER(m_hudWindow), hbox);

    m_playPauseAction = gtk_action_new("play", _("Play / Pause"), _("Play or pause the media"), PAUSE_ICON_NAME);
    m_playActionActivateSignalId = g_signal_connect(m_playPauseAction, "activate", G_CALLBACK(togglePlayPauseActivated), this);

    GtkWidget* item = gtk_action_create_tool_item(m_playPauseAction);
    gtk_box_pack_start(GTK_BOX(hbox), item, FALSE, TRUE, 0);

    GtkWidget* label = gtk_label_new(_("Time:"));
    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 0);

    GtkAdjustment* adjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 100.0, 0.1, 1.0, 1.0));
#ifdef GTK_API_VERSION_2
    m_timeHScale = gtk_hscale_new(adjustment);
#else
    m_timeHScale = gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, adjustment);
#endif
    gtk_scale_set_draw_value(GTK_SCALE(m_timeHScale), FALSE);
    gtk_range_set_show_fill_level(GTK_RANGE(m_timeHScale), TRUE);
    m_timeScaleButtonPressedSignalId = g_signal_connect(m_timeHScale, "button-press-event", G_CALLBACK(timeScaleButtonPressed), this);
    m_timeScaleButtonReleasedSignalId = g_signal_connect(m_timeHScale, "button-release-event", G_CALLBACK(timeScaleButtonReleased), this);
    m_hscaleUpdateId = g_signal_connect(m_timeHScale, "value-changed", G_CALLBACK(timeScaleValueChanged), this);

    gtk_box_pack_start(GTK_BOX(hbox), m_timeHScale, TRUE, TRUE, 0);

    m_timeLabel = gtk_label_new("");
    gtk_box_pack_start(GTK_BOX(hbox), m_timeLabel, FALSE, TRUE, 0);

    // Volume button.
    m_volumeButton = gtk_volume_button_new();
    gtk_box_pack_start(GTK_BOX(hbox), m_volumeButton, FALSE, TRUE, 0);
    gtk_scale_button_set_value(GTK_SCALE_BUTTON(m_volumeButton), m_player->volume());
    m_volumeUpdateId = g_signal_connect(m_volumeButton, "value-changed", G_CALLBACK(volumeValueChanged), this);

    m_exitFullscreenAction = gtk_action_new("exit", _("Exit Fullscreen"), _("Exit from fullscreen mode"), EXIT_FULLSCREEN_ICON_NAME);
    m_exitFullcreenActionActivateSignalId = g_signal_connect(m_exitFullscreenAction, "activate", G_CALLBACK(exitFullscreenActivated), this);
    g_object_set(m_exitFullscreenAction, "icon-name", EXIT_FULLSCREEN_ICON_NAME, NULL);
    item = gtk_action_create_tool_item(m_exitFullscreenAction);
    gtk_box_pack_start(GTK_BOX(hbox), item, FALSE, TRUE, 0);

    m_progressBarUpdateId = g_timeout_add(PROGRESS_BAR_UPDATE_INTERVAL, reinterpret_cast<GSourceFunc>(progressBarUpdateCallback), this);

    playStateChanged();
}
Exemple #5
0
void Installer::ResizeWindow(int width, int height)
{
    // Try very hard to center the window
    gtk_window_set_default_size(GTK_WINDOW(this->window), width, height);
    gtk_window_resize(GTK_WINDOW(this->window), width, height);
    gtk_window_set_gravity(GTK_WINDOW(this->window), GDK_GRAVITY_CENTER);
    gtk_window_move(
        GTK_WINDOW(this->window),
        gdk_screen_width()/2 - width/2,
        gdk_screen_height()/2 - height/2);
}
Exemple #6
0
int
main(int argc, char **argv)
{
  GError *error = NULL;
  GdkMonitor *monitor;
  GdkRectangle monitor_bounds;

  GOptionContext *context = g_option_context_new (NULL);
  g_option_context_add_main_entries (context, options, NULL);
  frame_stats_add_options (g_option_context_get_main_group (context));
  g_option_context_add_group (context,
                              gtk_get_option_group (TRUE));

  if (!g_option_context_parse (context, &argc, &argv, &error))
    {
      g_printerr ("Option parsing failed: %s\n", error->message);
      return 1;
    }

  g_print ("# Load factor: %g\n",
           load_factor);
  g_print ("# Resizing?: %s\n",
           cb_no_resize ? "no" : "yes");

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  frame_stats_ensure (GTK_WINDOW (window));

  gtk_window_set_keep_above (GTK_WINDOW (window), TRUE);
  gtk_window_set_gravity (GTK_WINDOW (window), GDK_GRAVITY_CENTER);
  gtk_widget_set_app_paintable (window, TRUE);

  g_signal_connect (window, "draw",
                    G_CALLBACK (on_window_draw), NULL);
  g_signal_connect (window, "destroy",
                    G_CALLBACK (gtk_main_quit), NULL);

  g_signal_connect (window, "map-event",
                    G_CALLBACK (on_map_event), NULL);
  on_frame (0.);

  monitor = gdk_display_get_primary_monitor (gtk_widget_get_display (window));
  gdk_monitor_get_geometry (monitor, &monitor_bounds);

  gtk_window_move (GTK_WINDOW (window),
                   monitor_bounds.x + (monitor_bounds.width - window_width) / 2,
                   monitor_bounds.y + (monitor_bounds.height - window_height) / 2);

  gtk_widget_show (window);

  gtk_main ();

  return 0;
}
int
main(int argc, char **argv)
{
  GError *error = NULL;
  GdkScreen *screen;
  GdkRectangle monitor_bounds;

  if (!gtk_init_with_args (&argc, &argv, "",
                           options, NULL, &error))
    {
      g_printerr ("Option parsing failed: %s\n", error->message);
      return 1;
    }

  g_print ("%sLoad factor: %g\n",
           machine_readable ? "# " : "",
           load_factor);
  g_print ("%sResizing?: %s\n",
           machine_readable ? "# " : "",
           cb_no_resize ? "no" : "yes");

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_keep_above (GTK_WINDOW (window), TRUE);
  gtk_window_set_gravity (GTK_WINDOW (window), GDK_GRAVITY_CENTER);
  gtk_widget_set_app_paintable (window, TRUE);

  g_signal_connect (window, "draw",
                    G_CALLBACK (on_window_draw), NULL);
  g_signal_connect (window, "destroy",
                    G_CALLBACK (gtk_main_quit), NULL);

  g_signal_connect (window, "map-event",
                    G_CALLBACK (on_map_event), NULL);
  on_frame (0.);

  screen = gtk_widget_get_screen (window);
  gdk_screen_get_monitor_geometry (screen,
                                   gdk_screen_get_primary_monitor (screen),
                                   &monitor_bounds);

  gtk_window_move (GTK_WINDOW (window),
                   monitor_bounds.x + (monitor_bounds.width - window_width) / 2,
                   monitor_bounds.y + (monitor_bounds.height - window_height) / 2);

  gtk_widget_show (window);

  gtk_main ();

  return 0;
}
static void create_library_editor(Editor *e)
{
    GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
    GtkWidget *library_editor = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_gravity(GTK_WINDOW(library_editor), GDK_GRAVITY_CENTER);

    gtk_container_add(GTK_CONTAINER(library_editor), vbox);
    
    gtk_box_pack_start(GTK_BOX(vbox), create_sample_view(e),  TRUE,  TRUE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), create_text_input(e),   FALSE, TRUE, 5);
    gtk_box_pack_start(GTK_BOX(vbox), create_radius_input(e), FALSE, TRUE, 5);
    gtk_box_pack_start(GTK_BOX(vbox), create_buttons(e),      FALSE, TRUE, 5);    

    e->window = library_editor;
}
Exemple #9
0
int lassi_osd_init(LassiOsdInfo *osd) {
    GtkWidget *hbox;

    g_assert(osd);

    memset(osd, 0, sizeof(*osd));

    osd->window = gtk_window_new(GTK_WINDOW_POPUP);
    gtk_window_set_title(GTK_WINDOW(osd->window), "Mango Lassi OSD");
    gtk_window_stick(GTK_WINDOW(osd->window));
    gtk_window_set_keep_above(GTK_WINDOW(osd->window), TRUE);
    gtk_window_set_decorated(GTK_WINDOW(osd->window), FALSE);
    gtk_window_set_deletable(GTK_WINDOW(osd->window), FALSE);
    gtk_window_set_type_hint(GTK_WINDOW(osd->window), GDK_WINDOW_TYPE_HINT_NOTIFICATION);
    gtk_window_set_skip_taskbar_hint(GTK_WINDOW(osd->window), TRUE);
    gtk_window_set_skip_pager_hint(GTK_WINDOW(osd->window), TRUE);
    gtk_window_set_accept_focus(GTK_WINDOW(osd->window), FALSE);
    gtk_window_set_focus_on_map(GTK_WINDOW(osd->window), FALSE);
    gtk_window_set_gravity(GTK_WINDOW(osd->window), GDK_GRAVITY_SOUTH_WEST);
    gtk_widget_set_app_paintable(GTK_WIDGET(osd->window), TRUE);
    g_signal_connect(osd->window, "draw", G_CALLBACK(draw_cb), NULL);

    osd->label = gtk_label_new("Test");
    gtk_misc_set_padding(GTK_MISC(osd->label), 16, 0);
/*     gtk_label_set_line_wrap(GTK_LABEL(osd->label), TRUE);  */
    osd->left_icon = gtk_image_new();
    osd->right_icon = gtk_image_new();

    hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_container_set_border_width(GTK_CONTAINER(hbox), 8);

    gtk_box_pack_start(GTK_BOX(hbox), osd->left_icon, FALSE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(hbox), osd->label, TRUE, TRUE, 0);
    gtk_box_pack_end(GTK_BOX(hbox), osd->right_icon, FALSE, TRUE, 0);

    gtk_container_add(GTK_CONTAINER(osd->window), hbox);

    gtk_widget_show(hbox);
    gtk_widget_show(osd->label);

    gtk_widget_realize(GTK_WIDGET(osd->window));

    /*g_debug("WINDOW=%p", osd->window);*/

    return 0;
}
Exemple #10
0
void window_set_position(ui::Window window, const WindowPosition &position)
{
	gtk_window_set_gravity( window, GDK_GRAVITY_STATIC );

	GdkScreen* screen = gdk_screen_get_default();
	if ( position.x < 0
		 || position.y < 0
		 || position.x > gdk_screen_get_width( screen )
		 || position.y > gdk_screen_get_height( screen ) ) {
		gtk_window_set_position( window, GTK_WIN_POS_CENTER_ON_PARENT );
	}
	else
	{
		gtk_window_move( window, position.x, position.y );
	}

	gtk_window_set_default_size( window, position.w, position.h );
}
Exemple #11
0
void build_interface(void)
{
	GtkWindow *w = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
	gtk_window_set_title(w, title);
	gtk_window_set_gravity(w, GDK_GRAVITY_CENTER);
	gtk_window_set_position(w, GTK_WIN_POS_CENTER_ALWAYS);
	gtk_window_set_type_hint(w, GDK_WINDOW_TYPE_HINT_DIALOG);
	gtk_window_set_icon_name(w, "dialog-question");

	GtkBox *b = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));

	entry = GTK_ENTRY(gtk_entry_new());
	gtk_widget_grab_focus(GTK_WIDGET(entry));

	list_store = gtk_list_store_new(1, G_TYPE_STRING);

	GtkTreeView *t = GTK_TREE_VIEW(gtk_tree_view_new_with_model(
				GTK_TREE_MODEL(list_store)));
	gtk_tree_view_set_headers_visible(t, FALSE);
	gtk_tree_view_append_column(t, gtk_tree_view_column_new_with_attributes("",
				gtk_cell_renderer_text_new(), "text", 0, NULL));

	tree_selection = gtk_tree_view_get_selection(t);

#define NO_FOCUS(W) gtk_widget_set_can_focus(GTK_WIDGET(W), FALSE) 

	NO_FOCUS(w);
	NO_FOCUS(b);
	NO_FOCUS(t);

#define BOX_APPEND(B, W, E, F) gtk_box_pack_start(b, GTK_WIDGET(W), E, F, 0)
	
	BOX_APPEND(b, entry, FALSE, TRUE);
	BOX_APPEND(b, t, TRUE, TRUE);
	gtk_container_add(GTK_CONTAINER(w), GTK_WIDGET(b));

#define CONNECT(O, S, C) g_signal_connect(G_OBJECT(O), S, G_CALLBACK(C), NULL)

	CONNECT(w, "destroy", gtk_main_quit);
	CONNECT(entry, "changed", on_entry_changed);
	CONNECT(entry, "key-press-event", on_entry_key_press_event);

	gtk_widget_show_all(GTK_WIDGET(w));
}
static void
gth_media_viewer_page_real_fullscreen (GthViewerPage *base,
				       gboolean       active)
{
	GthMediaViewerPage *self = (GthMediaViewerPage*) base;
	GdkScreen          *screen;

	if (! active) {
		g_object_ref (self->priv->mediabar);
		gtk_container_remove (GTK_CONTAINER (self->priv->fullscreen_toolbar), self->priv->mediabar);
		gtk_box_pack_start (GTK_BOX (self->priv->area_box), self->priv->mediabar, FALSE, FALSE, 0);
		g_object_unref (self->priv->mediabar);

		gtk_widget_destroy (self->priv->fullscreen_toolbar);
		self->priv->fullscreen_toolbar = NULL;

		return;
	}

	/* active == TRUE */

	screen = gtk_widget_get_screen (GTK_WIDGET (self->priv->browser));

	if (self->priv->fullscreen_toolbar == NULL) {
		self->priv->fullscreen_toolbar = gtk_window_new (GTK_WINDOW_POPUP);
		gtk_window_set_screen (GTK_WINDOW (self->priv->fullscreen_toolbar), screen);
		gtk_window_set_default_size (GTK_WINDOW (self->priv->fullscreen_toolbar), gdk_screen_get_width (screen), -1);
		gtk_container_set_border_width (GTK_CONTAINER (self->priv->fullscreen_toolbar), 0);
	}

	g_object_ref (self->priv->mediabar);
	gtk_container_remove (GTK_CONTAINER (self->priv->area_box), self->priv->mediabar);
	gtk_container_add (GTK_CONTAINER (self->priv->fullscreen_toolbar), self->priv->mediabar);
	g_object_unref (self->priv->mediabar);

	gtk_widget_realize (self->priv->mediabar);
	gtk_window_set_gravity (GTK_WINDOW (self->priv->fullscreen_toolbar), GDK_GRAVITY_SOUTH_EAST);
	gtk_window_move (GTK_WINDOW (self->priv->fullscreen_toolbar), 0, gdk_screen_get_height (screen) - self->priv->mediabar->allocation.height);

	gth_browser_register_fullscreen_control (self->priv->browser, self->priv->fullscreen_toolbar);
}
Exemple #13
0
Installer::Installer(
	std::string app_name,
	std::string confirm_title,
	std::string message) :
		app_name(app_name),
		confirm_title(confirm_title),
		message(message),
		current_job(NULL),
		cancel(false),
		error("")
{

	this->download_finished = false;
	this->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_container_set_border_width(GTK_CONTAINER(this->window), 10);
	gtk_window_set_default_size(GTK_WINDOW(this->window), WINDOW_WIDTH, WINDOW_HEIGHT);
	gtk_window_resize(GTK_WINDOW(this->window), WINDOW_WIDTH, WINDOW_HEIGHT);
	gtk_window_set_gravity(GTK_WINDOW(this->window), GDK_GRAVITY_CENTER);

	std::string title = this->app_name + " - Installer";
	gtk_window_set_title(GTK_WINDOW(this->window), title.c_str());

	g_signal_connect (
		G_OBJECT(this->window),
		"destroy",
		G_CALLBACK(destroy_cb),
		(gpointer) this);

	gtk_window_move(
		GTK_WINDOW(this->window),
		gdk_screen_width()/2 - WINDOW_WIDTH/2,
		gdk_screen_height()/2 - WINDOW_HEIGHT/2);

	GdkColormap* colormap = gtk_widget_get_colormap(this->window);
	GdkBitmap *mask = NULL;
	GdkPixmap* icon = gdk_pixmap_colormap_create_from_xpm_d(
		NULL,
		colormap,
		&mask,
		NULL,
		(gchar**) titanium_xpm);
	GtkWidget* image = gtk_image_new_from_pixmap(icon, mask);
	this->label = gtk_label_new("Downloading packages..");

	GtkWidget* hbox = gtk_hbox_new(FALSE, 0);
	gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 5);
	gtk_box_pack_start(GTK_BOX(hbox), this->label, FALSE, FALSE, 0);

	this->bar = gtk_progress_bar_new();

	GtkWidget* hbox2 = gtk_hbox_new(FALSE, 0);
	GtkWidget* cancel_but = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
	gtk_box_pack_start(GTK_BOX(hbox2), cancel_but, TRUE, FALSE, 0);

	g_signal_connect (
		G_OBJECT(cancel_but),
		"clicked",
		G_CALLBACK(cancel_cb),
		(gpointer) this);

	GtkWidget* vbox = gtk_vbox_new(FALSE, 5);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), this->bar, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), hbox2, FALSE, FALSE, 10);

	gtk_container_add(GTK_CONTAINER(this->window), vbox);

}
/* Method that create the "save dialog" */
void create_save_document(GtkMenuItem *button, MinimoBrowser *browser, gchar *location) 
{
  GtkWidget *fs, *ok_button, *cancel_button, *hbox;
  GtkWidget *SaveDialog, *scrolled_window;
  OpenDialogParams *dialogParams;
  
  G_CONST_RETURN gchar *file_name = NULL;
  
  g_return_if_fail(browser->mozEmbed != NULL);
  
  if (location)
    location = gtk_moz_embed_get_location(GTK_MOZ_EMBED (browser->mozEmbed));
  
  if (location) file_name = g_basename(location);
  
  dialogParams = (OpenDialogParams*) malloc(sizeof(OpenDialogParams));
  
  fs = gtk_file_chooser_widget_new (GTK_FILE_CHOOSER_ACTION_SAVE);
  SaveDialog = gtk_dialog_new ();
  gtk_widget_set_size_request (SaveDialog, 240, 320);
  gtk_window_set_title (GTK_WINDOW (SaveDialog), ("Save as"));
  gtk_window_set_position (GTK_WINDOW (SaveDialog), GTK_WIN_POS_CENTER_ON_PARENT);
  gtk_window_set_modal (GTK_WINDOW (SaveDialog), TRUE);
  gtk_window_set_default_size (GTK_WINDOW (SaveDialog), 240, 320);
  gtk_window_set_resizable (GTK_WINDOW (SaveDialog), FALSE);
  gtk_window_set_decorated (GTK_WINDOW (SaveDialog), TRUE);
  gtk_window_set_skip_taskbar_hint (GTK_WINDOW (SaveDialog), TRUE);
  gtk_window_set_skip_pager_hint (GTK_WINDOW (SaveDialog), TRUE);
  gtk_window_set_type_hint (GTK_WINDOW (SaveDialog), GDK_WINDOW_TYPE_HINT_DIALOG);
  gtk_window_set_gravity (GTK_WINDOW (SaveDialog), GDK_GRAVITY_NORTH_EAST);
  gtk_window_set_transient_for(GTK_WINDOW(SaveDialog), GTK_WINDOW(browser->topLevelWindow));
  
  scrolled_window = gtk_scrolled_window_new(NULL,NULL);
  gtk_widget_show(scrolled_window);
  gtk_box_pack_start(GTK_BOX(GTK_DIALOG (SaveDialog)->vbox),scrolled_window,TRUE,TRUE,0);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
  
  gtk_scrolled_window_add_with_viewport ( GTK_SCROLLED_WINDOW (scrolled_window) ,fs);
  
  g_object_set_data(G_OBJECT(fs), "minimo", browser);
  
  /* adding extra button into the widget -> 'Ok and Cancel' Button */
  ok_button = gtk_button_new_with_label ("Ok");
  gtk_widget_modify_font(GTK_BIN(ok_button)->child, getOrCreateDefaultMinimoFont());
  
  cancel_button = gtk_button_new_with_label ("Cancel");
  gtk_widget_modify_font(GTK_BIN(cancel_button)->child, getOrCreateDefaultMinimoFont());
  
  hbox = gtk_hbox_new(FALSE, 10);
  gtk_box_pack_start(GTK_BOX (hbox), ok_button, FALSE, TRUE, 10);
  gtk_box_pack_start(GTK_BOX (hbox), cancel_button, FALSE, TRUE, 10);
  gtk_widget_show_all (hbox);
  
  gtk_file_chooser_set_extra_widget ( GTK_FILE_CHOOSER (fs), GTK_WIDGET (hbox));
  
  dialogParams->main_combo= fs;	
  dialogParams->dialog_combo= SaveDialog;
  
  /* connecting callbacks into the extra buttons */
  g_signal_connect(G_OBJECT(ok_button), "clicked", G_CALLBACK(on_save_ok_cb), dialogParams);
  
  gtk_widget_show(fs);
  gtk_widget_show_all(SaveDialog);
  
  return;
}
Exemple #15
0
/*------------------------------main-----------------------------------*/
int main(int argc, char const *argv[])
{
    debug("main");
    /*command line args*/
    if(argc > 1) {
        if(!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {
            printf("%s\n", HELPMSG);
            return 0;
        }
        if(!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version")) {
            printf("%s\n", VERSION);
            return 0;
        }
        printf("Unknown args [%s], continue to GUI...\n", argv[1]);
    }

    /*gtk start*/
    gtk_init(NULL, NULL);
    debug("gtk init");

    /*init char*/
    mark = malloc(2);
    word = malloc(MAX_LENGTH);

    /* init curl */
    curl_global_init(CURL_GLOBAL_ALL);
    debug("curl init");

    /*window*/
    window = (GtkWidget *)gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_decorated(GTK_WINDOW(window), FALSE);
    gtk_window_set_icon_name(GTK_WINDOW(window),"accessories-dictionary");
    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER_ALWAYS);
    gtk_window_set_gravity(GTK_WINDOW(window), GDK_GRAVITY_CENTER);
    g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
    g_signal_connect(window, "key_press_event", G_CALLBACK(checkEsc), NULL);
    debug("window");

    /* entry */
    make_entry();

    /*button*/
    make_button1();

    /*assemble*/
    vbox1 = gtk_vbox_new(FALSE, 2); /*h**o, pad*/
    hbox1 = gtk_hbox_new(FALSE, 2);
    hboxmain = gtk_hbox_new(FALSE, 5);
    gtk_widget_set_no_show_all(hboxmain, TRUE);

    gtk_container_add((GtkContainer *)window, vbox1);
    gtk_container_add((GtkContainer *)vbox1, hbox1);
    gtk_container_add((GtkContainer *)vbox1, hboxmain);
    gtk_container_add((GtkContainer *)hbox1, entry);
    gtk_container_add((GtkContainer *)hbox1, button1);

    gtk_box_set_child_packing(GTK_BOX(hbox1), GTK_WIDGET(entry),
                              1,/*expand*/
                              1,/*fill*/
                              2,/*pad*/
                              GTK_PACK_START/*pack type*/
                             );

    gtk_box_set_child_packing(GTK_BOX(vbox1), hbox1,
                              0, 0, 1, GTK_PACK_START);

    gtk_box_set_child_packing(GTK_BOX(hbox1), button1,
                              0, 0, 1, GTK_PACK_START);
    debug("assemble initial view");


    gtk_widget_show_all(window);
    debug("start the show");

#ifdef MinGW
    /*volatino*/
    volatino = (GtkWidget *) gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_decorated(GTK_WINDOW(volatino), FALSE);
    gtk_widget_set_size_request(volatino, 450, 24);
    gtk_window_set_icon_name(GTK_WINDOW(volatino),"accessories-dictionary");
    gtk_window_set_position(GTK_WINDOW(volatino), GTK_WIN_POS_CENTER_ALWAYS);
    gtk_window_set_gravity(GTK_WINDOW(volatino), GDK_GRAVITY_CENTER);
    gtk_widget_show(volatino);
    gtk_widget_destroy(volatino);

#endif

    /*auto-completion*/
    store = gtk_list_store_new(1, G_TYPE_STRING);
    model = GTK_TREE_MODEL(store);

    /*completion model*/
    completion = gtk_entry_completion_new();
    gtk_entry_completion_set_model(completion, model);
    gtk_entry_completion_set_text_column(completion, 0);
    /*completion style*/
    gtk_entry_completion_set_inline_completion(completion, TRUE);
    gtk_entry_completion_set_inline_selection(completion, TRUE);

    /*commands*/
    append_list(store, ":about");
    append_list(store, ":help");

    /*connect completion*/
    gtk_entry_set_completion(GTK_ENTRY(entry), completion);

    debug("completion");
    debug("gtk main entering");
    gtk_main();

    /*gtk end*/
    debug("Sure.");

    /*clean up*/
    if(curl_handle)
        curl_easy_cleanup(curl_handle);
    curl_global_cleanup();

    free(s);
    free(rslt);
    free(mark);
    free(word);
    if(searchStr)
        free(searchStr);
    return 0;
}
 /*!
 * \fn G_MODULE_EXPORT void openAssistantNewCsu(GtkWidget *widget, gpointer data)
 *  Open the assistant for a new csu file
 * \param[in] widget the widget which send the signal
 * \param[in] data the globalData
 */
G_MODULE_EXPORT void openAssistantNewCsu(GtkWidget *widget, gpointer data)
{
    globalData *user_data = (globalData*) data;
    char home_path[SIZE_MAX_FILE_NAME]="";
    gchar system_path[SIZE_MAX_FILE_NAME]="";
    list_game_config *ptr_list_config;
    gint i;

    #ifndef PORTABLE
    readHomePathSlash(home_path);
    readSystemPath(system_path);
    #else
    readHomePath(system_path);
    #endif // PORTABLE

    /* creating of the assistant */
    user_data->ptr_new_csu_file_assistant = gtk_assistant_new();

    /* Set the assistant windows */
    gtk_window_set_transient_for(GTK_WINDOW(user_data->ptr_new_csu_file_assistant),GTK_WINDOW(user_data->ptr_main_window));
    gtk_window_set_gravity(GTK_WINDOW(user_data->ptr_new_csu_file_assistant),GDK_GRAVITY_CENTER);
    gtk_window_set_position(GTK_WINDOW(user_data->ptr_new_csu_file_assistant),GTK_WIN_POS_CENTER_ON_PARENT);
    gtk_window_set_modal(GTK_WINDOW(user_data->ptr_new_csu_file_assistant),TRUE);
    gtk_window_set_type_hint(GTK_WINDOW(user_data->ptr_new_csu_file_assistant),GDK_WINDOW_TYPE_HINT_DIALOG);
    gtk_window_resize(GTK_WINDOW(user_data->ptr_new_csu_file_assistant),700,400);
    gtk_window_set_title(GTK_WINDOW(user_data->ptr_new_csu_file_assistant),_("New csu file assistant"));

    /*Set the signal of the assistant */
    g_signal_connect(user_data->ptr_new_csu_file_assistant,"delete-event", G_CALLBACK(deleteEventAssistantNewCsu),user_data);
    g_signal_connect(user_data->ptr_new_csu_file_assistant,"cancel", G_CALLBACK(deleteAssistantNewCsu),user_data);
    g_signal_connect(user_data->ptr_new_csu_file_assistant,"prepare", G_CALLBACK(preparePageAssistantNewCsu),user_data);
    g_signal_connect(user_data->ptr_new_csu_file_assistant,"close", G_CALLBACK(endAssistantNewCsu),user_data);


    /* Set the first page */
    GtkWidget *grid_1 = getWidgetFromBuilder(user_data->ptr_builder,"grid_new_csu_file_assistant_1");
    gtk_assistant_append_page(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),grid_1);
    gtk_assistant_set_page_type(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),grid_1,GTK_ASSISTANT_PAGE_INTRO);
    gtk_assistant_set_page_title(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),grid_1,_("General information"));

    /* Configure the file chooser */
    gtk_entry_set_max_length(GTK_ENTRY(gtk_grid_get_child_at(GTK_GRID(grid_1),1,0)),SIZE_MAX_FILE_NAME/8);
    gtk_file_chooser_set_current_folder_file(GTK_FILE_CHOOSER(gtk_grid_get_child_at(GTK_GRID(grid_1),1,1)),g_file_new_for_path(g_locale_to_utf8(system_path,-1,NULL,NULL,NULL)),NULL);

    /* Set the combo  box of the game configuration */
    GtkWidget *combo_config = gtk_combo_box_text_new();
    ptr_list_config = readConfigListFile(home_path);
    for (i=0 ; i<ptr_list_config->nb_config ; i++)
        gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(combo_config),i,NULL,ptr_list_config->name_game_config[i]);
    gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(combo_config),ptr_list_config->nb_config,NULL,_("Add a new game configuration"));
    gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(combo_config),ptr_list_config->nb_config +1,NULL,_("Use an other game configuration"));
    gtk_grid_attach(GTK_GRID(grid_1),combo_config,1,3,1,1);
    g_signal_connect(combo_config,"changed", G_CALLBACK(chooseGameConfigurationNewAssistant),user_data);
    closeListGameConfig(ptr_list_config);


    /* Set the second page */
    GtkWidget *scrolled_window_name = getWidgetFromBuilder(user_data->ptr_builder,"scrolled_window_new_csu_file_assistant_2");
    gtk_assistant_append_page(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),scrolled_window_name);
    gtk_assistant_set_page_type(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),scrolled_window_name,GTK_ASSISTANT_PAGE_CONTENT);
    gtk_assistant_set_page_title(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),scrolled_window_name,_("Player's names"));

    /* Set the grid */
    GtkWidget *grid_name = gtk_grid_new();
    gtk_grid_set_column_spacing(GTK_GRID(grid_name),10);
    gtk_grid_set_row_spacing(GTK_GRID(grid_name),10);
    gtk_grid_set_column_homogeneous(GTK_GRID(grid_name),TRUE);
    #if GTK_MINOR_VERSION >= 12
    gtk_widget_set_margin_end(grid_name,10);
    gtk_widget_set_margin_start(grid_name,10);
    #else
    gtk_widget_set_margin_right(grid_name,10);
    gtk_widget_set_margin_left(grid_name,10);
    #endif // GTK_MINOR_VERSION
    gtk_widget_set_margin_top(grid_name,10);
    gtk_widget_set_margin_bottom(grid_name,10);
    gtk_container_add(GTK_CONTAINER(gtk_bin_get_child(GTK_BIN(scrolled_window_name))),grid_name);


    /* Set the third page */
    GtkWidget *grid_3 = getWidgetFromBuilder(user_data->ptr_builder,"grid_new_csu_file_assistant_3");
    gtk_assistant_append_page(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),grid_3);
    gtk_assistant_set_page_type(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),grid_3,GTK_ASSISTANT_PAGE_CONFIRM);
    gtk_assistant_set_page_title(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),grid_3,_("Distributor and validation"));

    GtkWidget *combo_distributor = gtk_combo_box_text_new();
    gtk_grid_attach(GTK_GRID(grid_3),combo_distributor,1,0,1,1);
    g_signal_connect(combo_distributor,"changed", G_CALLBACK(validAssistantNewCsuThree),user_data);

    cleanAssistantNewCsu(user_data);
    gtk_widget_show_all(user_data->ptr_new_csu_file_assistant);
}
Exemple #17
0
/* Create the ardesia bar window. */
GtkWidget *
create_bar_window (CommandLine *commandline,
                   GtkWidget   *parent)
{
  GtkWidget *bar_window = (GtkWidget *) NULL;
  BarData *bar_data = (BarData *) NULL;
  GError *error = (GError *) NULL;
  gchar *file = UI_FILE;
  gint x = 0;
  gint y = 0;
  gint width = 0;
  gint height = 0;


  /* Set up style for ardesia */
  gchar* gtkcss_file = get_xdg_config_file("ardesia/gtk.css");
  if (gtkcss_file)
    {
      GtkCssProvider *css = gtk_css_provider_new ();
      gtk_css_provider_load_from_path (css, gtkcss_file, NULL);
      g_free (gtkcss_file);
      gtk_style_context_add_provider_for_screen (gdk_screen_get_default(),
                                                 GTK_STYLE_PROVIDER(css),
                                                 GTK_STYLE_PROVIDER_PRIORITY_USER);
    }
    
  bar_gtk_builder = gtk_builder_new ();

  if (commandline->position>2)
    {
      /* North or south. */
      file = UI_HOR_FILE;
    }
  else
    {

      /* East or west. */
      if (gdk_screen_height () < 720)
        {
          /* 
           * The bar is too long and then I use an horizontal layout;
           * this is done to have the full bar for net book and screen
           * with low vertical resolution.
           */
          file = UI_HOR_FILE;
          commandline->position=NORTH;
        }

    }


  /* Load the bar_gtk_builder file with the definition of the ardesia bar gui. */
  gtk_builder_add_from_file (bar_gtk_builder, file, &error);
  if (error)
    {
      g_warning ("Failed to load builder file: %s", error->message);
      g_error_free (error);
      g_object_unref (bar_gtk_builder);
      bar_gtk_builder = NULL;
      return bar_window;
    }

  bar_data = init_bar_data ();

  bar_window = GTK_WIDGET (gtk_builder_get_object (bar_gtk_builder, BAR_WIDGET_NAME));
  gtk_widget_set_name (bar_window, BAR_WIDGET_NAME);
    
  /* Connect all the callback from bar_gtk_builder xml file. */
  gtk_builder_connect_signals (bar_gtk_builder, (gpointer) bar_data);

  //gtk_window_set_transient_for (GTK_WINDOW (bar_window), GTK_WINDOW (parent));

  if (commandline->decorated)
    {
      gtk_window_set_decorated (GTK_WINDOW (bar_window), TRUE);
    }

  gtk_window_get_size (GTK_WINDOW (bar_window) , &width, &height);

  /* x and y will be the bar left corner coordinates. */
  calculate_initial_position (bar_window,
                              &x,
                              &y,
                              width,
                              height,
                              commandline->position);

  /* The position is calculated respect the top left corner
   * and then I set the north west gravity. 
   */
  gtk_window_set_gravity (GTK_WINDOW (bar_window), GDK_GRAVITY_NORTH_WEST);

  /* Move the window in the desired position. */
  gtk_window_move (GTK_WINDOW (bar_window), x, y);


  return bar_window;
}
Exemple #18
0
static void
draw_zoom_animation_composited (GdkScreen *gscreen,
				int x, int y, int w, int h,
				GdkPixbuf *pixbuf,
				PanelOrientation orientation)
{
	GtkWidget *win;
	CompositedZoomData *zoom;
	int wx = 0, wy = 0;

	w += 2;
	h += 2;

	zoom = g_slice_new (CompositedZoomData);
	zoom->size = MIN (w,h);
	zoom->size_start = zoom->size;
	zoom->size_end = zoom->size * ZOOM_FACTOR;
	zoom->orientation = orientation;
	zoom->opacity = 1.0;
	zoom->pixbuf = g_object_ref (pixbuf);
	zoom->timeout_id = 0;

	win = gtk_window_new (GTK_WINDOW_POPUP);

	gtk_window_set_screen (GTK_WINDOW (win), gscreen);
	gtk_window_set_keep_above (GTK_WINDOW (win), TRUE);
	gtk_window_set_decorated (GTK_WINDOW (win), FALSE);
	gtk_widget_set_app_paintable(win, TRUE);
	gtk_widget_set_visual (win, gdk_screen_get_rgba_visual (gscreen));

	gtk_window_set_gravity (GTK_WINDOW (win), GDK_GRAVITY_STATIC);
	gtk_window_set_default_size (GTK_WINDOW (win),
				     w * ZOOM_FACTOR, h * ZOOM_FACTOR);

	switch (zoom->orientation) {
	case PANEL_ORIENTATION_TOP:
		wx = x - w * (ZOOM_FACTOR / 2);
		wy = y;
		break;

	case PANEL_ORIENTATION_RIGHT:
		wx = x - w * (ZOOM_FACTOR - 1);
		wy = y - h * (ZOOM_FACTOR / 2);
		break;

	case PANEL_ORIENTATION_BOTTOM:
		wx = x - w * (ZOOM_FACTOR / 2);
		wy = y - h * (ZOOM_FACTOR - 1);
		break;

	case PANEL_ORIENTATION_LEFT:
		wx = x;
		wy = y - h * (ZOOM_FACTOR / 2);
		break;

	default:
		break;
	}

	gtk_window_move (GTK_WINDOW (win), wx, wy);

	g_signal_connect (G_OBJECT (win), "draw",
			  G_CALLBACK (zoom_draw), zoom);

	/* see doc for gtk_widget_set_app_paintable() */
	gtk_widget_realize (win);
	gtk_widget_show (win);

	zoom->timeout_id = g_timeout_add (ZOOM_DELAY,
					  (GSourceFunc) zoom_timeout,
					  win);
}
Exemple #19
0
gint notification_window_open(const gchar *message, const gchar *submessage,
			      guint timeout)
{
	GtkWidget *window;
	GtkWidget *vbox;
	GtkWidget *msglabel;
	GtkWidget *sublabel;
	GdkRectangle rect;
	gint x, y;
	GtkRequisition requisition;

	if (notify_window.window) {
		notification_window_destroy();
	}

	window = gtk_window_new(GTK_WINDOW_POPUP);
	gtk_window_set_title(GTK_WINDOW(window), _("Notification"));
	gtk_window_set_wmclass(GTK_WINDOW(window), "notification", "Sylpheed");
	gtk_container_set_border_width(GTK_CONTAINER(window), 8);
	gtk_widget_set_events(window, GDK_EXPOSURE_MASK|GDK_BUTTON_MOTION_MASK|GDK_POINTER_MOTION_MASK|GDK_POINTER_MOTION_HINT_MASK|GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK|GDK_ENTER_NOTIFY_MASK|GDK_LEAVE_NOTIFY_MASK);
	gtk_window_set_skip_taskbar_hint(GTK_WINDOW(window), TRUE);
	gtk_window_set_gravity(GTK_WINDOW(window), GDK_GRAVITY_SOUTH_EAST);
	gtk_widget_set_size_request(window, NOTIFICATIONWINDOW_WIDTH, -1);
	gtk_widget_realize(window);
	gdk_window_set_type_hint(window->window, GDK_WINDOW_TYPE_HINT_NOTIFICATION);

	/* move window bottom-right */
	get_work_area(&rect);
	x = rect.x + rect.width - NOTIFICATIONWINDOW_WIDTH - 2;
	if (x < 0) x = 0;
	y = rect.y + rect.height - NOTIFICATIONWINDOW_HEIGHT - 2;
	if (y < 0) y = 0;
	gtk_window_move(GTK_WINDOW(window), x, y);

	g_signal_connect(G_OBJECT(window), "destroy",
			 G_CALLBACK(nwin_destroy_cb), NULL);
	g_signal_connect(G_OBJECT(window), "button_press_event",
			 G_CALLBACK(nwin_button_pressed), NULL);
	g_signal_connect(G_OBJECT(window), "enter_notify_event",
			 G_CALLBACK(nwin_entered), NULL);
	g_signal_connect(G_OBJECT(window), "motion_notify_event",
			 G_CALLBACK(nwin_motion_notify), NULL);

	vbox = gtk_vbox_new(FALSE, 8);
	gtk_container_add(GTK_CONTAINER(window), vbox);

	msglabel = gtk_label_new(message);
	gtk_box_pack_start(GTK_BOX(vbox), msglabel, FALSE, FALSE, 0);

	sublabel = gtk_label_new("");
	gtk_label_set_ellipsize(GTK_LABEL(sublabel), PANGO_ELLIPSIZE_END);
	gtk_label_set_markup(GTK_LABEL(sublabel), submessage);
	gtk_box_pack_start(GTK_BOX(vbox), sublabel, FALSE, FALSE, 0);
	gtk_label_set_justify(GTK_LABEL(sublabel), GTK_JUSTIFY_LEFT);
	gtk_misc_set_alignment(GTK_MISC(sublabel), 0.0, 0.5);

	gtk_widget_show_all(window);

	/* adjust window size and position */
	gtk_widget_get_child_requisition(window, &requisition);
	notify_window.width = NOTIFICATIONWINDOW_WIDTH;
	notify_window.height = MAX(requisition.height, NOTIFICATIONWINDOW_HEIGHT);
	gtk_widget_set_size_request(window, NOTIFICATIONWINDOW_WIDTH, notify_window.height);
	y = rect.y + rect.height - notify_window.height - 2;
	if (y < 0) y = 0;
	gtk_window_move(GTK_WINDOW(window), x, y);

	if (timeout == 0)
		timeout = 1;
	notify_window.notify_tag = g_timeout_add(timeout * 1000,
						 notify_timeout_cb, NULL);

	debug_print("notification window created\n");

	notify_window.window = window;
	notify_window.msglabel = msglabel;
	notify_window.sublabel = sublabel;
	notify_window.x = x;
	notify_window.y = y;
	notify_window.fade_length = 0;
	notify_window.fade_count = 0;
	notify_window.notify_event_count = 0;
	notify_window.timeout = timeout;

	return 0;
}
static int PickIWad (WadStuff *wads, int numwads, bool showwin, int defaultiwad)
{
	GtkWidget *window;
	GtkWidget *vbox = nullptr;
	GtkWidget *hbox = nullptr;
	GtkWidget *bbox = nullptr;
	GtkWidget *widget;
	GtkWidget *tree;
	GtkWidget *check;
	GtkListStore *store;
	GtkCellRenderer *renderer;
	GtkTreeViewColumn *column;
	GtkTreeSelection *selection;
	GtkTreeIter iter, defiter;
	int close_style = 0;
	int i;
	char caption[100];

	// Create the dialog window.
	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	mysnprintf(caption, countof(caption), GAMESIG " %s: Select an IWAD to use", GetVersionString());
	gtk_window_set_title (GTK_WINDOW(window), caption);
	gtk_window_set_position (GTK_WINDOW(window), GTK_WIN_POS_CENTER);
	gtk_window_set_gravity (GTK_WINDOW(window), GDK_GRAVITY_CENTER);
	gtk_container_set_border_width (GTK_CONTAINER(window), 10);
	g_signal_connect (window, "delete_event", G_CALLBACK(gtk_main_quit), NULL);
	g_signal_connect (window, "key_press_event", G_CALLBACK(CheckEscape), NULL);

	// Create the vbox container.
	if (gtk_box_new) // Gtk3
		vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
	else if (gtk_vbox_new) // Gtk2
		vbox = gtk_vbox_new (FALSE, 10);

	gtk_container_add (GTK_CONTAINER(window), vbox);

	// Create the top label.
	widget = gtk_label_new (GAMENAME " found more than one IWAD\nSelect from the list below to determine which one to use:");
	gtk_box_pack_start (GTK_BOX(vbox), widget, false, false, 0);

	if (gtk_widget_set_halign && gtk_widget_set_valign) // Gtk3
	{
		gtk_widget_set_halign (widget, GTK_ALIGN_START);
		gtk_widget_set_valign (widget, GTK_ALIGN_START);
	}
	else if (gtk_misc_set_alignment && gtk_misc_get_type) // Gtk2
		gtk_misc_set_alignment (GTK_MISC(widget), 0, 0);

	// Create a list store with all the found IWADs.
	store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT);
	for (i = 0; i < numwads; ++i)
	{
		const char *filepart = strrchr (wads[i].Path, '/');
		if (filepart == NULL)
			filepart = wads[i].Path;
		else
			filepart++;
		gtk_list_store_append (store, &iter);
		gtk_list_store_set (store, &iter,
			0, filepart,
			1, wads[i].Name.GetChars(),
			2, i,
			-1);
		if (i == defaultiwad)
		{
			defiter = iter;
		}
	}

	// Create the tree view control to show the list.
	tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL(store));
	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes ("IWAD", renderer, "text", 0, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW(tree), column);
	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes ("Game", renderer, "text", 1, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW(tree), column);
	gtk_box_pack_start (GTK_BOX(vbox), GTK_WIDGET(tree), true, true, 0);
	g_signal_connect(G_OBJECT(tree), "button_press_event", G_CALLBACK(DoubleClickChecker), &close_style);
	g_signal_connect(G_OBJECT(tree), "key_press_event", G_CALLBACK(AllowDefault), window);

	// Select the default IWAD.
	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(tree));
	gtk_tree_selection_select_iter (selection, &defiter);

	// Create the hbox for the bottom row.
	if (gtk_box_new) // Gtk3
		hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	else if (gtk_hbox_new) // Gtk2
		hbox = gtk_hbox_new (FALSE, 0);

	gtk_box_pack_end (GTK_BOX(vbox), hbox, false, false, 0);

	// Create the "Don't ask" checkbox.
	check = gtk_check_button_new_with_label ("Don't ask me this again");
	gtk_box_pack_start (GTK_BOX(hbox), check, false, false, 0);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(check), !showwin);

	// Create the OK/Cancel button box.
	if (gtk_button_box_new) // Gtk3
		bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
	else if (gtk_hbutton_box_new) // Gtk2
		bbox = gtk_hbutton_box_new ();

	gtk_button_box_set_layout (GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
	gtk_box_set_spacing (GTK_BOX(bbox), 10);
	gtk_box_pack_end (GTK_BOX(hbox), bbox, false, false, 0);

	// Create the OK button.
	widget = gtk_button_new_with_label ("OK");

	gtk_box_pack_start (GTK_BOX(bbox), widget, false, false, 0);

	gtk_widget_set_can_default (widget, true);

	gtk_widget_grab_default (widget);
	g_signal_connect (widget, "clicked", G_CALLBACK(ClickedOK), &close_style);
	g_signal_connect (widget, "activate", G_CALLBACK(ClickedOK), &close_style);

	// Create the cancel button.
	widget = gtk_button_new_with_label ("Cancel");

	gtk_box_pack_start (GTK_BOX(bbox), widget, false, false, 0);
	g_signal_connect (widget, "clicked", G_CALLBACK(gtk_main_quit), &window);

	// Finally we can show everything.
	gtk_widget_show_all (window);

	gtk_main ();

	if (close_style == 1)
	{
		GtkTreeModel *model;
		GValue value = { 0, { {0} } };

		// Find out which IWAD was selected.
		gtk_tree_selection_get_selected (selection, &model, &iter);
		gtk_tree_model_get_value (GTK_TREE_MODEL(model), &iter, 2, &value);
		i = g_value_get_int (&value);
		g_value_unset (&value);

		// Set state of queryiwad based on the checkbox.
		queryiwad = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(check));
	}
	else
	{
		i = -1;
	}

	if (GTK_IS_WINDOW(window))
	{
		gtk_widget_destroy (window);
		// If we don't do this, then the X window might not actually disappear.
		while (g_main_context_iteration (NULL, FALSE)) {}
	}

	return i;
}
Exemple #21
0
int CUIHandler::CreateMainWnd()
{
    GtkWidget* menubar;
    GtkWidget* filemenu, *helpmenu;
    GtkWidget* file, *quit;
    GtkWidget* help, *about;
    GtkWidget* vbox, *hbox;
    GtkWidget* align;
    GtkToolItem* toolitem;
    GtkWidget* frame;
    GtkWidget* status_menu;
    GtkWidget* status_menu_item;
    GtkWidget *hseparator;

    GtkWidget *statusbarHBox;
    GtkWidget *statusbarFrameConnection;
    GtkWidget *statusbarAlignmentConnection;
    GtkWidget *statusbarHBoxConnection;
    GtkWidget *statusbarFrameFps;
    GtkWidget *statusbarAlignmentFps;
    GtkWidget *statusbarFrameResolution;
    GtkWidget *statusbarAlignmentResolution;

    // set up tray icon
    trayIcon = gtk_status_icon_new_from_pixbuf(disconnectedTrayIcon);
    gtk_status_icon_set_tooltip(trayIcon, TRAY_TOOLTIP_DISCONNECTED);
    gtk_status_icon_set_visible(trayIcon, TRUE);
    g_signal_connect(G_OBJECT(trayIcon), "popup-menu", G_CALLBACK(status_popup), NULL);
    g_signal_connect(G_OBJECT(trayIcon), "activate", G_CALLBACK(status_activate), NULL);

    // set up main mainWindow
    mainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(mainWindow), "delete_event", G_CALLBACK(delete_event), NULL);
    g_signal_connect(G_OBJECT(mainWindow), "destroy", G_CALLBACK(destroy), NULL);
    g_signal_connect(G_OBJECT(mainWindow), "window_state_event", G_CALLBACK(track_minimize), NULL);

    gtk_window_set_title(GTK_WINDOW(mainWindow), SMARTCAM_WND_TITLE);
    gtk_container_set_border_width(GTK_CONTAINER(mainWindow), 1);
    gtk_window_set_resizable(GTK_WINDOW(mainWindow), FALSE);
    gtk_widget_set_size_request(mainWindow, MAIN_WND_WIDTH, MAIN_WND_HEIGHT);
    gtk_window_set_position(GTK_WINDOW(mainWindow), GTK_WIN_POS_NONE);
    gtk_window_set_gravity(GTK_WINDOW (mainWindow), GDK_GRAVITY_CENTER);

    gtk_window_set_default_icon(connectedTrayIcon);

    GdkPixbuf* icon;
    GList* icon_list = NULL;
    icon = gdk_pixbuf_new_from_file(DATADIR "/icons/hicolor/16x16/apps/smartcam.png", NULL);
    icon_list = g_list_append(icon_list, icon);
    icon = gdk_pixbuf_new_from_file(DATADIR "/icons/hicolor/22x22/apps/smartcam.png", NULL);
    icon_list = g_list_append(icon_list, icon);
    icon = gdk_pixbuf_new_from_file(DATADIR "/icons/hicolor/24x24/apps/smartcam.png", NULL);
    icon_list = g_list_append(icon_list, icon);
    icon = gdk_pixbuf_new_from_file(DATADIR "/icons/hicolor/32x32/apps/smartcam.png", NULL);
    icon_list = g_list_append(icon_list, icon);
    icon = gdk_pixbuf_new_from_file(DATADIR "/icons/hicolor/48x48/apps/smartcam.png", NULL);
    icon_list = g_list_append(icon_list, icon);

    gtk_window_set_default_icon_list(icon_list);

    g_list_foreach(icon_list, (GFunc)g_object_unref, NULL );
    g_list_free(icon_list);

    // create menubar
    menubar = gtk_menu_bar_new();

    filemenu = gtk_menu_new();
    file = gtk_menu_item_new_with_mnemonic("_File");
    miSettings = gtk_image_menu_item_new_with_label("Settings");
    gtk_image_menu_item_set_image(
        GTK_IMAGE_MENU_ITEM(miSettings),
        gtk_image_new_from_stock(GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU));
    g_signal_connect(G_OBJECT(miSettings), "activate", G_CALLBACK(OnSettingsClicked), (gpointer) NULL);
    quit = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, NULL);
    g_signal_connect(G_OBJECT(quit), "activate", G_CALLBACK(destroy), NULL);

    gtk_menu_shell_append(GTK_MENU_SHELL(menubar), file);
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), filemenu);
    gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), miSettings);
    gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), quit);

    helpmenu = gtk_menu_new();
    help = gtk_menu_item_new_with_mnemonic("_Help");
    about = gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT, NULL);
    g_signal_connect(about, "activate", G_CALLBACK(show_about_dialog), NULL);

    gtk_menu_shell_append(GTK_MENU_SHELL(menubar), help);
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), helpmenu);
    gtk_menu_shell_append(GTK_MENU_SHELL(helpmenu), about);

    // create toolbar
    toolbar = gtk_toolbar_new();
    gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);
    gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar), GTK_ICON_SIZE_MENU);
    g_object_set(G_OBJECT(toolbar), "can-focus", FALSE, NULL);

    tbSettings = gtk_tool_button_new_from_stock(GTK_STOCK_PREFERENCES);
    g_signal_connect(G_OBJECT(tbSettings), "clicked", G_CALLBACK(OnSettingsClicked), NULL);
    g_object_set(G_OBJECT(tbSettings), "tooltip-text", "Settings", NULL);
    g_object_set(G_OBJECT(tbSettings), "can-focus", FALSE, NULL);
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tbSettings, 0);

    tbDisconnect = gtk_tool_button_new_from_stock(GTK_STOCK_DISCONNECT);
    g_signal_connect(G_OBJECT(tbDisconnect), "clicked", G_CALLBACK(OnDisconnectClicked), NULL);
    g_object_set(G_OBJECT(tbDisconnect), "tooltip-text", "Disconnect", NULL);
    g_object_set(G_OBJECT(tbDisconnect), "can-focus", FALSE, NULL);
    g_object_set(G_OBJECT(tbDisconnect), "sensitive", FALSE, NULL); // disable disconnect
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tbDisconnect, 1);

    // create preview frame
    vbox = gtk_vbox_new(FALSE, 1);
    gtk_container_set_border_width(GTK_CONTAINER(vbox), 1);
    gtk_container_add(GTK_CONTAINER(mainWindow), vbox);

    align = gtk_alignment_new(0.5, 0.5, 0, 0);

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

    image = gtk_image_new_from_pixbuf(logoIcon);

    gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), align, TRUE, TRUE, 0);

    gtk_container_add(GTK_CONTAINER(align), frame);
    gtk_container_add(GTK_CONTAINER(frame), image);

    // set up status bar
    hseparator = gtk_hseparator_new ();
    gtk_box_pack_start (GTK_BOX (vbox), hseparator, FALSE, FALSE, 0);

    statusbarHBox = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (vbox), statusbarHBox, FALSE, FALSE, 0);

    statusbarFrameConnection = gtk_frame_new (NULL);
    gtk_box_pack_start (GTK_BOX (statusbarHBox), statusbarFrameConnection, TRUE, TRUE, 0);
    gtk_widget_set_size_request (statusbarFrameConnection, 55, 25);
    gtk_frame_set_label_align (GTK_FRAME (statusbarFrameConnection), 0, 0);
    gtk_frame_set_shadow_type (GTK_FRAME (statusbarFrameConnection), GTK_SHADOW_IN);

    statusbarAlignmentConnection = gtk_alignment_new (0, 0.5, 1, 1);
    gtk_container_add (GTK_CONTAINER (statusbarFrameConnection), statusbarAlignmentConnection);
    gtk_alignment_set_padding (GTK_ALIGNMENT (statusbarAlignmentConnection), 0, 0, 3, 0);

    statusbarHBoxConnection = gtk_hbox_new (FALSE, 0);
    gtk_container_add (GTK_CONTAINER (statusbarAlignmentConnection), statusbarHBoxConnection);

    if(pSmartEngine->GetSettings().connectionType == CONN_BLUETOOTH)
    {
        statusbarImageConnection = gtk_image_new_from_pixbuf(btStatusIcon);
    }
    else
    {
        statusbarImageConnection = gtk_image_new_from_pixbuf(inetStatusIcon);
    }
    gtk_box_pack_start (GTK_BOX (statusbarHBoxConnection), statusbarImageConnection, FALSE, FALSE, 0);
    gtk_misc_set_alignment (GTK_MISC (statusbarImageConnection), 0, 0.5);

    statusbarLabelConnection = gtk_label_new ("Disconnected");
    gtk_box_pack_start (GTK_BOX (statusbarHBoxConnection), statusbarLabelConnection, TRUE, TRUE, 0);
    gtk_misc_set_alignment (GTK_MISC (statusbarLabelConnection), 0, 0.5);

    statusbarFrameFps = gtk_frame_new (NULL);
    gtk_box_pack_start (GTK_BOX (statusbarHBox), statusbarFrameFps, TRUE, TRUE, 0);
    gtk_widget_set_size_request (statusbarFrameFps, 17, 25);
    gtk_frame_set_shadow_type (GTK_FRAME (statusbarFrameFps), GTK_SHADOW_IN);

    statusbarAlignmentFps = gtk_alignment_new (0, 0.5, 1, 1);
    gtk_container_add (GTK_CONTAINER (statusbarFrameFps), statusbarAlignmentFps);
    gtk_alignment_set_padding (GTK_ALIGNMENT (statusbarAlignmentFps), 0, 0, 3, 0);

    statusbarLabelFps = gtk_label_new (CUIHandler::STATUS_LABEL_FPS);
    gtk_container_add (GTK_CONTAINER (statusbarAlignmentFps), statusbarLabelFps);
    gtk_misc_set_alignment (GTK_MISC (statusbarLabelFps), 0, 0.5);

    statusbarFrameResolution = gtk_frame_new (NULL);
    gtk_box_pack_start (GTK_BOX (statusbarHBox), statusbarFrameResolution, TRUE, TRUE, 0);
    gtk_widget_set_size_request (statusbarFrameResolution, 92, 25);
    gtk_frame_set_shadow_type (GTK_FRAME (statusbarFrameResolution), GTK_SHADOW_IN);

    statusbarAlignmentResolution = gtk_alignment_new (0, 0.5, 1, 1);
    gtk_container_add (GTK_CONTAINER (statusbarFrameResolution), statusbarAlignmentResolution);
    gtk_alignment_set_padding (GTK_ALIGNMENT (statusbarAlignmentResolution), 0, 0, 3, 0);

    statusbarLabelResolution = gtk_label_new (CUIHandler::STATUS_LABEL_RESOLUTION);
    gtk_container_add (GTK_CONTAINER (statusbarAlignmentResolution), statusbarLabelResolution);
    gtk_misc_set_alignment (GTK_MISC (statusbarLabelResolution), 0, 0.5);

    gtk_widget_show_all(mainWindow);

    return 0;
}
Exemple #22
0
/**
 * gimp_session_info_apply_geometry:
 * @info:
 * @monitor:
 * @current_monitor:
 *
 * Apply the geometry stored in the session info object to the
 * associated widget.
 **/
void
gimp_session_info_apply_geometry (GimpSessionInfo *info,
                                  GdkMonitor      *current_monitor,
                                  gboolean         apply_stored_monitor)
{
  GdkMonitor     *monitor;
  GdkRectangle    rect;
  GdkRectangle    work_rect;
  GdkGravity      gravity;
  GdkWindowHints  hints;
  gint            width;
  gint            height;

  g_return_if_fail (GIMP_IS_SESSION_INFO (info));
  g_return_if_fail (GTK_IS_WINDOW (info->p->widget));
  g_return_if_fail (GDK_IS_MONITOR (current_monitor));

  monitor = current_monitor;

  if (apply_stored_monitor)
    {
      GdkDisplay *display = gdk_monitor_get_display (current_monitor);
      gint        n_monitors;

      n_monitors = gdk_display_get_n_monitors (display);

      if (info->p->monitor                  != DEFAULT_MONITOR &&
          monitor_number (info->p->monitor) <  n_monitors)
        {
          monitor = info->p->monitor;
        }
      else
        {
          monitor = gdk_display_get_primary_monitor (display);
        }
    }

  gdk_monitor_get_geometry (monitor, &rect);
  gdk_monitor_get_workarea (monitor, &work_rect);

  info->p->x += rect.x;
  info->p->y += rect.y;

  if (gimp_session_info_get_remember_size (info) &&
      info->p->width  > 0 &&
      info->p->height > 0)
    {
      width  = info->p->width;
      height = info->p->height;
    }
  else
    {
      GtkRequisition requisition;

      gtk_widget_get_preferred_size (info->p->widget, NULL, &requisition);

      width  = requisition.width;
      height = requisition.height;
    }

  info->p->x = CLAMP (info->p->x,
                      work_rect.x,
                      work_rect.x + work_rect.width  - width);
  info->p->y = CLAMP (info->p->y,
                      work_rect.y,
                      work_rect.y + work_rect.height - height);

  if (gimp_session_info_get_remember_size (info) &&
      info->p->width  > 0 &&
      info->p->height > 0)
    {
      /*  This used to call gtk_window_set_default_size() which worked
       *  fine in gtk2 and should continue to work, but doesn't for
       *  dock windows. gtk_window_resize() seems to work fine for all
       *  windows. Leave this comment here until we figured what's
       *  going on...
       *
       *  XXX If we end up updating this code, also do the same to the
       *  gtk_window_resize() call in gimp_session_info_dialog_show()
       *  signal handler.
       */
#if 1
      gtk_window_resize (GTK_WINDOW (info->p->widget),
                         info->p->width, info->p->height);
#else
      gtk_window_set_default_size (GTK_WINDOW (info->p->widget),
                                   info->p->width, info->p->height);
#endif
   }

  gtk_window_get_size (GTK_WINDOW (info->p->widget), &width, &height);

  gravity = GDK_GRAVITY_NORTH_WEST;

  if (info->p->right_align && info->p->bottom_align)
    {
      gravity = GDK_GRAVITY_SOUTH_EAST;
    }
  else if (info->p->right_align)
    {
      gravity = GDK_GRAVITY_NORTH_EAST;
    }
  else if (info->p->bottom_align)
    {
      gravity = GDK_GRAVITY_SOUTH_WEST;
    }

  if (gravity == GDK_GRAVITY_SOUTH_EAST ||
      gravity == GDK_GRAVITY_NORTH_EAST)
    info->p->x = work_rect.x + work_rect.width - width;

  if (gravity == GDK_GRAVITY_SOUTH_WEST ||
      gravity == GDK_GRAVITY_SOUTH_EAST)
    info->p->y = work_rect.y + work_rect.height - height;

  gtk_window_set_gravity (GTK_WINDOW (info->p->widget), gravity);
  gtk_window_move (GTK_WINDOW (info->p->widget),
                   info->p->x, info->p->y);

  hints = GDK_HINT_USER_POS;
  if (gimp_session_info_get_remember_size (info))
    hints |= GDK_HINT_USER_SIZE;

  gtk_window_set_geometry_hints (GTK_WINDOW (info->p->widget),
                                 NULL, NULL, hints);

  /*  Window managers and windowing systems suck. They have their own
   *  ideas about WM standards and when it's appropriate to honor
   *  user/application-set window positions and when not. Therefore,
   *  use brute force and "manually" position dialogs whenever they
   *  are shown. This is important especially for transient dialogs,
   *  because window managers behave even "smarter" then...
   */
  if (GTK_IS_WINDOW (info->p->widget))
    g_signal_connect (info->p->widget, "show",
                      G_CALLBACK (gimp_session_info_dialog_show),
                      info);
}