Ejemplo n.º 1
0
void on_button_send_clicked(GtkButton * button, gpointer user_data)
{
    GtkWidget *wid;
    gchar *text = NULL;
    gchar *buff = NULL;
    int result;

    SESSION_STATE *session;
    session = interface_get_session(GTK_WIDGET(button));
    if (session->single_line) {
            wid = interface_get_widget(GTK_WIDGET(button), "input1_entry");
            if (!wid)
                    g_warning("Can NOT acces input1 combo.");
            text =
                (gchar *)
                gtk_entry_get_text(GTK_ENTRY(wid));
      if (session->telnet == NULL || !session->telnet->echo)
                cmd_entry_update_cache (GTK_WIDGET (button));
    } else {
            GtkTextIter start, end;
            GtkTextBuffer *buffer;
            wid = interface_get_widget(GTK_WIDGET(button), "input2");
            buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(wid));
            gtk_text_buffer_get_start_iter(buffer, &start);
            gtk_text_buffer_get_end_iter(buffer, &end);
            text =
                gtk_text_buffer_get_text(buffer, &start, &end, TRUE);
    }

    if (session->telnet->fd == NO_CONNECTION )
    {
            g_warning("no connection");
    }
    else
    {
        gsize size;
        ATM*  match;
        buff = g_strdup(text);  // make a copy of text for modules
        size = strlen(text);
        module_call_all_data_out(config->modules, session, &buff,
                                 &size);
        // send to sever the text modified by modules 
        if (!(match = atm_find_fire (session, buff, size, session->aliases, TRUE, &result))
            &&
            !(match = atm_find_fire (session, buff, size, config->aliases, TRUE, &result)))
        {
            send_command (session, buff, size);
        }
        else
        {
            if (!result)
                interface_show_script_errors (match, "Alias errors:");
        }
        g_free(buff);
    }
}
Ejemplo n.º 2
0
void interface_update_controls (PlayList *playlist)
{
	g_return_if_fail (playlist != NULL);
	
	GtkWidget *prev;
	GtkWidget *next;
	
	prev = interface_get_widget ("button_prev");
	next = interface_get_widget ("button_next");
	
	gtk_widget_set_sensitive (prev, playlist_has_prev (playlist));
	gtk_widget_set_sensitive (next, playlist_has_next (playlist));
}
Ejemplo n.º 3
0
void interface_echo_message(SESSION_STATE * session, gchar * text)
{
  GtkTextView *out;
  GtkTextBuffer *buffer;
  GtkTextIter start, end;
  GtkTextMark *mark;
  GtkTextTag *tag;

  out =
      (GtkTextView *) interface_get_widget(GTK_WIDGET(session->tab),
             "output1");
  buffer = gtk_text_view_get_buffer(out);

  // save position
  gtk_text_buffer_get_end_iter(buffer, &end);
  mark = gtk_text_buffer_create_mark(buffer, NULL, &end, TRUE);

  // insert text
  gtk_text_buffer_insert(buffer, &end, text, -1);

  // Put some color on it
  tag =
      get_fg_color_tag(buffer, 128 * RED + 128 * GREEN + 255 * BLUE);

  gtk_text_buffer_get_iter_at_mark(buffer, &start, mark);
  gtk_text_buffer_get_end_iter(buffer, &end);
  gtk_text_buffer_apply_tag(buffer, tag, &start, &end);

  // insert newline
  gtk_text_buffer_insert(buffer, &end, "\n", -1);

  //scroll to bottom
  output_scroll_to_bottom(session->tab);
}
Ejemplo n.º 4
0
void music_artist_setup_tree (void)
{
    GtkCellRenderer *renderer;
    GtkTreeViewColumn *column;
    GtkTreeSortable *sortable;

    // TreeView holen
    artist_tree = GTK_TREE_VIEW (interface_get_widget ("treeview_artists"));

    // Name
    renderer = gtk_cell_renderer_text_new ();
    column = gtk_tree_view_column_new_with_attributes ("Interpret", renderer,
             "text", COL_ARTIST_NAME, NULL);
    gtk_tree_view_column_set_sort_column_id (column, COL_ARTIST_NAME);
    gtk_tree_view_append_column (GTK_TREE_VIEW (artist_tree), column);

    // Store erstellen
    artist_store = gtk_list_store_new (COLS_ARTIST, G_TYPE_STRING, G_TYPE_INT);

    // Sortierung
    sortable = GTK_TREE_SORTABLE (artist_store);
    gtk_tree_sortable_set_sort_func (sortable, COL_ARTIST_NAME, sort_artist_compare_func,
                                     GINT_TO_POINTER(COL_ARTIST_NAME), NULL);
    gtk_tree_sortable_set_sort_column_id (sortable, COL_ARTIST_NAME, GTK_SORT_ASCENDING);

    // Store dem Tree anhängen
    gtk_tree_view_set_model (GTK_TREE_VIEW (artist_tree),
                             GTK_TREE_MODEL (artist_store));
}
Ejemplo n.º 5
0
void interface_image_add(GtkWidget * tab, GtkTextIter * iter,
       GdkPixbuf * pixbuf)
{
  if (pixbuf == NULL)
    return;
  GtkTextView *out1 = GTK_TEXT_VIEW(interface_get_widget(tab, "output1"));
  GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(out1));

  GtkTextIter it;
  if (iter != NULL)
    it = *iter;
  else
    gtk_text_buffer_get_end_iter(buffer, &it);

  gtk_text_buffer_insert_pixbuf(buffer, &it, pixbuf);
  
  // append tag name, if needed
  SESSION_STATE *session = g_object_get_data(G_OBJECT(tab), "session");
  if (!session->imagemapName) return;
  
  GtkTextTag *t = gtk_text_tag_new (session->imagemapName);
  g_object_set_data(G_OBJECT(t), "imagemap",
                    g_strdup(session->imagemapName));

  GtkTextTagTable *table =
      gtk_text_buffer_get_tag_table(buffer);
  gtk_text_tag_table_add(table, t);
  gtk_text_buffer_apply_tag(buffer, t, &it, &it);
  g_signal_connect(G_OBJECT(t), "event",
                   G_CALLBACK(on_tag_click), session);
}
Ejemplo n.º 6
0
// Setzt auf dem Play Button auf Play oder Pause
void interface_set_playimage(const gchar *stock_id)
{
	GtkImage *playimage = NULL;

	playimage = GTK_IMAGE( interface_get_widget ("image_play"));
	if (playimage != NULL) {
		gtk_image_set_from_stock(playimage, stock_id, GTK_ICON_SIZE_BUTTON);
	}
}
Ejemplo n.º 7
0
gboolean on_input2_key_press_event(GtkWidget * widget, GdkEventKey * event,
           gpointer user_data)
{
  if ((event->state & GDK_SHIFT_MASK) && (event->keyval == 10)) {
    on_button_send_clicked(GTK_BUTTON
               (interface_get_widget
          (widget, "button_send")), NULL);
  }
  return FALSE;
}
Ejemplo n.º 8
0
// Zeige das vorherige Widget im Platzhalter an (für Fullscreen Modus)
void interface_show_previous_module (void)
{
	// Fullscreen Modus verlassen
	GtkWidget *tractasono;
	
	tractasono = interface_get_widget ("vbox_tractasono");
	
	gtk_widget_hide (module.fullscreen);
	gtk_widget_show (tractasono);
}
Ejemplo n.º 9
0
// Tritt auf, nachdem der "Jetzt importieren" Button gedrückt wurde
void on_button_settings_import_now_clicked (GtkWidget *widget, gpointer user_data)
{
	GtkWidget *entry;
	const gchar *pfad;
	
	entry = interface_get_widget ("settings_entry_import_path");
	
	pfad = gtk_entry_get_text (GTK_ENTRY(entry));
	
	settings_import_music (pfad);
}
Ejemplo n.º 10
0
GtkTextIter interface_get_current_position(SESSION_STATE * session)
{
  GtkTextView *out1 = GTK_TEXT_VIEW(interface_get_widget(session->tab, "output1"));

  GtkTextBuffer *buffer =
      gtk_text_view_get_buffer(GTK_TEXT_VIEW(out1));

  GtkTextIter it;
  gtk_text_buffer_get_end_iter(buffer, &it);
  return it;
}
Ejemplo n.º 11
0
// Event-Handler für den Vollbild Button
void on_button_fullscreen_clicked(GtkWidget *widget, gpointer user_data)
{
	// Spezialbehandlung für den Fullscreen Modus
	
	GtkWidget *vbox_main;
	GtkWidget *tractasono;
	
	vbox_main = interface_get_widget ("vbox_main");
	tractasono = interface_get_widget ("vbox_tractasono");
	
	gtk_widget_hide (tractasono);
	
	gtk_widget_ref(module.fullscreen);
	if (module.fullscreen->parent) {
		gtk_container_remove(GTK_CONTAINER(module.fullscreen->parent), module.fullscreen);
		gtk_container_add(GTK_CONTAINER(vbox_main), module.fullscreen);
	}
	

	gtk_widget_show(module.fullscreen);
	
}
Ejemplo n.º 12
0
// Fügt eine Zeile Text ein
void settings_import_messages_add (gchar *text)
{
	GtkTextView *view;
	GtkTextBuffer *buf;
	GtkTextIter iter;
	
	view = (GtkTextView*) interface_get_widget ("settings_textview_import");
	buf = gtk_text_view_get_buffer (view);

	gtk_text_buffer_get_end_iter (buf, &iter);
	gtk_text_buffer_insert (buf, &iter, g_strdup_printf ("%s\n", text), -1);
	
}
Ejemplo n.º 13
0
// TreeView für die Tracks erstellen
void music_track_setup_tree (void)
{
    GtkCellRenderer *renderer;
    GtkTreeViewColumn *column;
    GtkTreeSortable *sortable;

    // TreeView holen
    track_tree = GTK_TREE_VIEW (interface_get_widget ("treeview_tracks"));

    // Track Nummer
    renderer = gtk_cell_renderer_text_new ();
    column = gtk_tree_view_column_new_with_attributes ("Nr.", renderer,
             "text", COL_TRACK_NR, NULL);
    gtk_tree_view_column_set_sort_column_id (column, COL_TRACK_NR);
    gtk_tree_view_append_column (GTK_TREE_VIEW (track_tree), column);

    // Titel
    renderer = gtk_cell_renderer_text_new ();
    column = gtk_tree_view_column_new_with_attributes ("Titel", renderer,
             "text", COL_TRACK_TITLE, NULL);
    gtk_tree_view_column_set_sort_column_id (column, COL_TRACK_TITLE);
    gtk_tree_view_append_column (GTK_TREE_VIEW (track_tree), column);

    // Artist
    renderer = gtk_cell_renderer_text_new ();
    column = gtk_tree_view_column_new_with_attributes ("Artist", renderer,
             "text", COL_TRACK_ARTIST, NULL);
    gtk_tree_view_column_set_sort_column_id (column, COL_TRACK_ARTIST);
    gtk_tree_view_append_column (GTK_TREE_VIEW (track_tree), column);

    // Album
    renderer = gtk_cell_renderer_text_new ();
    column = gtk_tree_view_column_new_with_attributes ("Album", renderer,
             "text", COL_TRACK_ALBUM, NULL);
    gtk_tree_view_column_set_sort_column_id (column, COL_TRACK_ALBUM);
    gtk_tree_view_append_column (GTK_TREE_VIEW (track_tree), column);


    // Store erstellen
    track_store = gtk_list_store_new (COLS_TRACK, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT);

    // Sortierung
    sortable = GTK_TREE_SORTABLE (track_store);
    gtk_tree_sortable_set_sort_column_id (sortable, COL_TRACK_NR, GTK_SORT_ASCENDING);

    // Store dem Tree anhängen
    gtk_tree_view_set_model (GTK_TREE_VIEW (track_tree),
                             GTK_TREE_MODEL (track_store));
}
Ejemplo n.º 14
0
void output_scroll_to_bottom(GtkWidget * tab)
{
  GtkTextView *out1, *out2;
  GtkTextIter iter;

  while (gtk_events_pending())
    gtk_main_iteration();

  // scroll to bottom
  out1 = GTK_TEXT_VIEW(interface_get_widget(tab, "output1"));
  out2 = GTK_TEXT_VIEW(interface_get_widget(tab, "output2"));
  if (!(GTK_WIDGET_VISIBLE(out2))) {
    //only scroll if the second output is not visible
    //that means that we're scrolled to the very bottom ...
    gtk_text_buffer_get_end_iter(gtk_text_view_get_buffer
               (out1), &iter);
    gtk_text_view_scroll_to_iter(out1, &iter, 0.0, TRUE, 0.0,
               1.0);
  }
  //second output ALWAYS gets scrolled to the bottom
  gtk_text_buffer_get_end_iter(gtk_text_view_get_buffer(out2),
             &iter);
  gtk_text_view_scroll_to_iter(out2, &iter, 0.0, TRUE, 0.0, 1.0);
}
Ejemplo n.º 15
0
void settings_init()
{
	g_message ("\tSettings Modul init");
	
	// Aktuelle Version anzeigen
	gchar *text;
	GtkWidget *label_version;
	label_version = interface_get_widget ("label_settings_version");
	if (strcmp (REVISION, "")) {
		text = g_strdup_printf ("%s %s", PACKAGE, REVISION);
	} else {
		text = g_strdup_printf ("%s %s", PACKAGE, VERSION);
	}
	gtk_label_set_text (GTK_LABEL (label_version), text);
	g_free (text);
}
Ejemplo n.º 16
0
void interface_output_append(GtkWidget * tab, gchar * data, gsize len)
{
  SESSION_STATE *session;
  gsize i, j, pos;
  GtkTextView *output;

  g_return_if_fail(tab != NULL && data != NULL);
  session = g_object_get_data(G_OBJECT(tab), "session");
  g_return_if_fail(session != NULL);
  
  // change output window if need be
  output = owindowlist_active_textview (session->windowlist);
  
  // default output is the main window
  if (!output)
    output = GTK_TEXT_VIEW (interface_get_widget(tab, "output1"));
  
  for (i = pos = 0; i < len; i++) {
    if (data[i] == 27) {
      internal_output_add_text(session, output, data + pos, i - pos,
             &session->ansi);
      // looking for the end of ansi code 
      for (j = i; j < len; j++) {
        if (data[j] == 'm')
          break;
      }
      // telnet_process should not let any incopleted ansi code to pass 
      if (j == len) {
        g_warning
            ("incomplete ANSI code found in processed data.");
        return;
      }
      // update ANSI state
      internal_update_ansi_state(&session->ansi,
               data + i, j - i + 1);
      i = j;
      pos = j + 1;
    }
  }
  internal_output_add_text(session, output, data + pos, len - pos,
         &session->ansi);
}
Ejemplo n.º 17
0
void update_gaugelist (GAUGELIST *gl)
{
  g_return_if_fail (gl->sess->tab != NULL);
  GtkWidget *gaugebar = interface_get_widget (gl->sess->tab, "gaugebar");
  g_return_if_fail (gaugebar != NULL);
  
  // no gauges -> goodbye ...
  if (!gl->list) {
    gtk_widget_hide (gaugebar);
    return;
  }
  
  // we have some gauges - must show the widget
  gtk_widget_show (gaugebar);
  
  // set gaugelist pointer
  g_object_set_data (GTK_OBJECT (gaugebar), "gaugelist", gl);
  
  gtk_widget_queue_draw (gaugebar);
}
Ejemplo n.º 18
0
void interface_set_playing (PlayerState state)
{
	GtkWidget *progress_area;
	progress_area = interface_get_widget ("alignment_progress");
	
	switch(state) {
		case STATE_PLAY_LOCAL:	
			interface_set_playimage("gtk-media-pause");
			gtk_widget_show (progress_area);
			break;
		case STATE_PLAY_STREAM:
			interface_set_playimage("gtk-media-stop");
			gtk_widget_hide (progress_area);
			break;
		case STATE_PLAY_NOTHING:
			interface_set_playimage("gtk-media-play");
			interface_set_songinfo ("", "");
			gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress), 0);
			break;
	}
}
Ejemplo n.º 19
0
void settings_import_music (const gchar *path)
{
	GtkWidget *button;
	gchar *text;
	
	button = interface_get_widget ("button_settings_import_now");
	
	gtk_widget_set_sensitive (button, FALSE);
	
	text = g_strdup_printf ("Starte Import von %s", path);
	settings_import_messages_add (text);
	g_debug ("%s", text);
	
	// Starte Scan
	recursive_dir (path);
	
	text = g_strdup_printf ("Import beendet!");
	settings_import_messages_add (text);
	g_debug ("%s", text);
	
	gtk_widget_set_sensitive (button, TRUE);
}
Ejemplo n.º 20
0
void interface_echo_user_input(SESSION_STATE * session, gchar * text)
{
  GtkTextView *out;
  GtkTextBuffer *buffer;
  GtkTextIter start, end;
  GtkTextMark *mark;
  GtkTextTag *tag;
  GtkTextTagTable *tagtable;

  out = (GtkTextView *) interface_get_widget(GTK_WIDGET(session->tab),
             "output1");
  buffer = gtk_text_view_get_buffer(out);
  tagtable = gtk_text_buffer_get_tag_table(buffer);

  // save position
  gtk_text_buffer_get_end_iter(buffer, &end);
  mark = gtk_text_buffer_create_mark(buffer, NULL, &end, TRUE);

  // insert text
  gtk_text_buffer_insert(buffer, &end, text, -1);

  // Put some color on it
  tag = gtk_text_tag_table_lookup(tagtable, "user_input_tag");
  if (!tag)
    tag = gtk_text_buffer_create_tag(buffer, "user_input_tag",
             "foreground",
             session->ufg_color, NULL);

  gtk_text_buffer_get_iter_at_mark(buffer, &start, mark);
  gtk_text_buffer_get_end_iter(buffer, &end);
  gtk_text_buffer_apply_tag(buffer, tag, &start, &end);

  // delete mark 
  gtk_text_buffer_delete_mark(buffer, mark);

  //scroll to bottom
  output_scroll_to_bottom(session->tab);
}
Ejemplo n.º 21
0
void interface_output_append_line (GtkWidget * tab)
{
  // the horizontal line currently consists of 40 spaces with strikethrough on

  GtkTextView *out1 = GTK_TEXT_VIEW(interface_get_widget(tab, "output1"));
  GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(out1));
  gchar spaces[41];
  int i, offset;
  
  GtkTextIter start, end;
  gtk_text_buffer_get_end_iter(buffer, &end);
  offset = gtk_text_iter_get_offset(&end);

  for (i = 0; i < 40; i++) spaces[i] = ' ';
  spaces[40] = '\0';
  gtk_text_buffer_insert(buffer, &end, spaces, -1);

  // apply some tags on inserted text 
  gtk_text_buffer_get_iter_at_offset(buffer, &start, offset);
  gtk_text_buffer_get_end_iter(buffer, &end);

  gtk_text_buffer_apply_tag_by_name (buffer, "horzline", &start, &end);
}
Ejemplo n.º 22
0
void on_data_available(gpointer tab, gint fd, GdkInputCondition cond)
{
  GtkWidget *notebook, *top;
  gchar *buff = NULL;
  gsize len = 0;
  SESSION_STATE *session;
  session = g_object_get_data(G_OBJECT(tab), "session");

  telnet_process(session->telnet, &buff, &len);

  //if nothing to process - don't process
  if( len > 0 )
    process_text(session, buff, len);

  // if top != current window change title
  top = gtk_widget_get_toplevel(GTK_WIDGET(tab));
  //if (top != interface_get_active_window()) {
  if (!gtk_window_is_active(GTK_WINDOW(top)))
  {
    gchar *icon;
    gtk_window_set_title(GTK_WINDOW(top), "### MudMagic ###");
    icon = g_build_filename( mudmagic_data_directory(), "interface", "mudmagic2.xpm", NULL);
    gtk_window_set_icon_from_file(GTK_WINDOW(top), icon, NULL);
    g_free(icon);
  }

  if (session->telnet->fd < 0 ) // connection close occurs
  { 
    GtkWidget *wid, *message;
    gchar *label;
    gint response;
    gtk_input_remove(session->input_event_id);
    session->input_event_id = -1;
    wid = g_object_get_data(G_OBJECT(session->tab), "input1_entry");

    g_return_if_fail(wid != NULL);
    if ( ! gtk_entry_get_visibility (GTK_ENTRY(wid)) ) {
      interface_input_shadow(session, FALSE);
      gtk_entry_set_text(GTK_ENTRY(wid), "");
    }

    while (1) {
      wid =
          interface_create_object_by_name
          ("dialog_connection_close");
      if (wid == NULL) {
        g_warning
            ("can't create 'dialog_connection_close");
      }
      message =
          interface_get_widget(wid,
             "connection_close_message");
      if (message == NULL) {
        g_warning
            ("can't get 'dialog_connection_close");
      }
      label =
          g_strdup_printf
          ("Connection to %s:%d has been close.",
           session->game_host, session->game_port);
      gtk_label_set_text(GTK_LABEL(message), label);
      g_free(label);
      response = gtk_dialog_run(GTK_DIALOG(wid));
      gtk_widget_destroy(wid);
      if (response == 0) {  // stay disconnect
        break;
      }
      if (response == 1) {  // try to reconnect
		if (session->pconn) proxy_connection_close (session->pconn);
		session->pconn = proxy_connection_open(
    	  session->game_host, session->game_port, proxy_get_by_name (session->proxy, config->proxies)
	    );
		if (session->pconn) session->telnet->fd = session->pconn->sock; else session->telnet->fd = NO_CONNECTION;

        if (session->telnet->fd == NO_CONNECTION ) {
                          interface_messagebox (GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
                  network_errmsg (session->telnet->fd));
          continue;
        }
        session->input_event_id =
            gtk_input_add_full(session->telnet->fd,
                   GDK_INPUT_READ,(GdkInputFunction)on_data_available, NULL, tab, NULL);
        break;
      }
      if (response == 2) {  // close tab
        interface_remove_tab(tab);
        return;
      }

    }
  }
  // if tab != current tab change label color 
  notebook = gtk_widget_get_ancestor(tab, GTK_TYPE_NOTEBOOK);
  if (notebook) {
    GtkWidget *label;
    GtkWidget *current_tab;

    current_tab =
        gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
                gtk_notebook_get_current_page
                (GTK_NOTEBOOK(notebook))
        );
    if (tab != current_tab) {
      label =
          gtk_notebook_get_tab_label(GTK_NOTEBOOK
                   (notebook),
                   GTK_WIDGET(tab));
      if (label) {
        GtkWidget* icon;
        icon = g_object_get_data (G_OBJECT (label), "label_icon");
        gtk_image_set_from_stock (GTK_IMAGE (icon),
                GTK_STOCK_NO,
                GTK_ICON_SIZE_MENU); 
      }
    }
  }
}
Ejemplo n.º 23
0
void interface_init (int argc, char *argv[])
{
	g_message ("Interface init");
	
	// GTK initialisieren
	g_message ("\tGTK init");
	gtk_init(&argc, &argv);
	
	ui = NULL;
	mainwindow = NULL;
	vbox_placeholder = NULL;
	keyboard = NULL;
	vbox_tractasono = NULL;
	actual_entry = NULL;
	
	module.music = NULL;
	module.radio = NULL;
	module.server = NULL;
	module.import = NULL;
	module.settings = NULL;
	module.fullscreen = NULL;
	module.disc = NULL;
	module.previous = NULL;
	
	// Das Interface laden
	GString* buildfile = g_string_new(g_get_current_dir());
	buildfile = g_string_append(buildfile, "/data/tractasono.ui");
	if (g_file_test(buildfile->str, G_FILE_TEST_EXISTS) == FALSE) {
		buildfile = g_string_assign(buildfile, INSTALLED_GLADE);
	}
	if (g_file_test(buildfile->str, G_FILE_TEST_EXISTS) == FALSE) {
		g_warning ("Die Glade Datei konnte nicht geladen werden!");
		exit (0);
	}
	
	GError* error = NULL;
	ui = gtk_builder_new();
	if (!gtk_builder_add_from_file (ui, buildfile->str, &error)) {
		g_error ("Couldn't load builder file: %s", error->message);
		g_error_free (error);
	}
	
	// Verbinde die Signale automatisch mit dem Interface
	gtk_builder_connect_signals (ui, NULL);
	
	// Hauptfenster holen
	mainwindow = interface_get_widget ("window_main");
	
	// Icon setzen
	const gchar* icon = INSTALLED_ICON;
	if (g_file_test(icon, G_FILE_TEST_EXISTS) == TRUE) {
		gtk_window_set_icon_from_file (GTK_WINDOW (mainwindow), icon, NULL);
	}

	// Placeholder holen
	vbox_placeholder = interface_get_widget ("vbox_placeholder");
	
	// Tractasono Root holen
	vbox_tractasono = interface_get_widget ("vbox_tractasono");

	// Die einzelnen Windows laden und referenzieren
	module.music = g_object_ref (interface_get_widget ("modul_music"));
	module.disc = g_object_ref (interface_get_widget ("vbox_disc"));
	module.server = g_object_ref (interface_get_widget ("servermodul"));
	module.settings = g_object_ref (interface_get_widget ("vbox_settings"));
	module.radio = g_object_ref (interface_get_widget ("radiomodul"));
	module.fullscreen = g_object_ref (interface_get_widget ("eventbox_fullscreen"));

	// Keyboard laden
	GtkWidget *vbox_placeholder_keyboard = NULL;
	vbox_placeholder_keyboard = interface_get_widget ("vbox_placeholder_keyboard");
	keyboard = interface_get_widget ("alignment_keyboard");
	gtk_widget_reparent(keyboard, vbox_placeholder_keyboard);
	gtk_widget_hide(keyboard);
	
	// Progressbar laden
	progress = GTK_PROGRESS_BAR( interface_get_widget ("range_song"));
	
	// LCD
	GtkWidget *lcdspace;
	lcdspace = interface_get_widget ("lcdbox");
	lcd = lcd_new ();
	gtk_container_add (GTK_CONTAINER (lcdspace), GTK_WIDGET (lcd));
	
	// LCD Text initial setzen
	gchar *title = db_settings_get_text ("LCD", "StartText");
	lcd_set_title (LCD (lcd), title);
	
	// Widget anzeigen
	gtk_widget_show (GTK_WIDGET (lcd));
	
	// Einzelne GUI Module initialisieren
	disc_init ();
	radio_init ();
	music_init ();
	//server_init ();
	settings_init ();
	fullscreen_init ();
	
	// Musik von Anfang an anzeigen
	interface_show_module(module.music);
}
Ejemplo n.º 24
0
void on_input1_activate(GtkEntry * entry, gpointer user_data)
{
/*  GList *history = NULL;
  GList *list;
  gchar *text, *text2;
  gpointer p;

  GtkWidget *combo;
*/

  GtkWidget *wid;
/*
  SESSION_STATE *session;
  session =
      interface_get_session(GTK_WIDGET(GTK_WIDGET(entry)->parent)->
          parent);
  g_return_if_fail(session != NULL);

  //combo = interface_get_widget( GTK_WIDGET(entry), "input1" );
  combo = GTK_WIDGET(entry)->parent;
  //gtk_widget_show( GTK_COMBO(combo)->popwin );

  list = GTK_LIST(GTK_COMBO(combo)->list)->children;

  // add text from entry in history
  text = (gchar *) gtk_entry_get_text(entry);
  if (!session->telnet->echo)
    history = g_list_append(history, g_strdup(text));

  while (list != NULL) {
    text2 =
        GTK_LABEL(GTK_BIN(GTK_ITEM(list->data))->child)->label;
    if (strcmp(text, text2)) {
      history = g_list_append(history, g_strdup(text2));
    }
    if (g_list_length(history) > HISTORY_LEN)
      break;
    list = g_list_next(list);
  }
*/
  // get vertical box "input" 
  wid = GTK_WIDGET(GTK_WIDGET(entry)->parent)->parent;
  // get send button
  wid = interface_get_widget(wid, "button_send");
  // call send button 
  on_button_send_clicked(GTK_BUTTON(wid), NULL);
/*
  if (history != NULL)
    gtk_combo_set_popdown_strings(GTK_COMBO(combo), history);
  //destry history ( we don't need it anymore )
  while (history) {
    p = history->data;
    g_free(p);
    history = g_list_remove(history, p);
  }
  g_list_free(history);
*/
  //do we want to keep the last typed in data in our entry field?
  if (config->keepsent) {
    gtk_editable_select_region(GTK_EDITABLE(entry), 0, -1);
  } else {
    //clear out the entry bar after each input
    gtk_editable_delete_text(GTK_EDITABLE(entry), 0, -1);
  }
}
Ejemplo n.º 25
0
void on_modules_cell_toggle_callback(GtkCellRenderer * cell,
             gchar * path, gpointer model)
{
  GtkTreeIter iter;
  gboolean *on;
  gchar *name;
  MODULE_ENTRY *entry;
  GList *l;

  gtk_tree_model_get_iter_from_string(model, &iter, path);
  gtk_tree_model_get(model, &iter, COL_ENABLE, &on, COL_NAME, &name,
         -1);
  if (on) {
    entry = module_get_by_name(config->modules, name);
    GtkWidget *menubar;
    GtkWidget *toolbar;
    // reset menu for any existing window
    if (entry->functions) {
      l = config->windows;
      while (l) {
        menubar =
            interface_get_widget(GTK_WIDGET
               (l->data),
               "menubar_main");
        if (menubar)
          if (entry->functions->menu_reset)
            entry->functions->
                menu_reset((gpointer)
                     menubar);

        toolbar =
            interface_get_widget(GTK_WIDGET
               (l->data),
               "toolbar_main");
        if (toolbar)
          if (entry->functions->
              toolbar_reset)
            entry->functions->
                toolbar_reset((gpointer) toolbar);
        l = g_list_next(l);
      }

      // call session_open for all existing sessions
      if (entry->functions->session_close) {
        l = config->sessions;
        while (l) {
          entry->functions->session_close(l->
                  data);
          l = g_list_next(l);
        }
      }
    }
    if (module_unload(entry)) {
      gtk_list_store_set(model, &iter, COL_ENABLE, FALSE,
             -1);
      // change the menu 
    } else {
      char *message;
      message =
          g_strdup_printf
          (" Module \"%s\" can't be unloaded !", name);
      interface_display_message(message);
      g_free(message);
    }
  } else {
    if (module_load
        ((entry =
          module_get_by_name(config->modules, name)))) {
      GtkWidget *menubar;
      GtkWidget *toolbar;
      if (entry->functions) {
        // modify menu for any existing window
        l = config->windows;
        while (l) {
          menubar =
              interface_get_widget(GTK_WIDGET
                 (l->data),
                 "menubar_main");
          if (menubar)
            if (entry->functions->
                menu_modify)
              entry->functions->
                  menu_modify((gpointer) menubar);
          toolbar =
              interface_get_widget(GTK_WIDGET
                 (l->data),
                 "toolbar_main");
          if (toolbar)
            if (entry->functions->
                toolbar_modify)
              entry->functions->
                  toolbar_modify((gpointer) toolbar);
          l = g_list_next(l);
        }
        // call session_open for all existing sessions
        if (entry->functions->session_open) {
          l = config->sessions;
          while (l) {
            entry->functions->
                session_open(l->data);
            l = g_list_next(l);
          }
        }
      }
      gtk_list_store_set(model, &iter, COL_ENABLE, TRUE,
             -1);
    } else {
      char *message;
      message =
          g_strdup_printf
          (" Module \"%s\" can't be loaded !", name);
      interface_display_message(message);
      g_free(message);
    }
  }
  g_free(name);
}
Ejemplo n.º 26
0
void on_modules1_activate(GtkMenuItem * menuitem, gpointer user_data)
{
  GtkWidget *wid;
  GtkWidget *tree_view;
  GtkWidget *text_view;
  GtkTreeIter iter;
  GtkCellRenderer *renderer;
  GtkTreeViewColumn *column;
  GtkListStore *store;
  GtkTreeSelection *select;
  GList *l;
  wid = interface_create_object_by_name("window_modules");

  store = gtk_list_store_new(N_COL,
           G_TYPE_BOOLEAN,
           G_TYPE_STRING,
           G_TYPE_STRING, G_TYPE_STRING);

  l = config->modules;
  while (l) {
    gtk_list_store_append(store, &iter);
    gtk_list_store_set(store, &iter,
           COL_ENABLE,
           ((MODULE_ENTRY *) l->data)->
           functions ? TRUE : FALSE, COL_NAME,
           ((MODULE_ENTRY *) l->data)->name,
           COL_DESCRIPTION,
           ((MODULE_ENTRY *) l->data)->description,
           -1);
    l = g_list_next(l);
  }

  tree_view = interface_get_widget(wid, "modules_treeview");
  text_view = interface_get_widget(wid, "modules_desc");
  gtk_tree_view_set_model(GTK_TREE_VIEW(tree_view),
        GTK_TREE_MODEL(store));


  renderer = gtk_cell_renderer_toggle_new();
  g_object_set(renderer, "activatable", TRUE, NULL);
  g_signal_connect(renderer, "toggled",
       (GCallback) on_modules_cell_toggle_callback,
       store);

  column =
      gtk_tree_view_column_new_with_attributes("Enable", renderer,
                 "active", COL_ENABLE,
                 NULL);
  gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);

  renderer = gtk_cell_renderer_text_new();
  //g_object_set(renderer, "editable", TRUE, NULL );

  column =
      gtk_tree_view_column_new_with_attributes("Module", renderer,
                 "text",
                 COL_DESCRIPTION,
                 NULL);
  gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);

  select = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
  gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);

  g_print("[on_modules1_activate]\n");
}
Ejemplo n.º 27
0
gboolean on_tag_click(GtkTextTag * texttag, GObject * obj,
          GdkEvent * event, GtkTextIter * iter, gpointer sess)
{
  if ((event->type != GDK_BUTTON_PRESS) && (event->type != GDK_BUTTON_RELEASE))
    return FALSE;

  // get object data
  SESSION_STATE *session = (SESSION_STATE *) sess;
  if (session == NULL)
    return FALSE;

  char *action = 0, *type = 0, *menustr = 0;
  gboolean menu = FALSE;
  action = g_object_get_data(G_OBJECT(texttag), "action");
  type = g_object_get_data(G_OBJECT(texttag), "type");
  menustr = g_object_get_data(G_OBJECT(texttag), "menu");
  if (!strcmp (menustr, "yes")) menu = TRUE;

  // it must be a link
  if ((!action) || (!type))
    return FALSE;

  if (event->type == GDK_BUTTON_PRESS) {
    // Display the MXP menu if needed. No other action here.
    
    GdkEventButton *eb = (GdkEventButton *) event;
    if (eb->button != 3) // only for right button
      return FALSE;
    // Display the menu if this is a menu link. Do nothing otherwise.
    if (!menu) return FALSE;
    // TODO: will the objects get free-ed correctly when not needed ?
    GtkWidget *m = gtk_menu_new ();
    gchar **actions = g_strsplit (action, "|", 0);
    gchar **a = actions;
    while (*a) {
      GtkWidget *item = gtk_menu_item_new_with_label (*a);
      gtk_menu_append (GTK_MENU (m), item);
      g_object_set_data (G_OBJECT (item), "command", g_strdup (*a));
      g_signal_connect (G_OBJECT (item), "activate",
          GTK_SIGNAL_FUNC (linkmenu_activate), sess);
      gtk_widget_show (item);
      ++a;
    }
    g_strfreev (actions);
    gtk_menu_popup (GTK_MENU (m), NULL, NULL, NULL, NULL,
        eb->button, eb->time);
    return TRUE;  // don't display the default menu
  }
  
  // if we are here, the event is GDK_BUTTON_RELEASE

  // URL link ?
  if (type && strcmp(type, "url") == 0) {
    //in the future, let them choose which browser
    //they have. For now: IE or Mozilla
    int ret = try_to_execute_url( WEB_BROWSER, action );
    if( !ret )
      interface_display_message("Unable to visit with current web browser\n" );
    return FALSE;
  }
  
  // SEND link ?
  if (type && strcmp(type, "command") == 0) {
    // send the command
    // send the command, first one if it's a menu
    char *act = g_strdup (action);
    if (menu) {  // replace first "|" with " "
      char *pos = strchr (act, '|');
      if (pos) act[pos - act] = '\0';
    }
    send_command (session, act, strlen(act));
    g_free (act);
    return FALSE;
  }

  // image map ?
  char *imagemap = g_object_get_data(G_OBJECT(texttag), "imagemap");
  if (imagemap) {
    // it's an image map - send the location ...
    GdkPixbuf *pixbuf = gtk_text_iter_get_pixbuf (iter);
    if (!pixbuf) return FALSE;
    GdkRectangle rect;
    
    GtkTextView *view = GTK_TEXT_VIEW (interface_get_widget
        (session->tab, "output1"));
    gtk_text_view_get_iter_location (view, iter, &rect);
    int x = rect.x;
    int y = rect.y;

    int ex = ((GdkEventButton *) event)->x;
    int ey = ((GdkEventButton *) event)->y;
    gchar *cmd = g_strdup_printf ("%s?%d,%d", imagemap, ex-x, ey-y);
    send_command (session, cmd, strlen (cmd));
    g_free (cmd);
    return FALSE;
  }
  
  // none of the above - do nothing
  return FALSE;
}